private void setStopped() { _state = STOPPED; if (_listeners != null) { for (int i = 0; i < _listeners.length; i++) { _listeners[i].lifeCycleStopped(this); } } }
private void setStarted() { _state = STARTED; if (_listeners != null) { for (int i = 0; i < _listeners.length; i++) { _listeners[i].lifeCycleStarted(this); } } }
private void setStarting() { _state = STARTING; if (_listeners != null) { for (int i = 0; i < _listeners.length; i++) { _listeners[i].lifeCycleStarting(this); } } }
/** Update single parent to child relationship. * @param parent The parent of the child. * @param oldChild The previous value of the child. If this is non null and differs from <code>child</code>, then a remove event is generated. * @param child The current child. If this is non null and differs from <code>oldChild</code>, then an add event is generated. * @param relationship The name of the relationship * @param addRemoveBean If true add/remove is called for the new/old children as well as the relationships */ public synchronized void update(Object parent, Object oldChild, final Object child, String relationship,boolean addRemove) { if (oldChild!=null && !oldChild.equals(child)) { remove(parent,oldChild,relationship); if (addRemove) removeBean(oldChild); } if (child!=null && !child.equals(oldChild)) { if (addRemove) addBean(child); add(parent,child,relationship); } }
public final void stop() throws Exception { synchronized (_lock) { try { if (_state == STOPPING || _state == STOPPED) return; setStopping(); doStop(); Log.debug("stopped {}",this); setStopped(); } catch (Exception e) { Log.warn("failed " + this,e); setFailed(e); throw e; } catch (Error e) { Log.warn("failed " + this,e); setFailed(e); throw e; } } }
public final void start() throws Exception { synchronized (_lock) { try { if (_state == STARTED || _state == STARTING) return; setStarting(); doStart(); Log.debug("started {}",this); setStarted(); } catch (Exception e) { Log.warn("failed " + this,e); setFailed(e); throw e; } catch (Error e) { Log.warn("failed " + this,e); setFailed(e); throw e; } } }
/** Update multiple parent to child relationship. * @param parent The parent of the child. * @param oldChildren The previous array of children. A remove event is generated for any child in this array but not in the <code>children</code> array. * This array is modified and children that remain in the new children array are nulled out of the old children array. * @param children The current array of children. An add event is generated for any child in this array but not in the <code>oldChildren</code> array. * @param relationship The name of the relationship */ public synchronized void update(Object parent, Object[] oldChildren, final Object[] children, String relationship) { update(parent,oldChildren,children,relationship,false); }
/** Update single parent to child relationship. * @param parent The parent of the child. * @param oldChild The previous value of the child. If this is non null and differs from <code>child</code>, then a remove event is generated. * @param child The current child. If this is non null and differs from <code>oldChild</code>, then an add event is generated. * @param relationship The name of the relationship */ public synchronized void update(Object parent, Object oldChild, final Object child, String relationship) { if (oldChild!=null && !oldChild.equals(child)) remove(parent,oldChild,relationship); if (child!=null && !child.equals(oldChild)) add(parent,child,relationship); }
/** Add a parent child relationship * @param parent * @param child * @param relationship */ private void add(Object parent, Object child, String relationship) { if (Log.isDebugEnabled()) Log.debug("Container "+parent+" + "+child+" as "+relationship); if (_listeners!=null) { Relationship event=new Relationship(this,parent,child,relationship); for (int i=0; i<LazyList.size(_listeners); i++) ((Listener)LazyList.get(_listeners, i)).add(event); } }
/** remove a parent child relationship * @param parent * @param child * @param relationship */ private void remove(Object parent, Object child, String relationship) { if (Log.isDebugEnabled()) Log.debug("Container "+parent+" - "+child+" as "+relationship); if (_listeners!=null) { Relationship event=new Relationship(this,parent,child,relationship); for (int i=0; i<LazyList.size(_listeners); i++) ((Listener)LazyList.get(_listeners, i)).remove(event); } }
private void setStopping() { _state = STOPPING; if (_listeners != null) { for (int i = 0; i < _listeners.length; i++) { _listeners[i].lifeCycleStopping(this); } } }
private void setFailed(Throwable error) { _state = FAILED; if (_listeners != null) { for (int i = 0; i < _listeners.length; i++) { _listeners[i].lifeCycleFailure(this,error); } } }
public void removeBean(Object obj) { if (_listeners!=null) { for (int i=0; i<LazyList.size(_listeners); i++) ((Listener)LazyList.get(_listeners, i)).removeBean(obj); } }
public void addBean(Object obj) { if (_listeners!=null) { for (int i=0; i<LazyList.size(_listeners); i++) { Listener listener=(Listener)LazyList.get(_listeners, i); listener.addBean(obj); } } }
remove(parent,oldChildren[i],relationship); if (addRemove) removeBean(oldChildren[i]); addBean(newChildren[i]); add(parent,newChildren[i],relationship);
/** * @param realms Map of realm name to UserRealm instances. */ public void setUserRealms(UserRealm[] realms) { _container.update(this,_realms,realms, "realm",true); _realms=realms; }
/** * @param threadPool The threadPool to set. */ public void setThreadPool(ThreadPool threadPool) { _container.update(this,_threadPool,threadPool, "threadpool",true); _threadPool = threadPool; }
/** * @param sessionIdManager The sessionIdManager to set. */ public void setSessionIdManager(SessionIdManager sessionIdManager) { _container.update(this,_sessionIdManager,sessionIdManager, "sessionIdManager",true); _sessionIdManager = sessionIdManager; }