commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-commons/modeler/src/java/org/apache/commons/modeler Registry.java
Date Thu, 20 Feb 2003 05:54:22 GMT
costin      2003/02/19 21:54:22

  Modified:    modeler/src/java/org/apache/commons/modeler Registry.java
  Log:
  A method to register components by ObjectName, and few extra checks.
  
  The main function of the Registry is to find and create a model mbean
  for a regular java object ( bean ), using the XML model or introspection
  or other "magic".
  
  Revision  Changes    Path
  1.19      +17 -11    jakarta-commons/modeler/src/java/org/apache/commons/modeler/Registry.java
  
  Index: Registry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/Registry.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Registry.java	17 Feb 2003 01:00:09 -0000	1.18
  +++ Registry.java	20 Feb 2003 05:54:22 -0000	1.19
  @@ -334,24 +334,35 @@
   
       // -------------------- Instance registration  --------------------
   
  +    public void registerComponent(Object bean, String domain, String type,
  +                                  String name)
  +            throws Exception
  +    {
  +        StringBuffer sb=new StringBuffer();
  +        sb.append( domain ).append(":");
  +        sb.append( name );
  +        String nameStr=sb.toString();
  +        ObjectName oname=new ObjectName( nameStr );
  +        registerComponent(bean, oname, type );
  +    }
  +
       /** Main registration method
        *
        * If the metadata is not found, introspection will be used to generate
        * it automatically.
        *
        */
  -    public void registerComponent(Object bean, String domain, String type,
  -                                  String name)
  +    public void registerComponent(Object bean, ObjectName oname, String type)
              throws Exception
       {
  +
           if( bean ==null ) {
  -            log.error("Null component " + name );
  +            log.error("Null component " + oname );
               return;
           }
  -        String nameStr=null;
           try {
               if( type==null ) {
  -                // XXX find type from bean name.
  +                type=bean.getClass().getName();
               }
               ManagedBean managed = registry.findManagedBean(type);
               if( managed==null ) {
  @@ -372,11 +383,6 @@
   
               // The real mbean is created and registered
               ModelMBean mbean = managed.createMBean(bean);
  -            StringBuffer sb=new StringBuffer();
  -            sb.append( domain ).append(":");
  -            sb.append( name );
  -            nameStr=sb.toString();
  -            ObjectName oname=new ObjectName( nameStr );
   
               if(  getMBeanServer().isRegistered( oname )) {
                   if( log.isDebugEnabled())
  @@ -386,7 +392,7 @@
   
               getMBeanServer().registerMBean( mbean, oname);
           } catch( Exception ex) {
  -            log.error("Error registering " + nameStr, ex );
  +            log.error("Error registering " + oname, ex );
               throw ex;
           }
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message