@SuppressWarnings({"unchecked"}) public PhysicalConnectionTarget generateConnectionTarget(LogicalConsumer consumer) throws Fabric3Exception { SystemConnectionTarget target = new SystemConnectionTarget(); LogicalComponent<? extends SystemImplementation> component = (LogicalComponent<? extends SystemImplementation>) consumer.getParent(); URI uri = component.getUri(); target.setUri(uri); 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); return target; }
@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); }