This will be necessary to make per-deployment logging setups work right.
From what i remember, in AS-4.x this was done with a TCL log4j filter (not sure how credible that used to work). How is this being done in AS-5?
OK how about this. What is the mechanism to find the DeploymentUnit that a Class belongs to? Does jboss-cl give us something which does this?
You can do this:
(1) Get CL for the class
(2) Get the Module for CL
(3) Search all DUs for matching Module
--> the one that has that Module as an attachment is your DU
There might be a faster way, but I need to check the code,
as this was off the top of my head. :-)
You can't use a thread local because
1) the deployers/micrcontainer can cause other deployments/contexts to be processed
when dependencies are satisfied. e.g. deploying the transaction manager will cause
many other other services to start.
2) Outside the deployment framework callbacks there will be no "current deployment"
Also Classes don't necessarily belong to any deployment unit,
e.g. the bootstrap classes
I'd suggest the easiest way to implement this feature would be write a new deployer
that runs "post classlaoder". This would mainatain a map of
for any DeploymentUnit (including subdeployments like wars) that have a Module
attachment and hence their own classloader.
You can then use this map in whatever you want to do.