[jboss-dev-forums] [JBoss Microcontainer Development] - Re: Testing Deployers with new Reflect + ClassPool
flavia.rainone@jboss.com
do-not-reply at jboss.com
Fri Nov 6 06:34:43 EST 2009
"flavia.rainone at jboss.com" wrote : I think that we should look into the class pool tests and see what they are missing before we proceed to deployers tests. I'll start adding a test to reproduce the failure I caught yesterday.
This is related to JBREFLECT-65.
As a matter of fact, I found out that there is already a test that should catch this failure in the classpool tests. The tests Kabir wrote are very complete :)
The difference between the classpool test environment and the deployers one is that this one is lacking the calls to DomainRegistry.initMapsForLoader(loader, module, parentUnitLoader) method. Fixing that completely replaces the ugly hack, because parentUnitLoader is the loader we want when defining the parent of a class pool domain.
In JBoss AOP, the initMapsForLoader method is invoked by the AOPClassLoaderInitializer class. This class is indirectly invoked by the AOPDeployer and uses the DeploymentUnit to get to the arguments needed for initMapsForLoader. I've created a temporary deployer to test this on ClassPoolTestCase:
public void deploy(VFSDeploymentUnit unit) throws DeploymentException
| {
| if (unit.isTopLevel() || unit.getParent().getClassLoader() != unit.getClassLoader())
| {
| //Only bother doing all this if we are a different loader from the parent unit
| Module module = getModuleRecursively(unit);
| if (module == null)
| {
| throw new IllegalStateException("No " + Module.class.getName() +
| " attachment could be found in the following deployment unit or its parents: " + unit);
| }
| ClassLoader parentUnitLoader = unit.isTopLevel() ? null : unit.getParent().getClassLoader();
| domainRegistry.initMapsForLoader(unit.getClassLoader(), module, parentUnitLoader);
| }
| }
It works :).
However, I'm afraid this is not the correct way of doing this. We are not deploying anything at all, only registering the classloader structure created for the deployed unit. I thought on using a ModuleRegistry, but I can't find out how to get to the parameters required for initMapsForLoader from the module. I'm clueless on what is the correct approach for calling initMapsForLoader method. Any ideas?
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4264309#4264309
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4264309
More information about the jboss-dev-forums
mailing list