public synchronized void stop() throws Exception { if (this.status == LifeCycleMBean.STARTED) { this.status = LifeCycleMBean.STOPPED; // Stop endpoints Exception exception = null; for (Endpoint endpoint : getEndpoints()) { try { endpoint.stop(); } catch (Exception e) { exception = e; } } if (exception != null) { throw exception; } } }
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 start() throws Exception { if (this.status == LifeCycleMBean.STOPPED) { // Activate endpoints List<Endpoint> activated = new ArrayList<Endpoint>(); try { for (Endpoint endpoint : getEndpoints()) { endpoint.start(); } this.status = LifeCycleMBean.STARTED; } catch (Exception e) { // Deactivate activated endpoints for (Endpoint endpoint : activated) { try { endpoint.stop(); } 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; } } }