[jboss-dev-forums] [JBoss Microcontainer Development POJO Server] - Re: AS weld-int
alesj
do-not-reply at jboss.com
Mon Oct 26 09:00:19 EDT 2009
"kabir.khan at jboss.com" wrote :
| a) I need the BeanManager. BootstrapBean is initialised, so I can call BB.getWeldManager(). I do however need access to the bean manager to use, which I can get from the (Flat)Deployment attachment. I do see some issues down the line if a deployment has several bean managers, but want to get something up and running before digging into that.
|
This is the name under which BootstrapBean is registered in MC:
* String bootstrapName = DeployersUtils.getBootstrapBeanName(unit);
"kabir.khan at jboss.com" wrote :
| b) How do I make sure that WeldKernelControllerContexts are deployed instead of KernelControllerContexts? Replace BeanMetaDataDeployer with something else?
|
Yes.
I would rather change BMDDeployer than go down that ugly path you describe in your 2nd post. :-)
e.g.
Have a list of ControllerContext creators in BMDDeployer,
short circuit-ing on 1st return context instance; by default creating KCC.
"kabir.khan at jboss.com" wrote :
| This is done by BootstrapBean.boot() which is called as part of BootstrapBean's start phase. I need to make sure this happens after 2), which looks like it is the case in BootDeployerTestCase, due to some mysterious dependency on EjbContainer#1 (line 79)
|
This is the magic that does it:
| // call dynamic dependency creator for EJBs
| ParameterMetaDataBuilder install = bootstrap.addInstallWithParameters("createDepenencies", "DynamicDependencyCreator", null, ControllerState.CONFIGURED);
| install.addParameterMetaData(Object.class.getName(), bootstrapName);
| install.addParameterMetaData(Iterable.class.getName(), bootstrap.createInject(ejbServicesValue.getUnderlyingValue(), "ejbContainerNames"));
| install.addParameterMetaData(String.class.getName(), "Start");
| install.addParameterMetaData(String.class.getName(), "Start");
|
| /**
| * Create dependencies to target bean.
| *
| * @param targetName the target bean name
| * @param dependencies dependencies names
| * @param whenRequiredState when required state
| * @param dependentState dependencies dependent state
| */
| public void createDepenencies(Object targetName, Iterable<String> dependencies, String whenRequiredState, String dependentState)
| {
| if (targetName == null)
| throw new IllegalArgumentException("Null target name");
| if (dependencies == null)
| throw new IllegalArgumentException("Null dependecies");
|
| ControllerContext targetControllerContext = controller.getContext(targetName, null);
| if (targetControllerContext == null)
| throw new IllegalArgumentException("No such target bean installed: " + targetName);
|
| Throwable error = targetControllerContext.getError();
| if (error != null)
| throw new IllegalArgumentException("Target bean " + targetName + " is in Error state: " + error);
|
| ControllerState whenRequired;
| if (whenRequiredState == null)
| whenRequired = ControllerState.INSTALLED;
| else
| whenRequired = new ControllerState(whenRequiredState);
|
| ControllerState currentTargetState = targetControllerContext.getState();
| if (controller.getStates().isBeforeState(currentTargetState, whenRequired) == false)
| throw new IllegalArgumentException("Target bean " + targetName + " is already past " + whenRequiredState + " state: " + targetControllerContext);
|
| ControllerState dependent = null;
| if (dependentState != null)
| dependent = new ControllerState(dependentState);
|
| DependencyInfo di = targetControllerContext.getDependencyInfo();
| for (Object dependency : dependencies)
| {
| DependencyItem item = new AbstractDependencyItem(targetName, dependency, whenRequired, dependent);
| di.addIDependOn(item);
| }
| }
|
;-)
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4262171#4262171
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4262171
More information about the jboss-dev-forums
mailing list