-
1. Re: Classloading docs?
alesj Nov 11, 2008 6:13 AM (in response to emmartins)"emmartins" wrote:
UnifiedClassLoader ucl = (UnifiedClassLoader) Thread
.currentThread().getContextClassLoader();
UnifiedLoaderRepository3 lr = (UnifiedLoaderRepository3) ucl
.getLoaderRepository();
RepositoryClassLoader cl = lr.newClassLoader(
getTempClassDeploymentDir().toURL(), new File(
getUnitJarFile().getName()).toURL(), true);
Due to such hacks, we made new CL more bullet proof. ;-)"emmartins" wrote:
Now the context class loader is a BaseClassLoader and looking at that object through debug I don't find something similar as the "old" repository :-)
Repository == Domain.
ClassLoaderSystem --> ClassLoaderDomain --> ClassLoader
Check AbstractLevelClassLoaderSystemDeployer on how this all fits together. -
2. Re: Classloading docs?
emmartins Nov 11, 2008 10:42 AM (in response to emmartins)Ok, so I understand the ClassLoaderSystem, which I can simply get using .getInstance(), then I can use .registerClassLoaderPolicy(String domainName, ClassLoaderPolicy policy) to get a new domain and related class loader, my question now is how do I create the policy that "adds" to the classpath the directory where we generated classes. Any hint? :-)
-
3. Re: Classloading docs?
alesj Nov 11, 2008 10:56 AM (in response to emmartins)What exactly are you trying to do/hack? :-)
Perhaps this?
- http://anonsvn.jboss.org/repos/jbossas/projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/InMemoryClassesDeployer.java
This is how AOP adds aspectized/modified classes to classpath.
This is how I add Seam+JBossAS custom classes:
- http://anonsvn.jboss.org/repos/jbossas/projects/jboss-seam-int/trunk/microcontainer/src/main/java/org/jboss/seam/integration/microcontainer/deployers/SeamUrlIntegrationDeployer.java
And this is how Stan does it:
- http://jsfunit.blogspot.com/2008/10/jsfunit-easy-way.html
Hence I very much doubt you need to do a lot more. ;-) -
4. Re: Classloading docs?
slaboure Nov 11, 2008 10:58 AM (in response to emmartins)guys, don't we have better doc for people wanting to try something like this?
-
5. Re: Classloading docs?
alesj Nov 11, 2008 11:04 AM (in response to emmartins)"sacha.labourey@jboss.com" wrote:
guys, don't we have better doc for people wanting to try something like this?
You do. It's probably sitting 10m away from you. ;-)
Poke him about this
- https://jira.jboss.org/jira/browse/JBCL-10
many people have tried, none have succeedded. ;-)
And we're still looking for a couple of them who dared to ask ... :-) -
6. Re: Classloading docs?
emmartins Nov 11, 2008 11:20 AM (in response to emmartins)"alesj" wrote:
What exactly are you trying to do/hack? :-)
Putting the whole process in a simple manner, we monitor deployment of specific jars (JAIN SLEE deployable units), extract it to a directory in the server's temp one, and load its content (some is abstract so we need to do concrete implementations with javassist) to a specific class loader. This class loader now (Mobicents JAIN SLEE 1.2.x and JBoss AS4) is connected to the shared repository (the code to create it is in the first post) but in next version, compliant with JAIN SLEE 1.1 specs, we will need to support some kind of class loader composition among deployable units.
So... right now what we are exactly needing with this stuff is to create a class loader pointing to the URL where the deployable unit content was unpackaged and another class loader pointing to the URL where the concrete impl of abstract JAIN SLEE components was generated.
I will look at this links you shared, thanks :-) -
7. Re: Classloading docs?
emmartins Nov 12, 2008 5:21 AM (in response to emmartins)Found this class VFSClassLoaderPolicy, looking at code it seems that if used in ClassLoadersystem it will create the class loader pointing to the VFS roots defined, what we need now, did I miss something?
-
8. Re: Classloading docs?
emmartins Nov 12, 2008 7:50 AM (in response to emmartins)almost there:
VirtualFile tempClassDeploymentDirVF = VFS.getRoot(getTempClassDeploymentDir().toURL()); VFSClassLoaderPolicy classLoaderPolicy = VFSClassLoaderPolicy.createVFSClassLoaderPolicy(tempClassDeploymentDirVF); ClassLoader classLoader = classLoaderSystem.registerClassLoaderPolicy(classLoaderPolicy);
This registers the policy pointing to the URL in the default domain, that's fine, the issue now is that once I change to this class loader it doesn't see other classes in the class loader domain. Perhaps any config detail of the policy is missing? -
9. Re: Classloading docs?
alesj Nov 12, 2008 8:00 AM (in response to emmartins)Perhaps setting parent domain while registering it into system would help?
-
10. Re: Classloading docs?
adrian.brock Nov 12, 2008 8:29 AM (in response to emmartins)"emmartins" wrote:
almost there:VirtualFile tempClassDeploymentDirVF = VFS.getRoot(getTempClassDeploymentDir().toURL()); VFSClassLoaderPolicy classLoaderPolicy = VFSClassLoaderPolicy.createVFSClassLoaderPolicy(tempClassDeploymentDirVF); ClassLoader classLoader = classLoaderSystem.registerClassLoaderPolicy(classLoaderPolicy);
This registers the policy pointing to the URL in the default domain, that's fine, the issue now is that once I change to this class loader it doesn't see other classes in the class loader domain. Perhaps any config detail of the policy is missing?
classLoaderPolicy.setImportAll(true); // if you want to see other classes in the domain
classLoaderPolicy.setExportAll(ExportAll.NON_EMPTY)); // if you want others to see your classes -
11. Re: Classloading docs?
adrian.brock Nov 12, 2008 8:37 AM (in response to emmartins)"sacha.labourey@jboss.com" wrote:
guys, don't we have better doc for people wanting to try something like this?
What makes you think I would document people creating their own classloaders?
(I will but this stuff will be in the reference guide rather than the user guide).
JavaEE says its illegal for an application to create a classloader.
The approach described won't even work with OSGi style classloading.
The method works because currently things are using the "big ball of mud"
classloading policies.
The correct way is to modify the classpath of a deployment using
one of the methods Ales showed.
Which is actually deployer docs rather than classloader docs. ;-) -
12. Re: Classloading docs?
emmartins Nov 12, 2008 9:11 AM (in response to emmartins)"adrian@jboss.org" wrote:
"sacha.labourey@jboss.com" wrote:
guys, don't we have better doc for people wanting to try something like this?
What makes you think I would document people creating their own classloaders?
(I will but this stuff will be in the reference guide rather than the user guide).
JavaEE says its illegal for an application to create a classloader.
The approach described won't even work with OSGi style classloading.
The method works because currently things are using the "big ball of mud"
classloading policies.
The correct way is to modify the classpath of a deployment using
one of the methods Ales showed.
Which is actually deployer docs rather than classloader docs. ;-)
Thanks for you help Adrian. Regarding the "correct way", we receive the deployable unit jars via JMX, then unpack and process it, do you mean we should go for a MC deployer for it, and also for classes generated? -
13. Re: Classloading docs?
emmartins Nov 12, 2008 9:28 AM (in response to emmartins)"adrian@jboss.org" wrote:
classLoaderPolicy.setImportAll(true); // if you want to see other classes in the domain
classLoaderPolicy.setExportAll(ExportAll.NON_EMPTY)); // if you want others to see your classes
It worked, thanks :-)