/** * Adds the given bean, detecting whether to manage it or not. * If the bean is a {@link LifeCycle}, then it will be managed if it is not * already started and not managed if it is already started. * The {@link #addBean(Object, boolean)} * method should be used if this is not correct, or the {@link #manage(Object)} and {@link #unmanage(Object)} * methods may be used after an add to change the status. * * @param o the bean object to add * @return true if the bean was added, false if it was already present */ @Override public boolean addBean(Object o) { if (o instanceof LifeCycle) { LifeCycle l = (LifeCycle)o; return addBean(o,l.isRunning()?Managed.UNMANAGED:Managed.AUTO); } return addBean(o,Managed.POJO); }
/** * Adds a managed lifecycle. * <p>This is a convenience method that uses addBean(lifecycle,true) * and then ensures that the added bean is started iff this container * is running. Exception from nested calls to start are caught and * wrapped as RuntimeExceptions * @param lifecycle the managed lifecycle to add */ public void addManaged(LifeCycle lifecycle) { addBean(lifecycle,true); try { if (isRunning() && !lifecycle.isRunning()) start(lifecycle); } catch (RuntimeException | Error e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
if (!lc.isRunning()) { try { lc.start();
public void run() { for (LifeCycle lc : _jettys) { if (lc.isRunning()) { try { lc.stop(); } catch (Exception e) { changeState(STOPPING, e); } } } if (_context != null) { PortMapper pm = _context.portMapper(); if (_port > 0 && pm.getPort(PortMapper.SVC_EEPSITE) == _port) { _port = 0; pm.unregister(PortMapper.SVC_EEPSITE); } if (_sslPort > 0 && pm.getPort(PortMapper.SVC_HTTPS_EEPSITE) == _sslPort) { _sslPort = 0; pm.unregister(PortMapper.SVC_HTTPS_EEPSITE); } } changeState(STOPPED); } }
public void stopComponents() throws Exception { Collections.reverse(components); // if Jetty thread is still waiting for a component to start, this should unblock it interrupt(); for (LifeCycle component : components) { if (component.isRunning()) { log.info("Stopping: {}", component); component.stop(); } } components.clear(); stopped.await(); }
public void stopComponents() throws Exception { Collections.reverse(components); // if Jetty thread is still waiting for a component to start, this should unblock it interrupt(); for (LifeCycle component : components) { if (component.isRunning()) { log.info("Stopping: {}", component); component.stop(); } } components.clear(); stopped.await(); }
/** * Stop the joined lifecycle beans in the reverse order they were added. * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override protected void doStop() throws Exception { _started=false; super.doStop(); List<Bean> reverse = new ArrayList<Bean>(_beans); Collections.reverse(reverse); for (Bean b:reverse) { if (b._managed && b._bean instanceof LifeCycle) { LifeCycle l=(LifeCycle)b._bean; if (l.isRunning()) l.stop(); } } }
/** * Stop the joined lifecycle beans in the reverse order they were added. * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override protected void doStop() throws Exception { _started=false; super.doStop(); List<Bean> reverse = new ArrayList<Bean>(_beans); Collections.reverse(reverse); for (Bean b:reverse) { if (b._managed && b._bean instanceof LifeCycle) { LifeCycle l=(LifeCycle)b._bean; if (l.isRunning()) l.stop(); } } }
/** * Stops the managed lifecycle beans in the reverse order they were added. */ @Override protected void doStop() throws Exception { _doStarted = false; super.doStop(); List<Bean> reverse = new ArrayList<>(_beans); Collections.reverse(reverse); for (Bean b : reverse) { if (b._managed==Managed.MANAGED && b._bean instanceof LifeCycle) { LifeCycle l = (LifeCycle)b._bean; if (l.isRunning()) stop(l); } } }
/** * Stop the joined lifecycle beans in the reverse order they were added. * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override protected void doStop() throws Exception { _started=false; super.doStop(); List<Bean> reverse = new ArrayList<Bean>(_beans); Collections.reverse(reverse); for (Bean b:reverse) { if (b._managed && b._bean instanceof LifeCycle) { LifeCycle l=(LifeCycle)b._bean; if (l.isRunning()) l.stop(); } } }
/** * Start the managed lifecycle beans in the order they were added. * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override protected void doStart() throws Exception { for (Bean b:_beans) { if (b._managed && b._bean instanceof LifeCycle) { LifeCycle l=(LifeCycle)b._bean; if (!l.isRunning()) l.start(); } } // indicate that we are started, so that addBean will start other beans added. _started=true; super.doStart(); }
/** * Start the managed lifecycle beans in the order they were added. * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override protected void doStart() throws Exception { for (Bean b:_beans) { if (b._managed && b._bean instanceof LifeCycle) { LifeCycle l=(LifeCycle)b._bean; if (!l.isRunning()) l.start(); } } // indicate that we are started, so that addBean will start other beans added. _started=true; super.doStart(); }
/** * Start the managed lifecycle beans in the order they were added. * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart() */ @Override protected void doStart() throws Exception { for (Bean b:_beans) { if (b._managed && b._bean instanceof LifeCycle) { LifeCycle l=(LifeCycle)b._bean; if (!l.isRunning()) l.start(); } } // indicate that we are started, so that addBean will start other beans added. _started=true; super.doStart(); }
@Override protected void doStart() throws Exception { super.doStart(); if (_threadPool == null) { _threadPool = getServer().getThreadPool(); _privateThreadPool = false; } if (_threadPool instanceof LifeCycle && !((LifeCycle)_threadPool).isRunning()) ((LifeCycle)_threadPool).start(); _selectorManager.start(); }
@Override protected void doStart() throws Exception { super.doStart(); if (_threadPool == null) { _threadPool = getServer().getThreadPool(); _privateThreadPool = false; } if (_threadPool instanceof LifeCycle && !((LifeCycle)_threadPool).isRunning()) ((LifeCycle)_threadPool).start(); _selectorManager.start(); }
@Override protected void doStart() throws Exception { super.doStart(); if (_threadPool == null) { _threadPool = getServer().getThreadPool(); _privateThreadPool = false; } if (_threadPool instanceof LifeCycle && !((LifeCycle)_threadPool).isRunning()) ((LifeCycle)_threadPool).start(); _selectorManager.start(); }
@Override protected void doStart() throws Exception { super.doStart(); if (_threadPool == null) { _threadPool = getServer().getThreadPool(); _privateThreadPool = false; } if (_threadPool instanceof LifeCycle && !((LifeCycle)_threadPool).isRunning()) ((LifeCycle)_threadPool).start(); _selectorManager.start(); }
@Override protected void doStart() throws Exception { super.doStart(); if (_threadPool == null) { _threadPool = getServer().getThreadPool(); _privateThreadPool = false; } if (_threadPool instanceof LifeCycle && !((LifeCycle)_threadPool).isRunning()) ((LifeCycle)_threadPool).start(); _selectorManager.start(); }