private Class<?> getType(LogicalConsumer consumer) { Consumer<?> consumerDefinition = consumer.getDefinition(); return consumerDefinition.getType().getType(); }
private Class<?> getType(LogicalConsumer consumer) { Consumer<?> consumerDefinition = consumer.getDefinition(); return consumerDefinition.getType().getType(); }
@SuppressWarnings({"unchecked"}) public PhysicalConnectionTargetDefinition generateConnectionTarget(LogicalConsumer consumer) throws GenerationException { SpringConsumer springConsumer = (SpringConsumer) consumer.getDefinition(); String beanName = springConsumer.getBeanName(); String methodName = springConsumer.getMethodName(); JavaType<?> type = springConsumer.getType(); URI uri = consumer.getParent().getUri(); return new SpringConnectionTargetDefinition(beanName, methodName, type, uri); }
@SuppressWarnings({"unchecked"}) public PhysicalConnectionTarget generateConnectionTarget(LogicalConsumer consumer) throws Fabric3Exception { SpringConsumer springConsumer = (SpringConsumer) consumer.getDefinition(); String beanName = springConsumer.getBeanName(); String methodName = springConsumer.getMethodName(); JavaType type = springConsumer.getType(); URI uri = consumer.getParent().getUri(); return new SpringConnectionTarget(beanName, methodName, type, uri); }
private PhysicalEventStreamDefinition generateEventStream(LogicalConsumer consumer) { PhysicalEventStreamDefinition definition = new PhysicalEventStreamDefinition("default"); List<DataType<?>> types = consumer.getDefinition().getTypes(); boolean typed = false; boolean takesChannelEvent = false; for (DataType<?> dataType : types) { if (dataType instanceof JavaType) { // for now only support Java contracts if (!Object.class.equals(dataType.getLogical())) { typed = true; if (ChannelEvent.class.isAssignableFrom(dataType.getPhysical())) { takesChannelEvent = true; } } } definition.setChannelEvent(takesChannelEvent); definition.addEventType(dataType.getPhysical().getName()); } if (typed) { TypeEventFilterDefinition typeFilter = new TypeEventFilterDefinition(types); definition.addFilterDefinition(typeFilter); } return definition; }
@SuppressWarnings({"unchecked"}) public PhysicalConnectionTarget generateConnectionTarget(LogicalConsumer consumer) throws Fabric3Exception { SpringConsumer springConsumer = (SpringConsumer) consumer.getDefinition(); String beanName = springConsumer.getBeanName(); String methodName = springConsumer.getMethodName(); JavaType type = springConsumer.getType(); URI uri = consumer.getParent().getUri(); return new SpringConnectionTarget(beanName, methodName, type, uri); }
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 PhysicalChannelConnectionDefinition generateConsumerBinding(LogicalConsumer consumer, LogicalChannel channel, ChannelDeliveryType deliveryType, URI classLoaderId, PhysicalEventStreamDefinition eventStream) throws GenerationException { // use the bindings on the channel to create a consumer binding configuration LogicalBinding<?> binding = channel.getBinding(); ConnectionBindingGenerator bindingGenerator = getGenerator(binding); PhysicalConnectionSourceDefinition sourceDefinition = bindingGenerator.generateConnectionSource(consumer, binding, deliveryType); sourceDefinition.setSequence(consumer.getDefinition().getSequence()); sourceDefinition.setClassLoaderId(classLoaderId); ChannelTargetDefinition targetDefinition = new ChannelTargetDefinition(channel.getUri(), ChannelSide.CONSUMER); targetDefinition.setClassLoaderId(classLoaderId); return new PhysicalChannelConnectionDefinition(sourceDefinition, targetDefinition, eventStream); }
@SuppressWarnings({"unchecked"}) public void generateConnectionTarget(JavaConnectionTarget target, LogicalConsumer consumer) { // Create an injectable for the consumer. Note in cases where the consumer is a method that is connected via an event stream and is used to receive // events rather than act as a setter for a direct connection, the injector will never be activated. Injectable injectable = new Injectable(InjectableType.CONSUMER, consumer.getUri().getFragment()); target.setInjectable(injectable); LogicalComponent<? extends JavaImplementation> component = (LogicalComponent<? extends JavaImplementation>) consumer.getParent(); URI uri = component.getUri(); target.setUri(uri); ServiceContract serviceContract = consumer.getDefinition().getServiceContract(); Class<?> interfaze = serviceContract.getInterfaceClass(); target.setServiceInterface(interfaze); InjectingComponentType type = component.getDefinition().getImplementation().getComponentType(); AccessibleObject object = type.getConsumerSite(consumer.getUri().getFragment()); if (object == null) { // programming error throw new Fabric3Exception("Consumer not found on: " + consumer.getUri()); } target.setConsumerSite(object); }
@SuppressWarnings({"unchecked"}) private PhysicalChannelConnection generateBoundConnection(LogicalConsumer consumer, LogicalChannel channel, DeliveryType deliveryType, ClassLoader classLoader) { // use the bindings on the channel to create a consumer binding configuration LogicalBinding<?> binding = channel.getBinding(); ConnectionBindingGenerator bindingGenerator = getGenerator(binding); PhysicalConnectionSource source = bindingGenerator.generateConnectionSource(consumer, binding, deliveryType); source.setSequence(consumer.getDefinition().getSequence()); source.setClassLoader(classLoader); URI uri = channel.getUri(); ChannelTarget target = new ChannelTarget(uri, ChannelSide.CONSUMER); target.setClassLoader(classLoader); Class<?> type = getType(consumer); return new PhysicalChannelConnection(uri, consumer.getUri(), source, target, type, true); }
@SuppressWarnings({"unchecked"}) private PhysicalChannelConnection generateBoundConnection(LogicalConsumer consumer, LogicalChannel channel, DeliveryType deliveryType, ClassLoader classLoader) { // use the bindings on the channel to create a consumer binding configuration LogicalBinding<?> binding = channel.getBinding(); ConnectionBindingGenerator bindingGenerator = getGenerator(binding); PhysicalConnectionSource source = bindingGenerator.generateConnectionSource(consumer, binding, deliveryType); source.setSequence(consumer.getDefinition().getSequence()); source.setClassLoader(classLoader); URI uri = channel.getUri(); ChannelTarget target = new ChannelTarget(uri, ChannelSide.CONSUMER); target.setClassLoader(classLoader); Class<?> type = getType(consumer); return new PhysicalChannelConnection(uri, consumer.getUri(), source, target, type, true); }
public PhysicalConnectionSource generateConnectionSource(LogicalConsumer consumer, LogicalBinding<JmsBinding> binding, DeliveryType deliveryType) { JmsBindingMetadata metadata = binding.getDefinition().getJmsMetadata().snapshot(); SessionType sessionType = getSessionType(binding); JmsGeneratorHelper.generateDefaultFactoryConfiguration(metadata.getConnectionFactory(), sessionType); URI uri = consumer.getUri(); // set the client id specifier if (metadata.getSubscriptionId() == null && metadata.isDurable()) { String prefix = metadata.getSubscriptionIdPrefix() != null ? metadata.getSubscriptionIdPrefix() + "-" : ""; metadata.setSubscriptionId(prefix+JmsGeneratorHelper.getSubscriptionId(uri)); } String specifier = metadata.getSubscriptionId(); metadata.setSubscriptionId(specifier); metadata.getDestination().setType(DestinationType.TOPIC); // only use topics for channels Consumer<?> consumerDefinition = consumer.getDefinition(); DataType dataType = isJAXB(consumerDefinition.getType()) ? PhysicalDataTypes.JAXB : PhysicalDataTypes.JAVA_TYPE; JmsConnectionSource source = new JmsConnectionSource(uri, metadata, dataType, sessionType); if (provisioner != null) { provisioner.generateConnectionSource(source); } return source; }