public synchronized ChannelFactory getChannelFactoryInternal ( Class < ? > type , boolean isPersistent ) throws ChannelFactoryException { if ( type == null ) { throw new InvalidChannelFactoryException ( "ChannelFactory type is null" ) ; } ChannelFactory factory = null ; ChannelFactoryDataImpl cfd = null ; try { // check to see if an instance of the channel factory already exists; if // not the contract of this method states that we will create it // cfd = channelFactories . get ( type ) ; if ( cfd != null ) { factory = cfd . getChannelFactory ( ) ; } if ( null == factory ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Create channel factory; " + type ) ; } // create a new channel factory reflectively & register // it by its type factory = ( ChannelFactory ) type . newInstance ( ) ; if ( isPersistent ) { initChannelFactory ( type , factory , null ) ; } } } catch ( Exception exp ) { FFDCFilter . processException ( exp , getClass ( ) . getName ( ) + ".getChannelFactoryInternal" , "675" , this , new Object [ ] { cfd } ) ; throw new InvalidChannelFactoryException ( "Can't create instance of channel factory " + type . getName ( ) + " " + exp . getMessage ( ) ) ; } return factory ; }
This method will do the real work of accessing a channel factory . Note multiple methods in this class call into this method some of which are synchronized . According to the input parameters the factory that is returned may or may not be persisted in the framework . In some cases like simple channel adds there is no need for the factory in the framework an instantiation is only needed to verify that the factory is valid . Other times like during chain initialization persistence is necessary .