protected ChannelsModel toChannelsModel ( Channel [ ] channelAnnotations , KnowledgeNamespace knowledgeNamespace , ComponentModel componentModel , SwitchYardNamespace switchyardNamespace ) { if ( channelAnnotations == null || channelAnnotations . length == 0 ) { return null ; } ChannelsModel channelsModel = new V1ChannelsModel ( knowledgeNamespace . uri ( ) ) ; for ( Channel channelAnnotation : channelAnnotations ) { ChannelModel channelModel = new V1ChannelModel ( knowledgeNamespace . uri ( ) ) ; Class < ? extends org . kie . api . runtime . Channel > clazz = channelAnnotation . value ( ) ; if ( Channel . UndefinedChannel . class . isAssignableFrom ( clazz ) ) { clazz = SwitchYardServiceChannel . class ; } channelModel . setClazz ( clazz ) ; String name = channelAnnotation . name ( ) ; if ( UNDEFINED . equals ( name ) ) { if ( SwitchYardServiceChannel . class . isAssignableFrom ( clazz ) ) { name = SwitchYardServiceChannel . SERVICE ; } } if ( UNDEFINED . equals ( name ) ) { name = clazz . getSimpleName ( ) ; } channelModel . setName ( name ) ; String operation = channelAnnotation . operation ( ) ; if ( ! UNDEFINED . equals ( operation ) ) { channelModel . setOperation ( operation ) ; } String reference = channelAnnotation . reference ( ) ; if ( ! UNDEFINED . equals ( reference ) ) { channelModel . setReference ( reference ) ; ComponentReferenceModel componentReferenceModel = new V1ComponentReferenceModel ( switchyardNamespace . uri ( ) ) ; componentReferenceModel . setName ( reference ) ; Class < ? > interfaze = channelAnnotation . interfaze ( ) ; if ( ! Channel . UndefinedInterface . class . isAssignableFrom ( interfaze ) ) { InterfaceModel interfaceModel = new V1InterfaceModel ( InterfaceModel . JAVA ) ; interfaceModel . setInterface ( interfaze . getName ( ) ) ; componentReferenceModel . setInterface ( interfaceModel ) ; componentModel . addReference ( componentReferenceModel ) ; } } channelsModel . addChannel ( channelModel ) ; } return channelsModel ; }
Converts channel annotations to a channels model .