public PromotedComponentNotFound(LogicalBindable bindable, URI promotedComponentUri) { super(bindable.getParent().getUri(), bindable.getParent().getDefinition().getContributionUri(), Collections.singletonList(bindable)); this.bindableUri = bindable.getUri(); this.promotedComponentUri = promotedComponentUri; }
/** * Convenience method. * * @return true if the channel is configured with a binding */ public boolean isBound() { return !getBindings().isEmpty(); }
@Override public void addBinding(LogicalBinding<?> binding) { if (!getBindings().isEmpty()) { throw new IllegalStateException("Channel is already configured with a binding"); } super.addBinding(binding); }
private ServiceEndpointDefinition createServiceEndpointDefinition(LogicalBinding<WsBinding> binding, JavaServiceContract contract, Class<?> serviceClass) { URI targetUri = binding.getDefinition().getTargetUri(); if (targetUri == null) { targetUri = URI.create(binding.getParent().getUri().getFragment()); // use the service URI fragment } return synthesizer.synthesizeServiceEndpoint(contract, serviceClass, targetUri); }
public JmsWireTarget generateTarget(LogicalBinding<JmsBinding> binding, ServiceContract contract, List<LogicalOperation> operations) throws Fabric3Exception { SessionType sessionType = getSessionType(binding.getParent().getParent()); for (LogicalBinding<?> callbackBinding : binding.getParent().getCallbackBindings()) { if (callbackBinding.getDefinition() instanceof JmsBinding) { JmsBinding callbackDefinition = (JmsBinding) callbackBinding.getDefinition();
public URL resolveUrl(LogicalBinding<WsBinding> binding) throws Fabric3Exception { try { URL targetUrl; String path = binding.getDefinition().getTargetUri().toString(); if (path == null) { path = binding.getParent().getUri().getFragment(); } boolean https = false; if (RuntimeMode.VM == hostInfo.getRuntimeMode()) { // single VM if (https) { targetUrl = new URL("https://localhost:" + servletHost.getHttpsPort() + "/" + path); } else { targetUrl = new URL("http://localhost:" + servletHost.getHttpPort() + "/" + path); } } else { throw new Fabric3Exception("Resolve URL not supported in distributed configuration"); } return targetUrl; } catch (MalformedURLException e) { throw new Fabric3Exception(e); } }
public PromotedComponentNotFound(LogicalBindable bindable, URI promotedComponentUri) { super(bindable.getParent().getUri(), bindable.getParent().getDefinition().getContributionUri(), Collections.singletonList(bindable)); this.bindableUri = bindable.getUri(); this.promotedComponentUri = promotedComponentUri; }
public PhysicalConnectionSource generateConnectionSource(LogicalConsumer consumer, LogicalBinding<NATSBinding> binding, DeliveryType deliveryType) { NATSBinding natsBinding = binding.getDefinition(); URI channelUri = binding.getParent().getUri(); String defaultTopic = natsBinding.getDefaultTopic(); NATSData natsData = generateData(natsBinding); String consumerId = consumer.getUri().toString(); return new NATSConnectionSource(consumer.getUri(), channelUri, consumerId, defaultTopic, natsData); }
/** * Returns a binding matching the name * * @param name the binding name * @param bindable the bindable containing the binding * @return the matching binding or null if no matching one was found */ private LogicalBinding<?> getBinding(String name, LogicalBindable bindable) { LogicalBinding<?> selectedBinding = null; for (LogicalBinding<?> binding : bindable.getBindings()) { if (name.equals(binding.getDefinition().getName())) { selectedBinding = binding; break; } } return selectedBinding; }
public ZeroMQWireTarget generateTarget(LogicalBinding<ZeroMQBinding> binding, ServiceContract contract, List<LogicalOperation> operations) { validateServiceContract(contract); ZeroMQMetadata metadata = binding.getDefinition().getZeroMQMetadata(); if (binding.isCallback()) { URI targetUri = URI.create("zmq://" + contract.getInterfaceName()); return new ZeroMQWireTarget(targetUri, metadata); } URI targetUri; // If this is an undeployment, use the previously calculated target URI. This must be done since the target component may no longer // be in the domain if it has been undeployed from another zone. if (LogicalState.MARKED == binding.getState()) { targetUri = binding.getMetadata(TARGET_URI, URI.class); } else { targetUri = binding.getDefinition().getTargetUri();// parseTargetUri(binding); if (targetUri != null) { targetUri = URI.create(binding.getParent().getParent().getParent().getUri() + "/" + targetUri); } else { // create a synthetic name targetUri = URI.create("f3synthetic://" + binding.getParent().getUri() + "/" + binding.getDefinition().getName()); } binding.addMetadata(TARGET_URI, targetUri); } return generateTarget(contract, targetUri, metadata); }
public MetroWireTarget generateTarget(LogicalBinding<WsBinding> binding, JavaServiceContract contract) { URL targetUrl = null; WsBinding bindingDefinition = binding.getDefinition(); URI targetUri = bindingDefinition.getTargetUri(); if (binding.isCallback() && targetUri != null) { throw new Fabric3Exception("A web services callback binding cannot be used with a binding URI on a service: " + binding.getParent().getUri()); } if (targetUri != null) { if (!targetUri.isAbsolute() && !binding.isCallback()) { throw new Fabric3Exception("Web service binding URI must be absolute on reference: " + binding.getParent().getUri()); } try { targetUrl = targetUri.toURL(); } catch (MalformedURLException e) { throw new Fabric3Exception(e); } } else if (bindingDefinition.getWsdlElement() == null && bindingDefinition.getWsdlLocation() == null && !binding.isCallback()) { throw new Fabric3Exception("A web service binding URI must be specified: " + binding.getParent().getUri()); } return generateTarget(binding, targetUrl, contract); }
/** * Returns a binding matching the name * * @param name the binding name * @param bindable the bindable containing the binding * @return the matching binding or null if no matching one was found */ private LogicalBinding<?> getBinding(String name, LogicalBindable bindable) { LogicalBinding<?> selectedBinding = null; for (LogicalBinding<?> binding : bindable.getBindings()) { if (name.equals(binding.getDefinition().getName())) { selectedBinding = binding; break; } } return selectedBinding; }
public PhysicalConnectionTarget generateConnectionTarget(LogicalProducer producer, LogicalBinding<ZeroMQBinding> binding, DeliveryType deliveryType) { ZeroMQBinding bindingDefinition = binding.getDefinition(); URI targetUri = bindingDefinition.getTargetUri(); if (targetUri == null) { // no target uri specified, generate one as it is not used for the endpoint address targetUri = binding.getParent().getUri(); } ZeroMQMetadata metadata = bindingDefinition.getZeroMQMetadata(); setChannelName(binding, metadata); boolean dedicatedThread = DeliveryType.ASYNCHRONOUS_WORKER == deliveryType; return new ZeroMQConnectionTarget(targetUri, metadata, dedicatedThread); }
/** * Selects a binding from the given bindable by matching it against another binding * * @param bindable the bindable to select the binding from * @param binding the binding to match against * @return the selected binding or null if no matching ones were found */ private LogicalBinding<?> selectBinding(LogicalBindable bindable, LogicalBinding binding) { for (LogicalBinding<?> candidate : bindable.getBindings()) { if (candidate.getDefinition().getType().equals(binding.getDefinition().getType())) { return candidate; } } return null; }