@SuppressWarnings({"unchecked"}) public void disconnect(PhysicalChannelConnectionDefinition definition) throws BuilderException { PhysicalConnectionSourceDefinition source = definition.getSource(); PhysicalConnectionTargetDefinition target = definition.getTarget(); SourceConnectionAttacher sourceAttacher = sourceAttachers.get(source.getClass()); if (sourceAttacher == null) { throw new AttacherNotFoundException("Attacher not found for type: " + source.getClass().getName()); } TargetConnectionAttacher targetAttacher = targetAttachers.get(target.getClass()); if (targetAttacher == null) { throw new AttacherNotFoundException("Attacher not found for type: " + target.getClass().getName()); } sourceAttacher.detach(source, target); targetAttacher.detach(source, target); }
@SuppressWarnings({"unchecked"}) public void connect(PhysicalChannelConnectionDefinition definition) throws BuilderException { PhysicalConnectionSourceDefinition source = definition.getSource(); PhysicalConnectionTargetDefinition target = definition.getTarget(); SourceConnectionAttacher sourceAttacher = sourceAttachers.get(source.getClass()); if (sourceAttacher == null) { throw new AttacherNotFoundException("Attacher not found for type: " + source.getClass().getName()); } TargetConnectionAttacher targetAttacher = targetAttachers.get(target.getClass()); if (targetAttacher == null) { throw new AttacherNotFoundException("Attacher not found for type: " + target.getClass().getName()); } ChannelConnection connection = createConnection(definition); sourceAttacher.attach(source, target, connection); targetAttacher.attach(source, target, connection); }
/** * Creates the connection. * * @param definition the connection definition * @return the connection * @throws BuilderException if there is an error creating the connection */ private ChannelConnection createConnection(PhysicalChannelConnectionDefinition definition) throws BuilderException { ClassLoader loader = classLoaderRegistry.getClassLoader(definition.getTarget().getClassLoaderId()); PhysicalEventStreamDefinition streamDefinition = definition.getEventStream(); EventStream stream = new EventStreamImpl(streamDefinition); addTransformer(streamDefinition, stream, loader); addFilters(streamDefinition, stream); addHandlers(streamDefinition, stream); int sequence = definition.getSource().getSequence(); return new ChannelConnectionImpl(stream, sequence); }