User: d_jencks
  Date: 02/04/04 09:49:18

  Modified:    src/main/org/jboss/system ServiceConfigurator.java
                        ServiceController.java ServiceCreator.java
  Log:
  more little fixes to the class-mbean dependency management
  
  Revision  Changes    Path
  1.7       +39 -32    jboss-system/src/main/org/jboss/system/ServiceConfigurator.java
  
  Index: ServiceConfigurator.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss-system/src/main/org/jboss/system/ServiceConfigurator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ServiceConfigurator.java  4 Apr 2002 02:17:22 -0000       1.6
  +++ ServiceConfigurator.java  4 Apr 2002 17:49:18 -0000       1.7
  @@ -61,7 +61,8 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Hiram Chirino</a>
  - * @version $Revision: 1.6 $
  + * @author <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
  + * @version $Revision: 1.7 $
    *
    * <p><b>20010830 marc fleury:</b>
    * <ul>
  @@ -130,15 +131,7 @@
         {
         if (config.getTagName().equals("mbean"))
         {
  -         try
  -         {
  -            internalInstall(config, mbeans);
  -         }
  -         catch (ClassNotFoundException cnfe)
  -         {
  -            //ignore
  -         }
  -
  +         internalInstall(config, mbeans);
         }
         else
         {
  @@ -153,15 +146,7 @@
                  if (element.getTagName().equals("mbean"))
                     {
                     Element mbean = (Element)nl.item(i);
  -                  try
  -                  {
  -                     internalInstall(mbean, mbeans);
  -                  }
  -                  catch (ClassNotFoundException cnfe)
  -                     {
  -                     //ignore
  -                  }
  -
  +                  internalInstall(mbean, mbeans);
                  } // end of if ()
               } // end of if ()
            }//end of for
  @@ -188,24 +173,26 @@
         } // end of try-catch
      }
   
  -   private ObjectName internalInstall(Element mbeanElement, List mbeans) throws 
DeploymentException, ClassNotFoundException
  +   private ObjectName internalInstall(Element mbeanElement, List mbeans) throws 
DeploymentException
      {
         ObjectInstance instance = null;
  +      ObjectName mbeanName = parseObjectName(mbeanElement);
         try 
         {
  -         instance = serviceCreator.install(mbeanElement);
  +         instance = serviceCreator.install(mbeanName, mbeanElement);
         }
         catch (ClassNotFoundException cnfe)
         {
  -      serviceController.registerWaitingForClass(mbeanElement);
  -      throw cnfe;
  +      serviceController.registerWaitingForClass(mbeanName, mbeanElement);
  +      return mbeanName;
         }
         catch (Exception e)
         {
            throw new DeploymentException("could not create mbean", e);
         } // end of catch
         serviceController.registerMBeanClassName(instance);
  -      ObjectName mbeanName = instance.getObjectName();
  +      //just in case it changed...
  +      mbeanName = instance.getObjectName();
         
         mbeans.add(mbeanName);
         if (mbeanName != null) 
  @@ -462,14 +449,7 @@
               Element child = (Element)childNode;
               if (child.getTagName().equals("mbean"))
               {
  -            try
  -            {
  -               dependsObjectName = internalInstall(child, mbeans);
  -            }
  -            catch (ClassNotFoundException cnfe)
  -            {
  -               log.info("FIX HANDLING OF ClassNotFound", cnfe);
  -            }
  +            dependsObjectName = internalInstall(child, mbeans);
                  break;
               }
               else
  @@ -631,6 +611,33 @@
         mbeanElement.appendChild(dependsElement);
         }
         return mbeanElement;
  +   }
  +   /**
  +    * Parse an object name from the given element attribute 'name'.
  +    *
  +    * @param element    Element to parse name from.
  +    * @return           Object name.
  +    *
  +    * @throws ConfigurationException   Missing attribute 'name'
  +    *                                  (thrown if 'name' is null or "").
  +    * @throws MalformedObjectNameException
  +    */
  +   private ObjectName parseObjectName(final Element element)
  +      throws DeploymentException
  +   {
  +      String name = element.getAttribute("name");
  +      if (name == null || name.trim().equals("")) 
  +      {
  +         throw new DeploymentException("MBean attribute 'name' must be given.");
  +      }
  +      try
  +      {
  +      return new ObjectName(name);
  +      }
  +      catch (MalformedObjectNameException mone)
  +      {
  +      throw new DeploymentException("Malformed ObjectName: " + name);
  +      }
      }
   
   }
  
  
  
  1.9       +10 -10    jboss-system/src/main/org/jboss/system/ServiceController.java
  
  Index: ServiceController.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss-system/src/main/org/jboss/system/ServiceController.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ServiceController.java    4 Apr 2002 16:52:15 -0000       1.8
  +++ ServiceController.java    4 Apr 2002 17:49:18 -0000       1.9
  @@ -48,7 +48,7 @@
    * 
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
  - * @version $Revision: 1.8 $ <p>
  + * @version $Revision: 1.9 $ <p>
    *
    * <b>Revisions:</b> <p>
    *
  @@ -104,7 +104,7 @@
       * that cannot be deployed because the mbean class is not available.
       *
       */
  -   private Set waitingConfigs = new HashSet();
  +   private Map waitingConfigs = new HashMap();
      
      // Constructors --------------------------------------------------
      
  @@ -162,7 +162,7 @@
       */
      public List listWaitingMBeans() throws Exception
      {
  -      return new ArrayList(waitingConfigs);
  +      return new ArrayList(waitingConfigs.keySet());
      }
      
      /**
  @@ -662,7 +662,7 @@
               stop(mbeanName);
               destroy(mbeanName);
               remove(mbeanName);
  -            registerWaitingForClass(mbeanConfig);
  +            registerWaitingForClass(mbeanName, mbeanConfig);
            }
            catch (Exception e)
            {
  @@ -672,10 +672,10 @@
         }
      }
   
  -   synchronized void registerWaitingForClass(Element mbeanElement)
  +   synchronized void registerWaitingForClass(ObjectName mbeanName, Element 
mbeanElement)
      {
  -      log.trace("registering waiting for class: " + mbeanElement);
  -      waitingConfigs.add(mbeanElement);
  +      log.trace("registering waiting for class: " + mbeanName);
  +      waitingConfigs.put(mbeanName, mbeanElement);
      }
   
      /**
  @@ -685,13 +685,13 @@
      public void newClassLoaderNotification()
      {
         log.trace("Scanning for newly supplied classes for waiting mbeans");
  -      Set waiting = null;
  +      Map waiting = null;
         synchronized (this)
         {
         waiting = waitingConfigs;
  -      waitingConfigs = new HashSet();
  +      waitingConfigs = new HashMap();
         }
  -      for (Iterator i = waiting.iterator(); i.hasNext(); )
  +      for (Iterator i = waiting.values().iterator(); i.hasNext(); )
         {
         Element mbeanElement = (Element)i.next();
         try
  
  
  
  1.3       +16 -32    jboss-system/src/main/org/jboss/system/ServiceCreator.java
  
  Index: ServiceCreator.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-system/src/main/org/jboss/system/ServiceCreator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServiceCreator.java       4 Apr 2002 02:17:22 -0000       1.2
  +++ ServiceCreator.java       4 Apr 2002 17:49:18 -0000       1.3
  @@ -17,6 +17,7 @@
   import javax.management.MalformedObjectNameException;
   
   import org.jboss.logging.Logger;
  +import org.jboss.deployment.DeploymentException;
   import org.jboss.util.jmx.JMXExceptionDecoder;
   
   import org.w3c.dom.Element;
  @@ -28,7 +29,8 @@
    * @see Service
    * 
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
  - * @version $Revision: 1.2 $
  + * @author <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
  + * @version $Revision: 1.3 $
    * 
    * <p><b>Revisions:</b>
    * <p><b>2001/08/03 marcf </b>
  @@ -59,18 +61,21 @@
       *                                  invalid or missing syntax.
       * @throws Exception                Failed for some other reason.
       */
  -   public ObjectInstance install(Element mbeanElement) throws Exception
  +   public ObjectInstance install(ObjectName mbeanName, Element mbeanElement) throws 
