private ChannelData addChannelInternal ( String channelName , Class < ? > factoryType , Map < Object , Object > inputPropertyBag , int weight ) throws ChannelException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "addChannelInternal: channelName=" + channelName + ", factoryType=" + factoryType + ", weight=" + weight ) ; } // Ensure the weight is non negative. if ( weight < 0 ) { throw new InvalidWeightException ( "Invalid weight for channel, " + weight ) ; } // Ensure the input channel name is not null if ( null == channelName ) { throw new InvalidChannelNameException ( "Input channel name is null" ) ; } // Check if the channel name already exists in the configuration. ChannelData channelData = channelDataMap . get ( channelName ) ; if ( null != channelData ) { throw new InvalidChannelNameException ( "Channel already exists: " + channelName ) ; } // Check the factory type and its validity. No need to actually retrieve the // factory. We don't want it to persist and be saved, potentially wasting // memory. // Rather, just do the check to ensure the factory type is valid. getChannelFactoryInternal ( factoryType , false ) ; // Prepare the property bag. Map < Object , Object > propertyBag = inputPropertyBag ; if ( null == propertyBag ) { propertyBag = new HashMap < Object , Object > ( ) ; } channelData = createChannelData ( channelName , factoryType , propertyBag , weight ) ; this . channelDataMap . put ( channelName , channelData ) ; return channelData ; }
This method does the work of adding a channel data object to the framework . It is called internally by both the addInbound and addOutbound channel methods .