public synchronized void shutDown()

in jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/artifacts/ServiceAssemblyImpl.java [210:244]


    public synchronized void shutDown(boolean persist, boolean force) throws JBIException {
        listener.setAssembly(this);
        final Semaphore semaphore = force && shutdownTimeout > 0 ? startShutdownMonitorThread() : null;
        try {
            if (state == State.Shutdown) {
                return;
            }
            if (state == State.Started) {
                transition(Action.Stop, State.Stopped);
            }
            fireEvent(LifeCycleEvent.LifeCycleEventType.ShuttingDown);
            if (!force) {
                for (; ;) {
                    try {
                        listener.waitFor(this);
                        break;
                    } catch (InterruptedException e) {
                    }
                }
            }
            transition(Action.Shutdown, State.Shutdown);
            if (persist) {
                saveState();
            }
            fireEvent(LifeCycleEvent.LifeCycleEventType.ShutDown);
        } finally {
            listener.setAssembly(null);
            listener.forget(this);
            
            //notify the shutdown monitor thread that things ended correctly
            if (semaphore != null) {
                semaphore.release();
            }
        }
    }