Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 50807 invoked from network); 11 Jan 2003 07:28:14 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 11 Jan 2003 07:28:14 -0000 Received: (qmail 25886 invoked by uid 97); 11 Jan 2003 07:29:43 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 25830 invoked by uid 97); 11 Jan 2003 07:29:42 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 25812 invoked by uid 97); 11 Jan 2003 07:29:41 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: 11 Jan 2003 07:28:07 -0000 Message-ID: <20030111072807.58007.qmail@icarus.apache.org> From: costin@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/modeler/src/java/org/apache/commons/modeler BaseModelMBean.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N costin 2003/01/10 23:28:07 Modified: modeler/src/java/org/apache/commons/modeler BaseModelMBean.java Log: Added support for MbeanRegistration. Added a getClassName() method. Sorry about imports - I found no way to tell idea to not colapse them ( there are about 16 javax.management.XXX ) Revision Changes Path 1.11 +48 -23 jakarta-commons/modeler/src/java/org/apache/commons/modeler/BaseModelMBean.java Index: BaseModelMBean.java =================================================================== RCS file: /home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/BaseModelMBean.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- BaseModelMBean.java 6 Jan 2003 05:53:00 -0000 1.10 +++ BaseModelMBean.java 11 Jan 2003 07:28:07 -0000 1.11 @@ -72,23 +72,7 @@ import java.lang.reflect.Method; import java.util.Iterator; import java.util.Hashtable; -import javax.management.Attribute; -import javax.management.AttributeChangeNotification; -import javax.management.AttributeList; -import javax.management.AttributeNotFoundException; -import javax.management.Descriptor; -import javax.management.ListenerNotFoundException; -import javax.management.MBeanException; -import javax.management.MBeanInfo; -import javax.management.MBeanNotificationInfo; -import javax.management.Notification; -import javax.management.NotificationFilter; -import javax.management.NotificationListener; -import javax.management.InstanceNotFoundException; -import javax.management.ReflectionException; -import javax.management.RuntimeErrorException; -import javax.management.RuntimeOperationsException; -import javax.management.ServiceNotFoundException; + import javax.management.modelmbean.DescriptorSupport; import javax.management.modelmbean.InvalidTargetObjectTypeException; import javax.management.modelmbean.ModelMBean; @@ -97,6 +81,7 @@ import javax.management.modelmbean.ModelMBeanInfoSupport; import javax.management.modelmbean.ModelMBeanNotificationInfo; import javax.management.modelmbean.ModelMBeanOperationInfo; +import javax.management.*; // TODO: enable ant-like substitutions ? ( or at least discuss it ) @@ -133,7 +118,7 @@ * @version $Revision$ $Date$ */ -public class BaseModelMBean implements ModelMBean { +public class BaseModelMBean implements ModelMBean, MBeanRegistration { private static Log log = LogFactory.getLog(BaseModelMBean.class); // ----------------------------------------------------------- Constructors @@ -244,7 +229,7 @@ */ public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, - ReflectionException { + ReflectionException { // Validate the input parameters if (name == null) throw new RuntimeOperationsException @@ -1201,6 +1186,13 @@ } } + public String getClassName() { + if( resource==null ) { + return null; + } + return resource.getClass().getName(); + } + // ------------------------------------------------------ Protected Methods @@ -1228,4 +1220,37 @@ return (true); } + // -------------------- Registration -------------------- + // XXX We can add some method patterns here - like setName() and + // setDomain() for code that doesn't implement the Registration + + public ObjectName preRegister(MBeanServer server, + ObjectName name) + throws Exception + { + if( log.isDebugEnabled()) + log.debug("preRegister " + resource + " " + name ); + if( resource instanceof MBeanRegistration ) { + return ((MBeanRegistration)resource).preRegister(server, name ); + } + return name; + } + + public void postRegister(Boolean registrationDone) { + if( resource instanceof MBeanRegistration ) { + ((MBeanRegistration)resource).postRegister(registrationDone); + } + } + + public void preDeregister() throws Exception { + if( resource instanceof MBeanRegistration ) { + ((MBeanRegistration)resource).preDeregister(); + } + } + + public void postDeregister() { + if( resource instanceof MBeanRegistration ) { + ((MBeanRegistration)resource).postDeregister(); + } + } } -- To unsubscribe, e-mail: For additional commands, e-mail: