Just an update on this. Started off intending to ask a question, but I figured it out, so
this is just an FYI to anyone interested.
"scott.stark(a)jboss.org" wrote : A first pass implementation could simply have a
mapping from the metadata class/property that is being bound and a deployer would update
replace the component metadata before the component deployer runs.
I've been experimenting with how such a deployer would work with a basic pojo
deployment (e.g. a -beans.xml). Basically, get any BeanMetaData attachment and if there
is a binding for it, wrap it in a new BeanMetaData that overrides the interfaces/ports:
| public class ServiceBindingDeployer extends AbstractDeployer
| {
| public ServiceBindingDeployer()
| {
| setStage(DeploymentStages.POST_PARSE);
| setInput(BeanMetaData.class);
| setOutput(BeanMetaData.class);
| setComponentsOnly(true);
| }
|
| public void deploy(DeploymentUnit unit) throws DeploymentException
| {
| BeanMetaData metadata = unit.getAttachment(BeanMetaData.class);
| if (metadata != null)
| {
| BeanMetaData alteredMetaData = applyBindings(unit, metadata);
| unit.addAttachment(BeanMetaData.class, alteredMetaData);
| }
| }
|
| private BeanMetaData applyBindings(DeploymentUnit unit, BeanMetaData metadata)
| {
| // TODO implement me -- if a binding exists, wrap the passed in metadata
| // with an alternate that changes the values for interfaces/ports
|
| return metadata;
| }
| }
|
This is targeted at DeploymentStages.POST_PARSE, as what it's doing seems to fit the
javadoc for that stage:
| /** The post parse stage - where metadata can be fixed up */
| DeploymentStage POST_PARSE = new DeploymentStage("PostParse", PARSE);
|
Problem is, it doesn't work because the KernelDeploymentDeployer is what creates the
component DeploymentUnit(s) and their BeanMetaData. And that deployer runs at
DeploymentStages.REAL, after the above ServiceBindingDeployer.
I can get it to work by changing ServiceBindingDeployer to DeploymentStages.REAL. A
concern is making sure it gets invoked before BeanMetaDataDeployer for any given
deployment unit. But whether I deploy it after BeanMetaDataDeployer, it still gets
invoked first, which is good. :) And if I deploy it before KernelDeploymentDeployer, it
also works fine. :-) I figure this is because the output (BeanMetaData) from
KernelDeploymentDeployer is the input to ServiceBindingDeployer. ServiceBindingDeployer
outputs the same type that it inputs, and BeanMetaDataDeployer takes that as an input and
has no output, so Deployers must be recognizing that ServiceBindingDeployer needs to go in
the middle. Nice!
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4167472#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...