private List<PhysicalChannelConnection> generateDirectConnections(LogicalConsumer consumer, Map<LogicalChannel, DeliveryType> channels, PhysicalConnectionTarget target, ClassLoader classLoader) { List<PhysicalChannelConnection> connections = new ArrayList<>(); for (Map.Entry<LogicalChannel, DeliveryType> entry : channels.entrySet()) { LogicalChannel channel = entry.getKey(); if (!channel.isBound()) { PhysicalChannelConnection producerConnection = generateLocalConnection(consumer, channel, target, classLoader); connections.add(producerConnection); } else { DeliveryType deliveryType = entry.getValue(); PhysicalChannelConnection bindingConnection = generateDirectBoundConnection(consumer, channel, deliveryType, classLoader, target); connections.add(bindingConnection); } } return connections; }
private List<PhysicalChannelConnection> generateDirectConnections(LogicalConsumer consumer, Map<LogicalChannel, DeliveryType> channels, PhysicalConnectionTarget target, ClassLoader classLoader) { List<PhysicalChannelConnection> connections = new ArrayList<>(); for (Map.Entry<LogicalChannel, DeliveryType> entry : channels.entrySet()) { LogicalChannel channel = entry.getKey(); if (!channel.isBound()) { PhysicalChannelConnection producerConnection = generateLocalConnection(consumer, channel, target, classLoader); connections.add(producerConnection); } else { DeliveryType deliveryType = entry.getValue(); PhysicalChannelConnection bindingConnection = generateDirectBoundConnection(consumer, channel, deliveryType, classLoader, target); connections.add(bindingConnection); } } return connections; }
private List<PhysicalChannelConnection> generateConnections(LogicalConsumer consumer, Map<LogicalChannel, DeliveryType> channels, PhysicalConnectionTarget target, ClassLoader classLoader) { List<PhysicalChannelConnection> connections = new ArrayList<>(); for (Map.Entry<LogicalChannel, DeliveryType> entry : channels.entrySet()) { LogicalChannel channel = entry.getKey(); if (!channel.isBound()) { PhysicalChannelConnection consumerConnection = generateLocalConnection(consumer, channel, target, classLoader); connections.add(consumerConnection); } else { PhysicalChannelConnection consumerConnection = generateLocalConnection(consumer, channel, target, classLoader); connections.add(consumerConnection); DeliveryType deliveryType = entry.getValue(); PhysicalChannelConnection bindingDefinition = generateBoundConnection(consumer, channel, deliveryType, classLoader); connections.add(bindingDefinition); } } return connections; }
private List<PhysicalChannelConnection> generateConnections(LogicalConsumer consumer, Map<LogicalChannel, DeliveryType> channels, PhysicalConnectionTarget target, ClassLoader classLoader) { List<PhysicalChannelConnection> connections = new ArrayList<>(); for (Map.Entry<LogicalChannel, DeliveryType> entry : channels.entrySet()) { LogicalChannel channel = entry.getKey(); if (!channel.isBound()) { PhysicalChannelConnection consumerConnection = generateLocalConnection(consumer, channel, target, classLoader); connections.add(consumerConnection); } else { PhysicalChannelConnection consumerConnection = generateLocalConnection(consumer, channel, target, classLoader); connections.add(consumerConnection); DeliveryType deliveryType = entry.getValue(); PhysicalChannelConnection bindingDefinition = generateBoundConnection(consumer, channel, deliveryType, classLoader); connections.add(bindingDefinition); } } return connections; }
private List<PhysicalChannelConnection> generateConnections(LogicalProducer producer, Map<LogicalChannel, DeliveryType> channels, PhysicalConnectionSource source, ClassLoader classLoader) { List<PhysicalChannelConnection> connections = new ArrayList<>(); for (Map.Entry<LogicalChannel, DeliveryType> entry : channels.entrySet()) { LogicalChannel channel = entry.getKey(); Class<?> type = getType(producer); if (!channel.isBound()) { PhysicalChannelConnection connection = generateLocalConnection(producer, type, channel, source, classLoader); connections.add(connection); } else { PhysicalChannelConnection producerConnection = generateLocalConnection(producer, type, channel, source, classLoader); connections.add(producerConnection); DeliveryType deliveryType = entry.getValue(); PhysicalChannelConnection bindingConnection = generateBoundConnection(producer, channel, deliveryType, classLoader); connections.add(bindingConnection); } } return connections; }
private List<PhysicalChannelConnection> generateConnections(LogicalProducer producer, Map<LogicalChannel, DeliveryType> channels, PhysicalConnectionSource source, ClassLoader classLoader) { List<PhysicalChannelConnection> connections = new ArrayList<>(); for (Map.Entry<LogicalChannel, DeliveryType> entry : channels.entrySet()) { LogicalChannel channel = entry.getKey(); Class<?> type = getType(producer); if (!channel.isBound()) { PhysicalChannelConnection connection = generateLocalConnection(producer, type, channel, source, classLoader); connections.add(connection); } else { PhysicalChannelConnection producerConnection = generateLocalConnection(producer, type, channel, source, classLoader); connections.add(producerConnection); DeliveryType deliveryType = entry.getValue(); PhysicalChannelConnection bindingConnection = generateBoundConnection(producer, channel, deliveryType, classLoader); connections.add(bindingConnection); } } return connections; }
private List<PhysicalChannelConnection> generateDirectConnections(LogicalProducer producer, Map<LogicalChannel, DeliveryType> channels, PhysicalConnectionSource source, ClassLoader classLoader) { List<PhysicalChannelConnection> connections = new ArrayList<>(); Class<?> type = producer.getDefinition().getServiceContract().getInterfaceClass(); for (Map.Entry<LogicalChannel, DeliveryType> entry : channels.entrySet()) { LogicalChannel channel = entry.getKey(); if (!channel.isBound()) { PhysicalChannelConnection producerConnection = generateLocalConnection(producer, type, channel, source, classLoader); connections.add(producerConnection); } else { DeliveryType deliveryType = entry.getValue(); PhysicalChannelConnection bindingConnection = generateDirectBoundConnection(producer, channel, deliveryType, classLoader, source); connections.add(bindingConnection); } } return connections; }
private List<PhysicalChannelConnection> generateDirectConnections(LogicalProducer producer, Map<LogicalChannel, DeliveryType> channels, PhysicalConnectionSource source, ClassLoader classLoader) { List<PhysicalChannelConnection> connections = new ArrayList<>(); Class<?> type = producer.getDefinition().getServiceContract().getInterfaceClass(); for (Map.Entry<LogicalChannel, DeliveryType> entry : channels.entrySet()) { LogicalChannel channel = entry.getKey(); if (!channel.isBound()) { PhysicalChannelConnection producerConnection = generateLocalConnection(producer, type, channel, source, classLoader); connections.add(producerConnection); } else { DeliveryType deliveryType = entry.getValue(); PhysicalChannelConnection bindingConnection = generateDirectBoundConnection(producer, channel, deliveryType, classLoader, source); connections.add(bindingConnection); } } return connections; }
private boolean isDirect(LogicalInvocable invocable, Map<LogicalChannel, DeliveryType> channels) { boolean direct = false; if (!channels.isEmpty()) { LogicalChannel logicalChannel = channels.keySet().iterator().next(); ServiceContract contract = invocable.getServiceContract(); if (contract == null) { return false; } Class<?> interfaceClass = contract.getInterfaceClass(); if (logicalChannel.isBound()) { Binding binding = logicalChannel.getBinding().getDefinition(); if (!binding.getConnectionTypes().isEmpty()) { direct = binding.getConnectionTypes().stream().anyMatch(t -> t.isAssignableFrom(interfaceClass)); } } else { Channel channel = logicalChannel.getDefinition(); if (!channel.getConnectionTypes().isEmpty()) { direct = channel.getConnectionTypes().stream().anyMatch(t -> t.isAssignableFrom(interfaceClass)); } } } return direct; }
private boolean isDirect(LogicalInvocable invocable, Map<LogicalChannel, DeliveryType> channels) { boolean direct = false; if (!channels.isEmpty()) { LogicalChannel logicalChannel = channels.keySet().iterator().next(); ServiceContract contract = invocable.getServiceContract(); if (contract == null) { return false; } Class<?> interfaceClass = contract.getInterfaceClass(); if (logicalChannel.isBound()) { Binding binding = logicalChannel.getBinding().getDefinition(); if (!binding.getConnectionTypes().isEmpty()) { direct = binding.getConnectionTypes().stream().anyMatch(t -> t.isAssignableFrom(interfaceClass)); } } else { Channel channel = logicalChannel.getDefinition(); if (!channel.getConnectionTypes().isEmpty()) { direct = channel.getConnectionTypes().stream().anyMatch(t -> t.isAssignableFrom(interfaceClass)); } } } return direct; }
@SuppressWarnings({"unchecked"}) public List<PhysicalChannelConnectionDefinition> generateProducer(LogicalProducer producer, Map<LogicalChannel, ChannelDeliveryType> channels) throws GenerationException { List<PhysicalChannelConnectionDefinition> definitions = new ArrayList<PhysicalChannelConnectionDefinition>(); LogicalComponent<?> component = producer.getParent(); ComponentGenerator<?> componentGenerator = getGenerator(component); PhysicalConnectionSourceDefinition sourceDefinition = componentGenerator.generateConnectionSource(producer); URI classLoaderId = component.getDefinition().getContributionUri(); sourceDefinition.setClassLoaderId(classLoaderId); PhysicalEventStreamDefinition eventStream = generate(producer.getStreamOperation()); for (Map.Entry<LogicalChannel, ChannelDeliveryType> entry : channels.entrySet()) { LogicalChannel channel = entry.getKey(); if (!channel.isBound()) { PhysicalChannelConnectionDefinition definition = generateProducerConnection(producer, channel, sourceDefinition, classLoaderId, eventStream); definitions.add(definition); } else { PhysicalChannelConnectionDefinition producerDefinition = generateProducerConnection(producer, channel, sourceDefinition, classLoaderId, eventStream); definitions.add(producerDefinition); ChannelDeliveryType deliveryType = entry.getValue(); PhysicalChannelConnectionDefinition bindingDefinition = generateProducerBinding(producer, channel, deliveryType, classLoaderId, eventStream); definitions.add(bindingDefinition); } } return definitions; }
public List<PhysicalChannelConnectionDefinition> generateConsumer(LogicalConsumer consumer, Map<LogicalChannel, ChannelDeliveryType> channels) throws GenerationException { List<PhysicalChannelConnectionDefinition> definitions = new ArrayList<PhysicalChannelConnectionDefinition>(); LogicalComponent<?> component = consumer.getParent(); ComponentGenerator<?> generator = getGenerator(component); PhysicalConnectionTargetDefinition targetDefinition = generator.generateConnectionTarget(consumer); URI classLoaderId = component.getDefinition().getContributionUri(); targetDefinition.setClassLoaderId(classLoaderId); PhysicalEventStreamDefinition eventStream = generateEventStream(consumer); generatePolicy(consumer, eventStream); for (Map.Entry<LogicalChannel, ChannelDeliveryType> entry : channels.entrySet()) { LogicalChannel channel = entry.getKey(); if (!channel.isBound()) { PhysicalChannelConnectionDefinition definition = generateConsumerConnection(consumer, channel, targetDefinition, classLoaderId, eventStream); definitions.add(definition); } else { PhysicalChannelConnectionDefinition consumerConnection = generateConsumerConnection(consumer, channel, targetDefinition, classLoaderId, eventStream); definitions.add(consumerConnection); ChannelDeliveryType deliveryType = entry.getValue(); PhysicalChannelConnectionDefinition bindingDefinition = generateConsumerBinding(consumer, channel, deliveryType, classLoaderId, eventStream); definitions.add(bindingDefinition); } } return definitions; }
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); }
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); }
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); }
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); }
private PhysicalChannelConnectionDefinition generateConsumerConnection(LogicalConsumer consumer, LogicalChannel channel, PhysicalConnectionTargetDefinition targetDefinition, URI classLoaderId, PhysicalEventStreamDefinition eventStream) throws GenerationException { // the channel does not have bindings, which means it is a local channel if (!channel.getZone().equals(consumer.getParent().getZone()) && !channel.isBound()) { String name = channel.getDefinition().getName(); throw new GenerationException("Binding not configured on a channel where the consumer is in a different zone: " + name); } // construct a local connection to the channel PhysicalConnectionSourceDefinition sourceDefinition = new ChannelSourceDefinition(channel.getUri(), ChannelSide.CONSUMER); sourceDefinition.setSequence(consumer.getDefinition().getSequence()); sourceDefinition.setClassLoaderId(classLoaderId); return new PhysicalChannelConnectionDefinition(sourceDefinition, targetDefinition, eventStream); }
@SuppressWarnings({"unchecked"}) private PhysicalChannelConnection generateBoundConnection(LogicalProducer producer, LogicalChannel channel, DeliveryType deliveryType, ClassLoader classLoader) { LogicalBinding<?> binding = channel.getBinding(); ConnectionBindingGenerator bindingGenerator = getGenerator(binding); PhysicalConnectionTarget target = bindingGenerator.generateConnectionTarget(producer, binding, deliveryType); target.setClassLoader(classLoader); URI uri = channel.getUri(); ChannelSource source = new ChannelSource(uri, ChannelSide.PRODUCER); source.setClassLoader(classLoader); boolean bound = channel.isBound(); Class<?> type = getType(producer); return new PhysicalChannelConnection(uri, producer.getUri(), source, target, type, bound); }
@SuppressWarnings({"unchecked"}) private PhysicalChannelConnection generateBoundConnection(LogicalProducer producer, LogicalChannel channel, DeliveryType deliveryType, ClassLoader classLoader) { LogicalBinding<?> binding = channel.getBinding(); ConnectionBindingGenerator bindingGenerator = getGenerator(binding); PhysicalConnectionTarget target = bindingGenerator.generateConnectionTarget(producer, binding, deliveryType); target.setClassLoader(classLoader); URI uri = channel.getUri(); ChannelSource source = new ChannelSource(uri, ChannelSide.PRODUCER); source.setClassLoader(classLoader); boolean bound = channel.isBound(); Class<?> type = getType(producer); return new PhysicalChannelConnection(uri, producer.getUri(), source, target, type, bound); }