public static String getState(LifeCycle lc) { if (lc.isStarting()) return STARTING; if (lc.isStarted()) return STARTED; if (lc.isStopping()) return STOPPING; if (lc.isStopped()) return STOPPED; return FAILED; }
@Override public void run() { for (LifeCycle lifeCycle : _thread._lifeCycles) { try { if (lifeCycle.isStarted()) { lifeCycle.stop(); LOG.debug("Stopped {}",lifeCycle); } if (lifeCycle instanceof Destroyable) { ((Destroyable)lifeCycle).destroy(); LOG.debug("Destroyed {}",lifeCycle); } } catch (Exception ex) { LOG.debug(ex); } } } }
/** * Add an associated bean. * If the bean is a {@link LifeCycle}, then it will be managed if it is not * already started and umanaged 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 or false if it has already been added. */ public boolean addBean(Object o) { // beans are joined unless they are started lifecycles return addBean(o,!((o instanceof LifeCycle)&&((LifeCycle)o).isStarted())); }
/** * Add an associated bean. * If the bean is a {@link LifeCycle}, then it will be managed if it is not * already started and umanaged 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 or false if it has already been added. */ public boolean addBean(Object o) { // beans are joined unless they are started lifecycles return addBean(o,!((o instanceof LifeCycle)&&((LifeCycle)o).isStarted())); }
/** * Add an associated bean. * If the bean is a {@link LifeCycle}, then it will be managed if it is not * already started and umanaged 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 or false if it has already been added. */ public boolean addBean(Object o) { // beans are joined unless they are started lifecycles return addBean(o,!((o instanceof LifeCycle)&&((LifeCycle)o).isStarted())); }
/** * Add an associated bean. * If the bean is a {@link LifeCycle}, then it will be managed if it is not * already started and umanaged 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 or false if it has already been added. */ public boolean addBean(Object o) { // beans are joined unless they are started lifecycles return addBean(o,!((o instanceof LifeCycle)&&((LifeCycle)o).isStarted())); }
/** * <p>Sets the thread pool associated to this CometD service.</p> * <p>If the {@link ThreadPool} is a {@link LifeCycle} instance, * and it is not already started, then it will started.</p> * * @param pool The ThreadPool */ public void setThreadPool(ThreadPool pool) { try { if (pool instanceof LifeCycle) { if (!((LifeCycle)pool).isStarted()) { ((LifeCycle)pool).start(); } } } catch (Exception e) { throw new IllegalStateException(e); } _threadPool = pool; }
private void stopLifeCycles(Predicate<LifeCycle> predicate, boolean destroy) { List<LifeCycle> lifeCycles = new ArrayList<>(); synchronized (this) { lifeCycles.addAll(_lifeCycles); } for (LifeCycle l : lifeCycles) { try { if (l.isStarted() && predicate.test(l)) l.stop(); if ((l instanceof Destroyable) && destroy) ((Destroyable)l).destroy(); } catch (Throwable x) { debug(x); } } } }
public static String getState(LifeCycle lc) { if (lc.isStarting()) return STARTING; if (lc.isStarted()) return STARTED; if (lc.isStopping()) return STOPPING; if (lc.isStopped()) return STOPPED; return FAILED; }
public static String getState(LifeCycle lc) { if (lc.isStarting()) return STARTING; if (lc.isStarted()) return STARTED; if (lc.isStopping()) return STOPPING; if (lc.isStopped()) return STOPPED; return FAILED; }
public static String getState(LifeCycle lc) { if (lc.isStarting()) return STARTING; if (lc.isStarted()) return STARTED; if (lc.isStopping()) return STOPPING; if (lc.isStopped()) return STOPPED; return FAILED; }
public static String getState(LifeCycle lc) { if (lc.isStarting()) return STARTING; if (lc.isStarted()) return STARTED; if (lc.isStopping()) return STOPPING; if (lc.isStopped()) return STOPPED; return FAILED; }
public static String getState(LifeCycle lc) { if (lc.isStarting()) return STARTING; if (lc.isStarted()) return STARTED; if (lc.isStopping()) return STOPPING; if (lc.isStopped()) return STOPPED; return FAILED; }
public static String getState(LifeCycle lc) { if (lc.isStarting()) return STARTING; if (lc.isStarted()) return STARTED; if (lc.isStopping()) return STOPPING; if (lc.isStopped()) return STOPPED; return FAILED; }
public static String getState(LifeCycle lc) { if (lc.isStarting()) return STARTING; if (lc.isStarted()) return STARTED; if (lc.isStopping()) return STOPPING; if (lc.isStopped()) return STOPPED; return FAILED; }
public static String getState(LifeCycle lc) { if (lc.isStarting()) return STARTING; if (lc.isStarted()) return STARTED; if (lc.isStopping()) return STOPPING; if (lc.isStopped()) return STOPPED; return FAILED; }
@Override public void run() { for (LifeCycle lifeCycle : _thread._lifeCycles) { try { if (lifeCycle.isStarted()) { lifeCycle.stop(); LOG.debug("Stopped {}",lifeCycle); } } catch (Exception ex) { LOG.debug(ex); } } } }
@Override public void run() { for (LifeCycle lifeCycle : _thread._lifeCycles) { try { if (lifeCycle.isStarted()) { lifeCycle.stop(); LOG.debug("Stopped {}",lifeCycle); } } catch (Exception ex) { LOG.debug(ex); } } } }
@Override public void run() { for (LifeCycle lifeCycle : _thread._lifeCycles) { try { if (lifeCycle.isStarted()) { lifeCycle.stop(); LOG.debug("Stopped {}",lifeCycle); } if (lifeCycle instanceof Destroyable) { ((Destroyable)lifeCycle).destroy(); LOG.debug("Destroyed {}",lifeCycle); } } catch (Exception ex) { LOG.debug(ex); } } } }
@Override public void run() { for (LifeCycle lifeCycle : _thread._lifeCycles) { try { if (lifeCycle.isStarted()) { lifeCycle.stop(); LOG.debug("Stopped {}",lifeCycle); } if (lifeCycle instanceof Destroyable) { ((Destroyable)lifeCycle).destroy(); LOG.debug("Destroyed {}",lifeCycle); } } catch (Exception ex) { LOG.debug(ex); } } } }