costin 2003/02/08 18:31:08 Modified: catalina/src/share/org/apache/catalina/core ContainerBase.java Log: Few changes to improve the mbean registration ( and unregistration ). There are 2 scenarios I want to support: the current one, where components are added/removed using internal APIs. And a JMX one, where components are created by via JMX, and they insert themself in the running system ( for example the admin interface creates a new connector Mbean and starts it ). The big change is that the JMX handling is now in the component itself - each component will be aware if its JMX identity and will take care of registering and unregistering the childs. While this removes some of the flexibility ( i.e. JMX will be deep inside, instead of a listener ), I think the code will be cleaner and we'll gain some other fexibilities. Revision Changes Path 1.6 +47 -4 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ContainerBase.java Index: ContainerBase.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ContainerBase.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ContainerBase.java 30 Jan 2003 14:24:43 -0000 1.5 +++ ContainerBase.java 9 Feb 2003 02:31:08 -0000 1.6 @@ -836,6 +836,21 @@ } } children.put(child.getName(), child); + if( child instanceof ContainerBase ) { + ContainerBase childCB=(ContainerBase)child; + // XXX we should also send JMX notifications + if( childCB.getObjectName() == null ) { + // child was not registered yet. + ObjectName oname=childCB.createObjectName(this.getDomain(), + this.getObjectName()); + if( oname != null ) { + // XXX Register the child + + } + + } + } + fireContainerEvent(ADD_CHILD_EVENT, child); } @@ -1054,6 +1069,14 @@ log.error("ContainerBase.removeChild: stop: ", e); } } + if( child instanceof ContainerBase ) { + ContainerBase childCB=(ContainerBase)child; + // XXX we should also send JMX notifications + ObjectName oname=childCB.getObjectName(); + if( oname != null ) { + // XXX UnRegister the child + } + } fireContainerEvent(REMOVE_CHILD_EVENT, child); child.setParent(null); @@ -1226,9 +1249,10 @@ public synchronized void stop() throws LifecycleException { // Validate and update our current component state - if (!started) - throw new LifecycleException - (sm.getString("containerBase.notStarted", logName())); + if (!started) { + log.info(sm.getString("containerBase.notStarted", logName())); + return; + } // Notify our interested LifecycleListeners lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null); @@ -1523,5 +1547,24 @@ public void postDeregister() { } + + public ObjectName[] getChildren() { + ObjectName result[]=new ObjectName[children.size()]; + Iterator it=children.values().iterator(); + int i=0; + while( it.hasNext() ) { + Object next=it.next(); + if( next instanceof ContainerBase ) { + result[i++]=((ContainerBase)next).getObjectName(); + } + } + return result; + } + + public ObjectName createObjectName(String domain, ObjectName parent) { + log.info("Create ObjectName " + domain + " " + parent ); + return null; + } + }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]