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 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 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); } } }