/** * Sets the effective service contract for this bindable. * * @param serviceContract the contract */ public void setServiceContract(ServiceContract serviceContract) { this.serviceContract = serviceContract; createOperations(serviceContract); }
/** * Returns the channel in the invocable hierarchy. * * @param channelUri the channel uri * @param invocable the invocable * @return the channel * @throws Fabric3Exception if the channel is not found */ public static LogicalChannel getChannelInHierarchy(URI channelUri, LogicalInvocable invocable) throws Fabric3Exception { LogicalChannel channel = null; LogicalCompositeComponent parent = invocable.getParent().getParent(); while (true) { if (parent != null) { channel = parent.getChannel(channelUri); if (channel != null) { break; } parent = parent.getParent(); } else { break; } } if (channel == null) { throw new Fabric3Exception("Channel not found: " + channelUri); } return channel; }
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; }
/** * Returns the channel in the invocable hierarchy. * * @param channelUri the channel uri * @param invocable the invocable * @return the channel * @throws ChannelNotFoundException if the channel is not found */ public static LogicalChannel getChannelInHierarchy(URI channelUri, LogicalInvocable invocable) throws ChannelNotFoundException { LogicalChannel channel = null; LogicalCompositeComponent parent = invocable.getParent().getParent(); while (true) { if (parent != null) { channel = parent.getChannel(channelUri); if (channel != null) { break; } parent = parent.getParent(); } else { break; } } if (channel == null) { throw new ChannelNotFoundException("Channel not found: " + channelUri); } return channel; }
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; }
/** * Returns the channel in the invocable hierarchy. * * @param channelUri the channel uri * @param invocable the invocable * @return the channel * @throws Fabric3Exception if the channel is not found */ public static LogicalChannel getChannelInHierarchy(URI channelUri, LogicalInvocable invocable) throws Fabric3Exception { LogicalChannel channel = null; LogicalCompositeComponent parent = invocable.getParent().getParent(); while (true) { if (parent != null) { channel = parent.getChannel(channelUri); if (channel != null) { break; } parent = parent.getParent(); } else { break; } } if (channel == null) { throw new Fabric3Exception("Channel not found: " + channelUri); } return channel; }
/** * Constructor. * * @param uri URI of the SCA artifact. * @param contract the service contract * @param parent Parent of the SCA artifact. */ protected LogicalInvocable(URI uri, ServiceContract contract, LogicalComponent<?> parent) { super(parent); this.uri = uri; createOperations(contract); this.serviceContract = contract; }
public LogicalOperation resolve(LogicalOperation source, List<LogicalOperation> targets) { Operation sourceDefinition = source.getDefinition(); for (LogicalOperation target : targets) { Operation targetDefinition = target.getDefinition(); if (sourceDefinition.getName().equals(targetDefinition.getName())) { List<DataType> sourceInputTypes = sourceDefinition.getInputTypes(); DataType sourceOutputType = sourceDefinition.getOutputType(); DataType targetOutputType = targetDefinition.getOutputType(); if (sourceOutputType.equals(targetOutputType) && sourceInputTypes.equals(targetDefinition.getInputTypes())) { return target; } } } LogicalInvocable parent = source.getParent(); if (parent != null) { String sourceComponent = parent.getParent().getUri().toString(); throw new Fabric3Exception("Target operation not found for " + sourceDefinition.getName() + " on source component " + sourceComponent); } else { throw new Fabric3Exception("Target operation not found for " + sourceDefinition.getName()); } }
public LogicalOperation resolve(LogicalOperation source, List<LogicalOperation> targets) { Operation sourceDefinition = source.getDefinition(); for (LogicalOperation target : targets) { Operation targetDefinition = target.getDefinition(); if (sourceDefinition.getName().equals(targetDefinition.getName())) { List<DataType> sourceInputTypes = sourceDefinition.getInputTypes(); DataType sourceOutputType = sourceDefinition.getOutputType(); DataType targetOutputType = targetDefinition.getOutputType(); if (sourceOutputType.equals(targetOutputType) && sourceInputTypes.equals(targetDefinition.getInputTypes())) { return target; } } } LogicalInvocable parent = source.getParent(); if (parent != null) { String sourceComponent = parent.getParent().getUri().toString(); throw new Fabric3Exception("Target operation not found for " + sourceDefinition.getName() + " on source component " + sourceComponent); } else { throw new Fabric3Exception("Target operation not found for " + sourceDefinition.getName()); } }