geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config Configuration.java
Date Fri, 09 Apr 2004 18:46:22 GMT
dain        2004/04/09 11:46:22

  Modified:    modules/kernel/src/java/org/apache/geronimo/kernel/config
                        Configuration.java
  Log:
  Set thread context classloader before registering the GBeans as registration
  causes the GBean delegate to be constructed.
  
  Revision  Changes    Path
  1.18      +28 -21    incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
  
  Index: Configuration.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Configuration.java	10 Mar 2004 09:59:01 -0000	1.17
  +++ Configuration.java	9 Apr 2004 18:46:22 -0000	1.18
  @@ -163,28 +163,35 @@
               classLoader = new URLClassLoader(urls, parent.getClassLoader());
           }
   
  -        // create and initialize GBeans
  -        gbeans = loadGBeans(gbeanState, classLoader);
  +        ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
  +        try {
  +            Thread.currentThread().setContextClassLoader(classLoader);
   
  -        // register all the GBeans
  -        MBeanServer mbServer = context.getServer();
  -        for (Iterator i = gbeans.entrySet().iterator(); i.hasNext();) {
  -            Map.Entry entry = (Map.Entry) i.next();
  -            ObjectName name = (ObjectName) entry.getKey();
  -            GBeanMBean gbean = (GBeanMBean) entry.getValue();
  -            log.trace("Registering GBean " + name);
  -            try {
  -                mbServer.registerMBean(gbean, name);
  -            } catch (JMRuntimeException e) {
  -                Throwable cause = e.getCause();
  -                if (cause instanceof Exception) {
  -                    throw (Exception) cause;
  -                } else if (cause instanceof Error) {
  -                    throw (Error) cause;
  +            // create and initialize GBeans
  +            gbeans = loadGBeans(gbeanState, classLoader);
  +
  +            // register all the GBeans
  +            MBeanServer mbServer = context.getServer();
  +            for (Iterator i = gbeans.entrySet().iterator(); i.hasNext();) {
  +                Map.Entry entry = (Map.Entry) i.next();
  +                ObjectName name = (ObjectName) entry.getKey();
  +                GBeanMBean gbean = (GBeanMBean) entry.getValue();
  +                log.trace("Registering GBean " + name);
  +                try {
  +                    mbServer.registerMBean(gbean, name);
  +                } catch (JMRuntimeException e) {
  +                    Throwable cause = e.getCause();
  +                    if (cause instanceof Exception) {
  +                        throw (Exception) cause;
  +                    } else if (cause instanceof Error) {
  +                        throw (Error) cause;
  +                    }
  +                    throw e;
                   }
  -                throw e;
  +                mbServer.invoke(Kernel.DEPENDENCY_SERVICE, "addDependency", new Object[]{name,
context.getObjectName()}, new String[]{ObjectName.class.getName(), ObjectName.class.getName()});
               }
  -            mbServer.invoke(Kernel.DEPENDENCY_SERVICE, "addDependency", new Object[]{name,
context.getObjectName()}, new String[]{ObjectName.class.getName(), ObjectName.class.getName()});
  +        } finally {
  +            Thread.currentThread().setContextClassLoader(oldCl);
           }
   
           log.info("Started configuration " + id);
  
  
  

Mime
View raw message