[jboss-user] [JBoss Microcontainer] - Re: Custom ClassLoader

Irfan Basha do-not-reply at jboss.com
Tue Mar 26 09:28:40 EDT 2013


Irfan Basha [https://community.jboss.org/people/irbash] created the discussion

"Re: Custom ClassLoader"

To view the discussion, visit: https://community.jboss.org/message/804847#804847

--------------------------------------------------------------
Solution: 

1. Add jboss-beans.xml to WEB-INF: 
+<deployment xmlns="urn:jboss:bean-deployer:2.0">+
+        +  +<classloader name="custom-classloader" xmlns="urn:jboss:classloader:1.0"+
+                    export-all="NON_EMPTY" import-all="true" />+
+          <bean name="CustomCL" class="com.beans.CustomClassLoader">+
+                    <constructor>+
+                              <parameter>+
+                                        <inject bean="custom-classloader:0.0.0" />+
+                              </parameter>+
+                    </constructor>+ 
+          </bean>+
+          <bean name="CB1" class="com.Sample">+
+          <classloader>+
+                    <inject bean="CustomCL" />+
+          </classloader>+
+</bean>+
+</deployment>+
+
+

2. Create a CustomClassLoader (com.beans.CustomClassLoader):
public class CustomClassLoader extends ClassLoader
{ 
   public CustomClassLoader(ClassLoader parent)
   {
      super(parent);
   }
   public Class<?> loadClass(String name) throws ClassNotFoundException
   {     
          //This simply calls super's loadClass (if run from jboss, it calls BaseClassLoader
         return super.loadClass(name);     
   }
   
}

Run JBoss, keep a breakpoint in CustomClassLoader.loadClass method. when class com.Sample has to be loaded the breakpoint will be hit. 

Regards,
Irfan
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/804847#804847]

Start a new discussion in JBoss Microcontainer at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2114]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130326/e08afc0b/attachment.html 


More information about the jboss-user mailing list