This content has been marked as final.
Show 2 replies
-
1. Re: Deployment unit aware annotations
alesj Feb 17, 2009 11:38 AM (in response to wolfc)"wolfc" wrote:
For the moment it would be great to actually know the deployment unit which is causing a MC bean install.
This info is under Deployment(Unit|Context)::getControllerContextNames. -
2. Re: Deployment unit aware annotations
wolfc Feb 18, 2009 3:11 AM (in response to wolfc)That doesn't work because the bean itself isn't there yet. So right now I examine the BeanMetaData.
(iterating over mainDeployer.getTopLevel())private DeploymentUnit findBean(DeploymentUnit deploymentUnit, String contextName) { if(deploymentUnit == null) return null; /* Set<Object> controllerContextNames = deploymentUnit.getControllerContextNames(); if(controllerContextNames != null) { for(Object name : controllerContextNames) { if(name.equals(contextName)) return deploymentUnit; } } */ BeanMetaData bmd = deploymentUnit.getAttachment(BeanMetaData.class); if(bmd != null && bmd.getName().equals(contextName)) return deploymentUnit; DeploymentUnit result; for(DeploymentUnit component : deploymentUnit.getComponents()) { result = findBean(component, contextName); if(result != null) return deploymentUnit; } for(DeploymentUnit child : deploymentUnit.getChildren()) { result = findBean(child, contextName); if(result != null) return result; } return null; }