Exception
      {
         boolean debug = log.isDebugEnabled();
   
  -      ObjectName name = parseObjectName(mbeanElement);
  +      if (server.isRegistered(mbeanName))
  +      {
  +      throw new DeploymentException("Trying to install an already registered mbean: 
" + mbeanName);
  +      }
   
  -      // marcf fixme add and remove the classlaoder from the controller
  +      // marcf fixme add and remove the classloader from the controller
   
         ObjectName loader = new ObjectName("jboss.system.classloader:id=" +
  -                                         name.hashCode());
  +                                         mbeanName.hashCode());
   
  -      MBeanClassLoader cl = new MBeanClassLoader(name);
  +      MBeanClassLoader cl = new MBeanClassLoader(mbeanName);
   
         if (!server.isRegistered(loader))
            server.registerMBean(cl, loader);
  @@ -87,7 +92,7 @@
   
         ConstructorInfo.create(mbeanElement);
         
  -      if (debug) log.debug("About to create bean: "+name);
  +      log.debug("About to create bean: " + mbeanName);
   
                
         // Create the MBean instance
  @@ -97,12 +102,12 @@
            log.debug("code: " + code);
         }
            ObjectInstance instance = server.createMBean(code,
  -                                                      name,
  +                                                      mbeanName,
                                                         loader,
                                                         constructor.params,
                                                         constructor.signature);
            if (debug)
  -            log.debug("Created bean: "+name);
  +            log.debug("Created bean: "+mbeanName);
                
            return instance;
         } 
  @@ -111,14 +116,14 @@
         Throwable newE = JMXExceptionDecoder.decode(e);
         if (newE instanceof ClassNotFoundException)
         {
  -         log.debug("Class not found for mbean: " + name);
  +         log.debug("Class not found for mbean: " + mbeanName);
            throw (ClassNotFoundException)newE;
         }
   
            // didn't work, unregister in case the jmx agent is screwed.
            try 
            {
  -            server.unregisterMBean(name);
  +            server.unregisterMBean(mbeanName);
            }
            catch (Exception ignore) {}
            
  @@ -274,25 +279,4 @@
         }
      }
      
  -   /**
  -    * Parse an object name from the given element attribute 'name'.
  -    *
  -    * @param element    Element to parse name from.
  -    * @return           Object name.
  -    *
  -    * @throws ConfigurationException   Missing attribute 'name'
  -    *                                  (thrown if 'name' is null or "").
  -    * @throws MalformedObjectNameException
  -    */
  -   private ObjectName parseObjectName(final Element element)
  -      throws ConfigurationException, MalformedObjectNameException
  -   {
  -      String name = element.getAttribute("name");
  -      if (name == null || name.trim().equals("")) {
  -         throw new ConfigurationException
  -         ("MBean attribute 'name' must be given.");
  -      }
  -      
  -      return new ObjectName(name);
  -   }
   }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to