protected Registry createRegistry() { return new Registry(this); }
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 ServiceUnit getServiceUnit(String name) { return component.getRegistry().getServiceUnit(name); }
|| !ep.getServiceUnit().getComponent().getRegistry().isRegistered(ep.getServiceUnit()))) { logger.info("something wrong during register endpoint {}", ep.getKey()); e.getServiceUnit().getComponent().getRegistry().unregisterServiceUnit(e.getServiceUnit());
public DefaultComponent() { setComponent(this); logger.debug("Create the registry"); registry = createRegistry(); logger.debug("Create the SU manager"); serviceUnitManager = createServiceUnitManager(); logger.debug("Create the XBean SU"); XBeanServiceUnit su = new XBeanServiceUnit(); su.setName("#default#"); su.setComponent(this); serviceUnit = su; registry.registerServiceUnit(serviceUnit); }
public void registerServiceUnit(ServiceUnit su) { this.serviceUnits.put(su.getName(), su); Collection<Endpoint> endpoints = su.getEndpoints(); for (Endpoint endpoint : endpoints) { registerEndpoint(endpoint); } }
public void unregisterServiceUnit(ServiceUnit su) { this.serviceUnits.remove(su.getName()); Collection<Endpoint> endpoints = su.getEndpoints(); for (Endpoint endpoint : endpoints) { unregisterEndpoint(endpoint); } }
public boolean isRegistered(ServiceUnit su) { return isServiceUnitRegistered(su.getName()); }
public synchronized String undeploy(String serviceUnitName, String serviceUnitRootPath) throws DeploymentException { ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { logger.debug("Undeploying service unit"); logger.debug("Shutting down service unit"); if (serviceUnitName == null || serviceUnitName.length() == 0) { throw new IllegalArgumentException("serviceUnitName should be non null and non empty"); } ServiceUnit su = getServiceUnit(serviceUnitName); if (su == null) { throw failure("undeploy", "Service Unit '" + serviceUnitName + "' is not deployed", null); } if (!LifeCycleMBean.SHUTDOWN.equals(su.getCurrentState())) { throw failure("undeploy", "ServiceUnit should be in a SHUTDOWN state", null); } Thread.currentThread().setContextClassLoader(su.getConfigurationClassLoader()); if (serviceUnitRootPath != null) { doUndeploy(su); } component.getRegistry().unregisterServiceUnit(su); logger.debug("Service unit undeployed"); return createSuccessMessage("undeploy"); } catch (DeploymentException e) { throw e; } catch (Exception e) { throw failure("undeploy", "Unable to undeploy service unit", e); } finally { Thread.currentThread().setContextClassLoader(cl); } }
throw failure("init", "Unable to find suitable deployer for Service Unit '" + serviceUnitName + "'", null); component.getRegistry().registerServiceUnit(su); } else { throw failure("init", "Service Unit '" + serviceUnitName + "' is not deployed", null);
/** * Dynamically adds a new endpoint */ public synchronized void addEndpoint(Endpoint endpoint) throws Exception { endpoint.setServiceUnit(serviceUnit); validateEndpoint(endpoint); endpoint.validate(); registry.registerEndpoint(endpoint); serviceUnit.addEndpoint(endpoint); }
public synchronized void removeEndpoint(Endpoint endpoint) throws Exception { registry.unregisterEndpoint(endpoint); endpoint.getServiceUnit().removeEndpoint(endpoint); }
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 String deploy(String serviceUnitName, String serviceUnitRootPath) throws DeploymentException { try { logger.debug("Deploying service unit"); if (serviceUnitName == null || serviceUnitName.length() == 0) { throw new IllegalArgumentException("serviceUnitName should be non null and non empty"); } if (getServiceUnit(serviceUnitName) != null) { throw failure("deploy", "Service Unit '" + serviceUnitName + "' is already deployed", null); } ServiceUnit su = doDeploy(serviceUnitName, serviceUnitRootPath); if (su == null) { throw failure("deploy", "Unable to find suitable deployer for Service Unit '" + serviceUnitName + "'", null); } component.getRegistry().registerServiceUnit(su); logger.debug("Service unit deployed"); return createSuccessMessage("deploy"); } catch (DeploymentException e) { throw e; } catch (Exception e) { throw failure("deploy", "Unable to deploy service unit", e); } }
protected Registry createRegistry() { return new Registry(this); }
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; } }
public void register(EndpointWrapper wrapper, Map properties) throws Exception { logger.debug("[" + component.getComponentName() + "] Endpoint registered with properties: " + properties); Endpoint endpoint = wrapper.getEndpoint(); if (component.isKnownEndpoint(endpoint)) { logger.debug("[" + component.getComponentName() + "] Endpoint recognized"); try { OsgiServiceUnit su = new OsgiServiceUnit(component, endpoint, wrapper.getClassLoader()); component.getRegistry().registerServiceUnit(su); } finally { //get chance to do some clean up wrapper.setDeployed(); } } }
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; } }
ServiceEndpoint endpoint = exchange.getEndpoint(); String key = EndpointSupport.getKey(exchange.getEndpoint()); Endpoint ep = this.component.getRegistry().getEndpoint(key); if (ep == null) { if (endpoint.getServiceName().equals(getEPRServiceName())) { if (exchange.getProperty(JbiConstants.SENDER_ENDPOINT) != null) { String key = exchange.getProperty(JbiConstants.SENDER_ENDPOINT).toString(); ep = this.component.getRegistry().getEndpoint(key);