User: user57  
  Date: 02/02/26 21:51:25

  Modified:    src/main/org/jboss/system/server ServerImpl.java
                        ServerImplMBean.java ServerLoader.java
  Log:
   o ServerImpl/ServerLoader TCL fixes
   o Detatched ServerImplMBean from Server (as not all methods are ment for
     mgmnt).
  
  Revision  Changes    Path
  1.6       +36 -18    jboss-system/src/main/org/jboss/system/server/ServerImpl.java
  
  Index: ServerImpl.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss-system/src/main/org/jboss/system/server/ServerImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ServerImpl.java   27 Feb 2002 02:01:18 -0000      1.5
  +++ ServerImpl.java   27 Feb 2002 05:51:25 -0000      1.6
  @@ -10,7 +10,6 @@
   package org.jboss.system.server;
   
   import java.io.File;
  -import java.io.FileFilter;
   
   import java.net.URL;
   
  @@ -39,15 +38,20 @@
   import org.jboss.system.UnifiedClassLoader;
   import org.jboss.system.MBeanClassLoader;
   
  +import org.jboss.util.file.FileSuffixFilter;
  +
   /**
    * The main container component of a JBoss server instance.
    *
  + * <h3>Concurrency</h3>
  + * This class is <b>not</b> thread-safe.
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public class ServerImpl
  -   implements ServerImplMBean
  +   implements Server, ServerImplMBean
   {
      /** 
       * Class logger.  We masqurade as Server for looks, but we log our
  @@ -103,6 +107,20 @@
         if (config != null)
            throw new IllegalStateException("already initialized");
   
  +      ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
  +      
  +      try {
  +         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
  +         doInit(props);
  +      }
  +      finally {
  +         Thread.currentThread().setContextClassLoader(oldCL);
  +      }
  +   }
  +
  +   /** Actually does the init'ing... */
  +   private void doInit(final Properties props) throws Exception
  +   {
         // make sure our impl type is exposed
         log.debug("server type: " + getClass());
   
  @@ -112,7 +130,7 @@
         // Setup JBoss URL handlers
         URL.setURLStreamHandlerFactory(new 
org.jboss.net.protocol.URLStreamHandlerFactory());
   
  -      // this does not seem to work at the moment due to CL issues
  +      // this does not work at the moment due to java.net.URL not using TCL
         /*
         String handlerPkgs = System.getProperty("java.protocol.handler.pkgs");
         if (handlerPkgs != null) {
  @@ -179,8 +197,12 @@
         if (started)
            throw new IllegalStateException("already started");
   
  -      // Deal with those pesky JMX throwables
  +      ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
  +
         try {
  +         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
  +
  +         // Deal with those pesky JMX throwables
            try
            {
               doStart();
  @@ -216,6 +238,9 @@
            
            throw new org.jboss.util.UnexpectedThrowable(t);
         }
  +      finally {
  +         Thread.currentThread().setContextClassLoader(oldCL);
  +      }
      }
   
      /** Actually does the starting... */
  @@ -282,8 +307,8 @@
         // Initialize the MainDeployer
         server.invoke(controllerName,
                       "create",
  -                    new Object[] {mainDeployer},
  -                    new String[] {ObjectName.class.getName()});
  +                    new Object[] { mainDeployer },
  +                    new String[] { ObjectName.class.getName() });
         
         // SAR Deployer
         server.createMBean("org.jboss.deployment.SARDeployer", null, loaderName);
  @@ -297,13 +322,13 @@
         server.invoke(mainDeployer,
                       "deploy",
                       new Object[] { config.getConfigURL() + "jboss-service.xml" },
  -                    new String[] { "java.lang.String" });
  +                    new String[] { String.class.getName() });
   
         // Start the main deployer thread
         server.invoke(controllerName,
                       "start",
  -                    new Object[] {mainDeployer},
  -                    new String[] {ObjectName.class.getName()});
  +                    new Object[] { mainDeployer },
  +                    new String[] { ObjectName.class.getName() });
         
         // Calculate how long it took
         long lapsedTime = System.currentTimeMillis() - startDate.getTime();
  @@ -342,14 +367,7 @@
                  list.add(dir.toURL());
                  
                  // Add the contents of the directory too
  -               File[] jars = dir.listFiles(new FileFilter()
  -               {
  -                  public boolean accept(File file)
  -                  {
  -                     String name = file.getName().toLowerCase();
  -                     return name.endsWith(".jar") || name.endsWith(".zip");
  -                  }
  -               });
  +               File[] jars = dir.listFiles(new FileSuffixFilter(new String[] { 
".jar", ".zip" }, true));
                  
                  for (int j = 0; jars != null && j < jars.length; j++)
                  {
  
  
  
  1.2       +1 -2      
jboss-system/src/main/org/jboss/system/server/ServerImplMBean.java
  
  Index: ServerImplMBean.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss-system/src/main/org/jboss/system/server/ServerImplMBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServerImplMBean.java      24 Feb 2002 10:24:34 -0000      1.1
  +++ ServerImplMBean.java      27 Feb 2002 05:51:25 -0000      1.2
  @@ -19,10 +19,9 @@
    * The JMX MBean interface for the <tt>ServerImpl</tt> component.
    *      
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public interface ServerImplMBean
  -   extends Server
   {
      /** The default JMX object name for this MBean. */
      ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.system:type=Server");
  
  
  
  1.5       +16 -13    jboss-system/src/main/org/jboss/system/server/ServerLoader.java
  
  Index: ServerLoader.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss-system/src/main/org/jboss/system/server/ServerLoader.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ServerLoader.java 27 Feb 2002 04:46:35 -0000      1.4
  +++ ServerLoader.java 27 Feb 2002 05:51:25 -0000      1.5
  @@ -50,7 +50,7 @@
    *    server.shutdown();
    * </pre>
    *
  - * @version <tt>$Revision: 1.4 $</tt>
  + * @version <tt>$Revision: 1.5 $</tt>
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
    */
   public class ServerLoader
  @@ -207,11 +207,6 @@
      /**
       * Load a {@link Server} instance.  
       *
  -    * <p>
  -    * <b>NOTE</b>: This call will replace the
  -    * thread context classloader with the classloader used to load
  -    * the server class.
  -    *
       * @parent    The parent of any class loader created during boot.
       * @return    An uninitialized (and unstarted) Server instance.
       *
  @@ -219,14 +214,22 @@
       */
      public Server load(final ClassLoader parent) throws Exception
      {
  -      // get the boot lib list
  -      URL[] urls = getBootClasspath();
  -      URLClassLoader classLoader = new URLClassLoader(urls, parent);
  -      Thread.currentThread().setContextClassLoader(classLoader);
  +      Server server;
  +      ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
  +
  +      try {
  +         // get the boot lib list
  +         URL[] urls = getBootClasspath();
  +         URLClassLoader classLoader = new URLClassLoader(urls, parent);
  +         Thread.currentThread().setContextClassLoader(classLoader);
         
  -      // construct a new Server instance
  -      String typename = props.getProperty(ServerConfig.SERVER_TYPE, 
DEFAULT_SERVER_TYPE);
  -      Server server = createServer(typename, classLoader);
  +         // construct a new Server instance
  +         String typename = props.getProperty(ServerConfig.SERVER_TYPE, 
DEFAULT_SERVER_TYPE);
  +         server = createServer(typename, classLoader);
  +      }
  +      finally {
  +         Thread.currentThread().setContextClassLoader(oldCL);
  +      }
   
         // thats all folks, have fun
         return server;
  
  
  

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

Reply via email to