2 Replies Latest reply on Dec 5, 2006 12:22 PM by Edith Hofer

    Custom ClassLoader

    dec dec Newbie

      I want to write a custom ClassLoader to load the whole application (.war).
      My configuration is:

      jboss-services.xml
      ---------------------------------------




      jboss-web.xml
      --------------------------------------
      <?xml version="1.0"?>
      <jboss-web>
      <class-loading>
      <loader-repository>
      com.july:loader=jboss-trial.war
      </loader-repository>
      </class-loading>
      </jboss-web>


      TrialClassLoader.java
      -----------------------------------------
      /*
      * Created on Oct 23, 2006
      *
      */
      package com.july.jboss;

      import java.net.URL;

      import javax.management.MalformedObjectNameException;
      import javax.management.ObjectName;

      import org.jboss.mx.loading.ClassLoaderUtils;
      import org.jboss.mx.loading.UnifiedClassLoader3;

      /**
      * @author Administrator
      *
      */
      public class TrialClassLoader extends UnifiedClassLoader3 implements ServiceMBean {

      public TrialClassLoader() {
      this(null);
      System.out.println("TrialClassLoader.TrialClassLoader");
      }

      public TrialClassLoader(URL url) {
      super(url);
      System.out.println("TrialClassLoader.TrialClassLoader(" + url + ")");
      }

      /* (non-Javadoc)
      * @see org.jboss.mx.loading.RepositoryClassLoader#getObjectName()
      */
      public ObjectName getObjectName() throws MalformedObjectNameException {
      System.out.println("TrialClassLoader.getObjectName");
      return null;
      }

      /* (non-Javadoc)
      * @see org.jboss.system.ServiceMBean#getName()
      */
      public String getName() {
      System.out.println("TrialClassLoader.getName");
      return null;
      }

      /* (non-Javadoc)
      * @see org.jboss.system.ServiceMBean#getState()
      */
      public int getState() {
      System.out.println("TrialClassLoader.getState");
      return 0;
      }

      /* (non-Javadoc)
      * @see org.jboss.system.ServiceMBean#getStateString()
      */
      public String getStateString() {
      System.out.println("TrialClassLoader.getStateString");
      return null;
      }

      /* (non-Javadoc)
      * @see org.jboss.system.ServiceMBean#jbossInternalLifecycle(java.lang.String)
      */
      public void jbossInternalLifecycle(String arg0) throws Exception {
      System.out.println("TrialClassLoader.jbossInternalLifecycle(" + arg0 + ")");
      }

      /* (non-Javadoc)
      * @see org.jboss.system.Service#create()
      */
      public void create() throws Exception {
      System.out.println("TrialClassLoader.create");
      }

      /* (non-Javadoc)
      * @see org.jboss.system.Service#start()
      */
      public void start() throws Exception {
      System.out.println("TrialClassLoader.start");
      }

      /* (non-Javadoc)
      * @see org.jboss.system.Service#stop()
      */
      public void stop() {
      System.out.println("TrialClassLoader.stop");
      }

      /* (non-Javadoc)
      * @see org.jboss.system.Service#destroy()
      */
      public void destroy() {
      System.out.println("TrialClassLoader.destroy");
      }

      /* (non-Javadoc)
      * @see java.lang.ClassLoader#findClass(java.lang.String)
      */
      protected Class findClass(String arg0) throws ClassNotFoundException {
      System.out.println("TrialClassLoader.findClass(" + arg0 + ")");
      return super.findClass(arg0);
      }
      }


      -----------------------------------------------------
      After server startup, com.july:loader=jboss-trial.war appears in jmx-console, but this classloader is never used.

      Anyone help what is wrong?