protected List<Provides> getProvides(Endpoint endpoint) { List<Provides> providesList = new ArrayList<Provides>(); if (endpoint.getRole().equals(MessageExchange.Role.PROVIDER)) { Provides newProvide = new Provides(); newProvide.setEndpointName(endpoint.getEndpoint()); newProvide.setInterfaceName(endpoint.getInterfaceName()); newProvide.setServiceName(endpoint.getService()); providesList.add(newProvide); } return providesList; }
public synchronized void addEndpoint(Endpoint endpoint) throws DeploymentException { String key = endpoint.getKey(); if (this.endpoints.put(key, endpoint) != null) { throw new DeploymentException( "More than one endpoint found in the SU for key: " + key); } if (this.status == LifeCycleMBean.STOPPED) { try { endpoint.activate(); } catch (Exception e) { throw new DeploymentException(e); } } else if (this.status == LifeCycleMBean.STARTED) { try { endpoint.activate(); endpoint.start(); } catch (Exception e) { throw new DeploymentException(e); } } }
public synchronized void init() throws Exception { if (this.status == LifeCycleMBean.SHUTDOWN) { // Activate endpoints List<Endpoint> activated = new ArrayList<Endpoint>(); try { for (Endpoint endpoint : getEndpoints()) { endpoint.activate(); activated.add(endpoint); } this.status = LifeCycleMBean.STOPPED; } catch (Exception e) { // Deactivate activated endpoints for (Endpoint endpoint : activated) { try { endpoint.deactivate(); } catch (Exception e2) { // do nothing } } throw e; } } }
public OsgiServiceUnit(DefaultComponent component, Endpoint endpoint, ClassLoader classLoader) throws DeploymentException { this.component = component; this.endpoint = endpoint; this.classLoader = classLoader; this.endpoint.setServiceUnit(this); this.endpoint.validate(); this.name = endpoint.getKey(); addEndpoint(this.endpoint); } public Endpoint getEndpoint() {
public boolean isExchangeWithConsumerOkay(ServiceEndpoint endpoint, MessageExchange exchange) { String key = EndpointSupport.getKey(endpoint); Endpoint ep = this.registry.getEndpoint(key); if (ep != null) { if (ep.getRole() != Role.PROVIDER) { logger.debug("Endpoint {} is a consumer. Refusing exchange with consumer.", key); return false; } else { return ep.isExchangeOkay(exchange); } } else { logger.debug("No endpoint found for {}. Refusing exchange with consumer.", key); return false; } }
if (endpoint.getServiceName().equals(getEPRServiceName())) { ep = getResolvedEPR(exchange.getEndpoint()); ep.activate(); ep.start(); dynamic = true; ep.stop(); ep.deactivate();
public synchronized void removeEndpoint(Endpoint endpoint) throws DeploymentException { String key = endpoint.getKey(); if (this.endpoints.remove(key) == null) { throw new DeploymentException("Endpoint not found in the SU for key: " + EndpointSupport.getKey(endpoint)); } if (this.status == LifeCycleMBean.STOPPED) { try { component.prepareShutdown(endpoint); endpoint.deactivate(); } catch (Exception e) { throw new DeploymentException(e); } } else if (this.status == LifeCycleMBean.STARTED) { try { endpoint.stop(); component.prepareShutdown(endpoint); endpoint.deactivate(); } catch (Exception e) { throw new DeploymentException(e); } } }
public Map<String, String> getServiceUnits() { if (endpointRegistrations == null) { throw new IllegalStateException("Service assembly has not been deployed"); } Map<String, String> sus = new HashMap<String, String>(); for (Endpoint ep : getEndpoints()) { if (ep.getServiceUnit() == null) { // This should not happen, as we only register the SA after all endpoints have been deployed throw new IllegalStateException("Endpoint has not been initialized. Check that the component is installed."); } sus.put(ep.getServiceUnit().getName(), ep.getServiceUnit().getComponent().getComponentName()); } return sus; }
return; if (ep != null && (ep.getServiceUnit() == null || !ep.getServiceUnit().getComponent().getRegistry().isRegistered(ep.getServiceUnit()))) { logger.info("something wrong during register endpoint {}", ep.getKey()); e.getServiceUnit().getComponent().getRegistry().unregisterServiceUnit(e.getServiceUnit()); boolean initialized = true; for (Endpoint e : endpoints) { if (e.getServiceUnit().getComponent().getComponentContext() == null) { initialized = false; break;
boolean processed = false; try { ClassLoader cl = (ep != null) ? ep.getServiceUnit().getConfigurationClassLoader() : null; if (cl != null) { Thread.currentThread().setContextClassLoader(cl); EndpointDeliveryChannel.setEndpoint(ep); handleExchange(ep, exchange, exchange.getStatus() == ExchangeStatus.ACTIVE); ep.process(exchange); processed = true; } finally {
public static String getKey(Endpoint endpoint) { return endpoint.getKey(); }
public Document getServiceDescription(ServiceEndpoint endpoint) { logger.debug("Querying service description for {}", endpoint); String key = EndpointSupport.getKey(endpoint); Endpoint ep = this.registry.getEndpoint(key); if (ep != null) { Document doc = ep.getDescription(); if (doc == null) { logger.debug("No description found for {}", key); } return doc; } else { logger.debug("No endpoint found for {}", key); return null; } }
public synchronized void shutDown() throws Exception { if (this.status == LifeCycleMBean.STARTED) { stop(); } if (this.status == LifeCycleMBean.STOPPED) { this.status = LifeCycleMBean.SHUTDOWN; // Deactivate endpoints Exception exception = null; for (Endpoint endpoint : getEndpoints()) { try { // TODO: uncomment when all tests in various components work fine // TODO: we also need to find a way to not wait forever on this call //component.prepareShutdown(endpoint); endpoint.deactivate(); } catch (Exception e) { exception = e; } } if (exception != null) { throw exception; } } }
public boolean isExchangeWithConsumerOkay(ServiceEndpoint endpoint, MessageExchange exchange) { String key = EndpointSupport.getKey(endpoint); Endpoint ep = this.registry.getEndpoint(key); if (ep != null) { if (ep.getRole() != MessageExchange.Role.PROVIDER) { logger.debug("Endpoint {} is a consumer. Refusing exchange with consumer.", key); return false; } else { return ep.isExchangeOkay(exchange); } } else { logger.debug("No endpoint found for {}. Refusing exchange with consumer.", key); return false; } }
public synchronized void removeEndpoint(Endpoint endpoint) throws Exception { registry.unregisterEndpoint(endpoint); endpoint.getServiceUnit().removeEndpoint(endpoint); }
public void unregisterEndpoint(Endpoint ep) { this.endpoints.remove(ep.getKey()); }
public Document getServiceDescription(ServiceEndpoint endpoint) { logger.debug("Querying service description for {}", endpoint); String key = EndpointSupport.getKey(endpoint); Endpoint ep = this.registry.getEndpoint(key); if (ep != null) { Document doc = ep.getDescription(); if (doc == null) { logger.debug("No description found for {}", key); } return doc; } else { logger.debug("No endpoint found for {}", key); return null; } }
protected List getConsumes(Endpoint endpoint) { List consumesList = new ArrayList(); Consumes consumes; if (endpoint.getRole().equals(MessageExchange.Role.CONSUMER)) { consumes = new Consumes(); JmsEndpoint httpEndpoint = (JmsEndpoint) endpoint; consumes.setEndpointName(httpEndpoint.getTargetEndpoint()); consumes.setInterfaceName(httpEndpoint.getTargetInterfaceName()); consumes.setServiceName(httpEndpoint.getTargetService()); if (consumes.isValid()) { consumesList.add(consumes); } else { consumes = new Consumes(); consumes.setEndpointName(endpoint.getEndpoint()); consumes.setInterfaceName(endpoint.getInterfaceName()); consumes.setServiceName(endpoint.getService()); consumesList.add(consumes); } } return consumesList; }
public EndpointComponentContext(Endpoint endpoint) { this.endpoint = endpoint; this.context = endpoint.getServiceUnit().getComponent().getComponentContext(); }
protected Set<String> getKnownExchanges(Endpoint endpoint) { Set<String> exchanges = knownExchanges.get(endpoint.getKey()); if (exchanges == null) { synchronized (knownExchanges) { exchanges = knownExchanges.get(endpoint.getKey()); if (exchanges == null) { exchanges = new HashSet<String>(); knownExchanges.put(endpoint.getKey(), exchanges); } } } return exchanges; }