User: oberg   
  Date: 00/12/07 07:44:06

  Modified:    src/main/org/jboss/dependencies DependencyManager.java
  Log:
  Changed configuration scheme (lots of changes to jboss.conf, jboss.jcml, 
org.jboss.Main)
  Added ServiceControl
  Changed jBoss -> JBoss
  Changed GPL -> LGPL
  Added jaxp/parser
  Updated services to have default constructors
  
  Revision  Changes    Path
  1.4       +56 -3     jboss/src/main/org/jboss/dependencies/DependencyManager.java
  
  Index: DependencyManager.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/dependencies/DependencyManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DependencyManager.java    2000/09/29 17:00:08     1.3
  +++ DependencyManager.java    2000/12/07 15:44:06     1.4
  @@ -1,7 +1,7 @@
   /*
  - * jBoss, the OpenSource EJB server
  + * JBoss, the OpenSource EJB server
    *
  - * Distributable under GPL license.
  + * Distributable under LGPL license.
    * See terms of license at gnu.org.
    */
   package org.jboss.dependencies;
  @@ -17,6 +17,7 @@
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
   import javax.management.ReflectionException;
  +import javax.management.RuntimeErrorException;
   import org.xml.sax.AttributeList;
   import org.xml.sax.HandlerBase;
   import org.xml.sax.InputSource;
  @@ -28,7 +29,7 @@
    * and then starts a list of MBeans according to the dependencies in the
    * file.
    * @author Aaron Mulder <[EMAIL PROTECTED]>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class DependencyManager {
       // Static --------------------------------------------------------
  @@ -83,6 +84,23 @@
       }
   
       /**
  +     * Initializes all the MBeans in a server in an order consistant with the
  +     * dependencies.
  +     */
  +    public void initMBeans(MBeanServer server) {
  +        this.server = server;
  +
  +        // Init all the MBeans
  +        Iterator it = server.queryNames(null, null).iterator();
  +        while(it.hasNext()) {
  +            ObjectName name = (ObjectName)it.next();
  +            if(!initMBean(name)) {
  +                System.out.println("Unable to init MBean 
'"+name.getCanonicalName()+"'");
  +            }
  +        }
  +    }
  +    
  +    /**
        * Starts all the MBeans in a server in an order consistant with the
        * dependencies.
        */
  @@ -273,6 +291,41 @@
           return loaded;
       }
   
  +    /**
  +     * Calls the "init" method on an MBean.  If no such method is available,
  +     * that's OK, but if the call fails for another reason, returns false.
  +     */
  +    private boolean initMBean(ObjectName name) {
  +        boolean loaded = false;
  +        if(DEBUG) System.out.println("Initializing instance 
'"+name.getCanonicalName()+"'");
  +        try {
  +            server.invoke(name, "init", new Object[0], new String[0]);
  +            loaded = true;
  +        } catch(ReflectionException e) {
  +            if(e.getTargetException() instanceof NoSuchMethodException) {
  +                loaded = true;  // This bean doesn't have a start!
  +            } else {
  +                e.getTargetException().printStackTrace(System.err);
  +                System.out.println("BAR");
  +                if (e.getTargetException() instanceof RuntimeErrorException)
  +                {
  +                  System.out.println("FOO");
  +                   
((RuntimeErrorException)e.getTargetException()).getTargetError().printStackTrace(System.err);
  +                }
  +                
  +                System.out.println("Error initializing service 
'"+name.getCanonicalName()+"': "+e.getTargetException());
  +            }
  +        } catch(Throwable t) {
  +            if (t instanceof RuntimeErrorException)
  +            {
  +              System.out.println("LGPL");
  +               
((RuntimeErrorException)t).getTargetError().printStackTrace(System.err);
  +            }
  +            System.out.println("Error initializing service 
'"+name.getCanonicalName()+"': "+t);
  +        }
  +        return loaded;
  +    }
  +    
       /**
        * Calls the "start" method on an MBean.  If no such method is available,
        * that's OK, but if the call fails for another reason, returns false.
  
  
  

Reply via email to