-
1. Re: Locating the current DeploymentUnit
dmlloyd May 28, 2009 7:01 PM (in response to dmlloyd)One challenge will be if and when one deployment unit calls into another. Maybe a reflection-based stack introspection would be better, but I don't believe there's a portable API to accomplish that.
-
2. Re: Locating the current DeploymentUnit
dmlloyd Jun 1, 2009 11:10 AM (in response to dmlloyd)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?
-
3. Re: Locating the current DeploymentUnit
jaikiran Jun 3, 2009 5:23 AM (in response to dmlloyd)"david.lloyd@jboss.com" wrote:
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? -
4. Re: Locating the current DeploymentUnit
alesj Jun 8, 2009 4:05 AM (in response to dmlloyd)"david.lloyd@jboss.com" wrote:
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. :-) -
5. Re: Locating the current DeploymentUnit
bob.mcwhirter Jun 8, 2009 9:22 AM (in response to dmlloyd)fwiw, TorqueBox (jboss-rails) is one of those that has a DU that creates another DU.
Something stack-ish would be appropriate in my use-case, perhaps. -
6. Re: Locating the current DeploymentUnit
adrian.brock Jun 8, 2009 9:26 AM (in response to dmlloyd)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
ClassLoader->DeploymentUnit
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.