public Channel build(PhysicalChannelDefinition definition) throws BuilderException { URI uri = definition.getUri(); QName deployable = definition.getDeployable(); RingBufferData data = definition.getMetadata(RingBufferData.class); int size = data.getRingSize(); WaitStrategy strategy = createWaitStrategy(data); ChannelSide channelSide = definition.getChannelSide(); return new RingBufferChannel(uri, deployable, size, strategy, channelSide, executorService); }
public PhysicalChannelDefinition generate(LogicalChannel channel, QName deployable) throws GenerationException { URI uri = channel.getUri(); ChannelDefinition definition = channel.getDefinition(); String channelType = definition.getType(); boolean replicate = definition.getIntents().contains(ChannelConstants.REPLICATE_INTENT); PhysicalChannelDefinition physicalDefinition = new PhysicalChannelDefinition(uri, deployable, replicate, channelType, ASYNCHRONOUS_WORKER); physicalDefinition.setMetadata(definition.getMetadata().get(ChannelConstants.METADATA)); return physicalDefinition; }
public void dispose(PhysicalChannelDefinition definition, Channel channel) throws BuilderException { URI uri = definition.getUri(); if (definition.isReplicate() && replicationCapable) { String channelName = uri.toString(); try { topologyService.closeChannel(channelName); } catch (ZoneChannelException e) { throw new BuilderException(e); } } disposeBinding(channel, definition.getBindingDefinition()); }
public Channel build(PhysicalChannelDefinition definition) throws BuilderException { URI uri = definition.getUri(); QName deployable = definition.getDeployable(); FanOutHandler fanOutHandler; if (definition.getBindingDefinition() != null) { // if a binding is set on the channel, make the channel synchronous since async behavior will be provided by the binding fanOutHandler = new SyncFanOutHandler(); } else { // the channel is local, have it implement asynchrony fanOutHandler = new AsyncFanOutHandler(executorService); } Channel channel; if (definition.isReplicate() && replicationCapable) { String channelName = uri.toString(); ReplicationHandler replicationHandler = new ReplicationHandler(channelName, topologyService, monitor); channel = new DefaultChannelImpl(uri, deployable, replicationHandler, fanOutHandler, definition.getChannelSide()); if (!topologyService.isChannelOpen(channelName)) { try { topologyService.openChannel(channelName, null, replicationHandler); } catch (ZoneChannelException e) { throw new BuilderException(e); } } } else { channel = new DefaultChannelImpl(uri, deployable, fanOutHandler, definition.getChannelSide()); } PhysicalChannelBindingDefinition bindingDefinition = definition.getBindingDefinition(); buildBinding(channel, bindingDefinition); return channel; }
public Channel build(PhysicalChannelDefinition definition) throws BuilderException { URI uri = definition.getUri(); ChannelSide channelSide = definition.getChannelSide(); Channel channel = channelManager.getAndIncrementChannel(uri, channelSide); if (channel != null) { return channel; } ChannelBuilder builder = getBuilder(definition); channel = builder.build(definition); try { channelManager.register(channel); return channel; } catch (RegistrationException e) { throw new BuilderException(e); } }
@SuppressWarnings({"unchecked"}) private PhysicalChannelDefinition generateChannelDefinition(LogicalChannel channel, QName deployable, Direction direction) throws GenerationException { LogicalBinding<?> binding = channel.getBinding(); String type = channel.getDefinition().getType(); ChannelGenerator generator = channelGenerators.get(type); if (generator == null) { throw new GenerationException("Channel generator not found: " + type); } PhysicalChannelDefinition definition = generator.generate(channel, deployable); if (!channel.getBindings().isEmpty()) { // generate binding information if (!(binding.getDefinition() instanceof SCABinding)) { // avoid generating SCABinding ConnectionBindingGenerator bindingGenerator = getGenerator(binding); ChannelDeliveryType deliveryType = definition.getDeliveryType(); PhysicalChannelBindingDefinition bindingDefinition = bindingGenerator.generateChannelBinding(binding, deliveryType); definition.setBindingDefinition(bindingDefinition); definition.setChannelSide(Direction.CONSUMER == direction ? ChannelSide.CONSUMER : ChannelSide.PRODUCER); } else { definition.setChannelSide(ChannelSide.COLLOCATED); } } else { definition.setChannelSide(ChannelSide.COLLOCATED); } return definition; }
DisposeChannelCommand disposeCommand = channelGenerator.generateDispose(channel, deployable, PRODUCER); command.addDisposeChannelCommand(disposeCommand); channels.put(channel, disposeCommand.getDefinition().getDeliveryType()); BuildChannelCommand buildCommand = channelGenerator.generateBuild(channel, deployable, PRODUCER); command.addBuildChannelCommand(buildCommand); channels.put(channel, buildCommand.getDefinition().getDeliveryType());
public void dispose(PhysicalChannelDefinition definition) throws BuilderException { ChannelBuilder builder = getBuilder(definition); try { URI uri = definition.getUri(); ChannelSide channelSide = definition.getChannelSide(); Channel channel = channelManager.getAndDecrementChannel(uri, channelSide); if (channelManager.getCount(uri, channelSide) == 0) { channelManager.unregister(uri, channelSide); builder.dispose(definition, channel); } } catch (RegistrationException e) { throw new BuilderException(e); } }
DisposeChannelCommand disposeCommand = channelGenerator.generateDispose(channel, deployable, CONSUMER); command.addDisposeChannelCommand(disposeCommand); channels.put(channel, disposeCommand.getDefinition().getDeliveryType()); BuildChannelCommand buildCommand = channelGenerator.generateBuild(channel, deployable, CONSUMER); command.addBuildChannelCommand(buildCommand); channels.put(channel, buildCommand.getDefinition().getDeliveryType());
public PhysicalChannelDefinition generate(LogicalChannel channel, QName deployable) throws GenerationException { URI uri = channel.getUri(); ChannelDefinition definition = channel.getDefinition(); String channelType = definition.getType(); boolean replicate = definition.getIntents().contains(ChannelConstants.REPLICATE_INTENT); PhysicalChannelDefinition physicalDefinition = new PhysicalChannelDefinition(uri, deployable, replicate, channelType, ChannelDeliveryType.DEFAULT); physicalDefinition.setMetadata(definition.getMetadata().get(ChannelConstants.METADATA)); return physicalDefinition; } }