/** * Adds a channel. * * @param channel the channel to add */ public void addChannel(LogicalChannel channel) { channels.put(channel.getUri(), channel); }
public void allocate(LogicalChannel channel, DeploymentPlan plan) throws AllocationException { QName deployable = channel.getDeployable(); if (deployable == null) { // programming error throw new AssertionError("Deployable not found for " + channel.getUri()); } String zoneName = plan.getDeployableMappings().get(deployable); if (zoneName == null) { throw new DeployableMappingNotFoundException("Zone mapping not found for deployable: " + deployable); } channel.setZone(zoneName); }
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 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; } }
public <T> T getProducer(Class<T> interfaze, String name, String topic) { LogicalChannel logicalChannel = getChannel(name); LogicalProducer producer = createProducer(interfaze, logicalChannel.getUri()); PhysicalChannel physicalChannel = channelGenerator.generate(logicalChannel, SYNTHETIC_CONTRIBUTION, PRODUCER); channelBuilderRegistry.build(physicalChannel); Map<LogicalChannel, DeliveryType> channels = Collections.singletonMap(logicalChannel, DeliveryType.DEFAULT); List<PhysicalChannelConnection> connections = connectionGenerator.generateProducer(producer, channels); // connect the connections and return the non-managed source so the proxy can be returned to the client NonManagedConnectionSource source = connect(topic, connections); return interfaze.cast(source.getProxy()); }
public <T> T getProducer(Class<T> interfaze, String name, String topic) { LogicalChannel logicalChannel = getChannel(name); LogicalProducer producer = createProducer(interfaze, logicalChannel.getUri()); PhysicalChannel physicalChannel = channelGenerator.generate(logicalChannel, SYNTHETIC_CONTRIBUTION, PRODUCER); channelBuilderRegistry.build(physicalChannel); Map<LogicalChannel, DeliveryType> channels = Collections.singletonMap(logicalChannel, DeliveryType.DEFAULT); List<PhysicalChannelConnection> connections = connectionGenerator.generateProducer(producer, channels); // connect the connections and return the non-managed source so the proxy can be returned to the client NonManagedConnectionSource source = connect(topic, connections); return interfaze.cast(source.getProxy()); }
public void bind(LogicalChannel channel) { QName deployable = channel.getParent().getDeployable(); String topic = channel.getUri().toString(); JmsBindingDefinition channelDefinition = createTopicBindingDefinition(topic); LogicalBinding<JmsBindingDefinition> channelBinding = new LogicalBinding<JmsBindingDefinition>(channelDefinition, channel, deployable); channelBinding.setAssigned(true); channel.addBinding(channelBinding); }
private PhysicalChannelConnection generateLocalConnection(LogicalProducer producer, Class<?> type, LogicalChannel channel, PhysicalConnectionSource source, ClassLoader classLoader) { URI uri = channel.getUri(); PhysicalConnectionTarget target = new ChannelTarget(uri, ChannelSide.PRODUCER); target.setClassLoader(classLoader); boolean bound = channel.isBound(); return new PhysicalChannelConnection(uri, producer.getUri(), source, target, type, bound); }
public PhysicalChannel generate(LogicalChannel channel, URI contributionUri) throws Fabric3Exception { URI uri = channel.getUri(); Channel definition = channel.getDefinition(); String channelType = definition.getType(); PhysicalChannel physicalChannel = new PhysicalChannel(uri, channelType, DeliveryType.DEFAULT, contributionUri); physicalChannel.setMetadata(definition.getMetadata(Object.class)); return physicalChannel; } }
private PhysicalChannelConnection generateLocalConnection(LogicalProducer producer, Class<?> type, LogicalChannel channel, PhysicalConnectionSource source, ClassLoader classLoader) { URI uri = channel.getUri(); PhysicalConnectionTarget target = new ChannelTarget(uri, ChannelSide.PRODUCER); target.setClassLoader(classLoader); boolean bound = channel.isBound(); return new PhysicalChannelConnection(uri, producer.getUri(), source, target, type, bound); }
public PhysicalChannel generate(LogicalChannel channel, URI contributionUri) throws Fabric3Exception { URI uri = channel.getUri(); Channel channelDefinition = channel.getDefinition(); String channelType = channelDefinition.getType(); PhysicalChannel physicalChannel = new PhysicalChannel(uri, channelType, ASYNCHRONOUS_WORKER, contributionUri); physicalChannel.setMetadata(channelDefinition.getMetadata(Object.class)); return physicalChannel; }
public PhysicalChannel generate(LogicalChannel channel, URI contributionUri) throws Fabric3Exception { URI uri = channel.getUri(); Channel definition = channel.getDefinition(); String channelType = definition.getType(); PhysicalChannel physicalChannel = new PhysicalChannel(uri, channelType, DeliveryType.DEFAULT, contributionUri); physicalChannel.setMetadata(definition.getMetadata(Object.class)); return physicalChannel; } }
public <T> T getConsumer(Class<T> interfaze, String name, String topic) { LogicalChannel logicalChannel = getChannel(name); LogicalConsumer consumer = createConsumer(interfaze, logicalChannel.getUri()); PhysicalChannel physicalChannel = channelGenerator.generate(logicalChannel, SYNTHETIC_CONTRIBUTION, CONSUMER); channelBuilderRegistry.build(physicalChannel); Map<LogicalChannel, DeliveryType> channels = Collections.singletonMap(logicalChannel, DeliveryType.DEFAULT); List<PhysicalChannelConnection> connections = connectionGenerator.generateConsumer(consumer, channels); PhysicalChannelConnection connection = connections.get(0); // safe as there is only one connection connection.setTopic(topic); connection.getSource().setTopic(topic); connection.getTarget().setTopic(topic); channelConnector.connect(connection); NonManagedConnectionTarget target = (NonManagedConnectionTarget) connection.getTarget(); return interfaze.cast(target.getProxy()); }
private PhysicalChannelConnectionDefinition generateProducerConnection(LogicalProducer producer, LogicalChannel channel, PhysicalConnectionSourceDefinition sourceDefinition, URI classLoaderId, PhysicalEventStreamDefinition eventStream) throws GenerationException { if (!channel.getZone().equals(producer.getParent().getZone()) && !channel.isBound()) { String name = channel.getDefinition().getName(); throw new GenerationException("Binding not configured on a channel where the producer is in a different zone: " + name); } PhysicalConnectionTargetDefinition targetDefinition = new ChannelTargetDefinition(channel.getUri(), ChannelSide.PRODUCER); targetDefinition.setClassLoaderId(classLoaderId); return new PhysicalChannelConnectionDefinition(sourceDefinition, targetDefinition, eventStream); }
@SuppressWarnings({"unchecked"}) private PhysicalChannelConnectionDefinition generateProducerBinding(LogicalProducer producer, LogicalChannel channel, ChannelDeliveryType deliveryType, URI classLoaderId, PhysicalEventStreamDefinition eventStream) throws GenerationException { LogicalBinding<?> binding = channel.getBinding(); ConnectionBindingGenerator bindingGenerator = getGenerator(binding); PhysicalConnectionTargetDefinition targetDefinition = bindingGenerator.generateConnectionTarget(producer, binding, deliveryType); targetDefinition.setClassLoaderId(classLoaderId); ChannelSourceDefinition sourceDefinition = new ChannelSourceDefinition(channel.getUri(), ChannelSide.PRODUCER); sourceDefinition.setClassLoaderId(classLoaderId); return new PhysicalChannelConnectionDefinition(sourceDefinition, targetDefinition, eventStream); }
@SuppressWarnings({"unchecked"}) private PhysicalChannelConnection generateDirectBoundConnection(LogicalConsumer consumer, LogicalChannel channel, DeliveryType deliveryType, ClassLoader classLoader, PhysicalConnectionTarget target) { LogicalBinding<?> binding = channel.getBinding(); ConnectionBindingGenerator bindingGenerator = getGenerator(binding); PhysicalConnectionSource source = bindingGenerator.generateConnectionSource(consumer, binding, deliveryType); source.setClassLoader(classLoader); URI uri = channel.getUri(); Class<?> type = getType(consumer); return new PhysicalChannelConnection(uri, consumer.getUri(), source, target, type, true); }
@SuppressWarnings({"unchecked"}) private PhysicalChannelConnection generateDirectBoundConnection(LogicalConsumer consumer, LogicalChannel channel, DeliveryType deliveryType, ClassLoader classLoader, PhysicalConnectionTarget target) { LogicalBinding<?> binding = channel.getBinding(); ConnectionBindingGenerator bindingGenerator = getGenerator(binding); PhysicalConnectionSource source = bindingGenerator.generateConnectionSource(consumer, binding, deliveryType); source.setClassLoader(classLoader); URI uri = channel.getUri(); Class<?> type = getType(consumer); return new PhysicalChannelConnection(uri, consumer.getUri(), source, target, type, true); }
private PhysicalChannelConnection generateLocalConnection(LogicalConsumer consumer, LogicalChannel channel, PhysicalConnectionTarget target, ClassLoader classLoader) { // the channel does not have bindings, which means it is a local channel // construct a local connection to the channel URI uri = channel.getUri(); PhysicalConnectionSource source = new ChannelSource(uri, ChannelSide.CONSUMER); source.setSequence(consumer.getDefinition().getSequence()); source.setClassLoader(classLoader); Class<?> type = getType(consumer); boolean bound = channel.isBound(); return new PhysicalChannelConnection(uri, consumer.getUri(), source, target, type, bound); }
private PhysicalChannelConnection generateLocalConnection(LogicalConsumer consumer, LogicalChannel channel, PhysicalConnectionTarget target, ClassLoader classLoader) { // the channel does not have bindings, which means it is a local channel // construct a local connection to the channel URI uri = channel.getUri(); PhysicalConnectionSource source = new ChannelSource(uri, ChannelSide.CONSUMER); source.setSequence(consumer.getDefinition().getSequence()); source.setClassLoader(classLoader); Class<?> type = getType(consumer); boolean bound = channel.isBound(); return new PhysicalChannelConnection(uri, consumer.getUri(), source, target, type, bound); }
@SuppressWarnings({"unchecked"}) private PhysicalChannelConnection generateDirectBoundConnection(LogicalProducer producer, LogicalChannel channel, DeliveryType deliveryType, ClassLoader classLoader, PhysicalConnectionSource source) { LogicalBinding<?> binding = channel.getBinding(); ConnectionBindingGenerator bindingGenerator = getGenerator(binding); PhysicalConnectionTarget target = bindingGenerator.generateConnectionTarget(producer, binding, deliveryType); target.setClassLoader(classLoader); URI uri = channel.getUri(); Class<?> type = producer.getDefinition().getServiceContract().getInterfaceClass(); // the type is the producer interface since it is direct return new PhysicalChannelConnection(uri, producer.getUri(), source, target, type, true); }