@ Override public Object createResource ( final ResourceInfo resInfo ) throws Exception { final boolean trace = TraceComponent . isAnyTracingEnabled ( ) ; if ( trace && tc . isEntryEnabled ( ) ) Tr . entry ( this , tc , "createResource" , resInfo ) ; Object connectionFactory ; lock . readLock ( ) . lock ( ) ; try { if ( ! isInitialized . get ( ) ) { // Switch to write lock for lazy initialization lock . readLock ( ) . unlock ( ) ; lock . writeLock ( ) . lock ( ) ; try { if ( ! isInitialized . get ( ) ) initPrivileged ( ) ; } finally { // Downgrade to read lock for rest of method lock . readLock ( ) . lock ( ) ; lock . writeLock ( ) . unlock ( ) ; } } checkAccess ( ) ; ConnectionManager conMgr = AccessController . doPrivileged ( new PrivilegedExceptionAction < ConnectionManager > ( ) { @ Override public ConnectionManager run ( ) throws Exception { return conMgrSvc . getConnectionManager ( resInfo , AbstractConnectionFactoryService . this ) ; } } ) ; connectionFactory = getManagedConnectionFactory ( null ) . createConnectionFactory ( conMgr ) ; } catch ( Exception x ) { if ( trace && tc . isEntryEnabled ( ) ) Tr . exit ( this , tc , "createResource" , x ) ; throw x ; } catch ( Error x ) { if ( trace && tc . isEntryEnabled ( ) ) Tr . exit ( this , tc , "createResource" , x ) ; throw x ; } finally { lock . readLock ( ) . unlock ( ) ; } // Only connection factories defined in the server configuration are tracked for the app recycle coordinator. if ( isServerDefined ) { ComponentMetaData cData = ComponentMetaDataAccessorImpl . getComponentMetaDataAccessor ( ) . getComponentMetaData ( ) ; if ( cData != null ) appsToRecycle . add ( cData . getJ2EEName ( ) . getApplication ( ) ) ; } if ( trace && tc . isEntryEnabled ( ) ) Tr . exit ( this , tc , "createResource" , connectionFactory ) ; return connectionFactory ; }
Create a connection factory .