[jboss-dev-forums] [JBoss Microcontainer Development] - Re: Supporting qualifiers in MC
kabir.khan@jboss.com
do-not-reply at jboss.com
Mon Nov 23 09:54:50 EST 2009
The problem is that in PreInstallAction, KernelControllerContext.setBeanInfo() adds the bean info and also describeVisits the metadata, while KernelMetaDataRepository.addMetaData() creates the MDR entry and updates the annotations. So with the way it is there is no MDR at the time we are in describeVisit.
| protected void installActionInternal(KernelControllerContext context) throws Throwable
| {
| KernelController controller = (KernelController)context.getController();
| Kernel kernel = controller.getKernel();
| KernelConfigurator configurator = kernel.getConfigurator();
|
| BeanMetaData metaData = context.getBeanMetaData();
| if (metaData.getBean() != null)
| {
| BeanInfo info = configurator.getBeanInfo(metaData);
| context.setBeanInfo(info);
| KernelMetaDataRepository repository = controller.getKernel().getMetaDataRepository();
| ClassLoader oldCL = SecurityActions.setContextClassLoader(context);
| try
| {
| repository.addMetaData(context); //1
| }
| finally
| {
| SecurityActions.resetContextClassLoader(oldCL);
| }
| try
| {
| applyScoping(context);
| }
| catch (Throwable t)
| {
| removeMetaData(context);
| throw t;
| }
| }
| }
|
If I call KCC.setBeanInfo() after KMDR.addMetaData() some of the exisiting tests like ClassAnnotationTestCase break. Now, the problem is that the internal calls to update the annotations return early since there is no bean info. I have worked around this with the following change locally:
| protected void installActionInternal(KernelControllerContext context) throws Throwable
| {
| KernelController controller = (KernelController)context.getController();
| Kernel kernel = controller.getKernel();
| KernelConfigurator configurator = kernel.getConfigurator();
|
| BeanMetaData metaData = context.getBeanMetaData();
| if (metaData.getBean() != null)
| {
| BeanInfo info = configurator.getBeanInfo(metaData);
| context.setBeanInfo(info);
| KernelMetaDataRepository repository = controller.getKernel().getMetaDataRepository();
| ClassLoader oldCL = SecurityActions.setContextClassLoader(context);
| try
| {
| repository.addMetaData(context);
| }
| finally
| {
| SecurityActions.resetContextClassLoader(oldCL);
| }
| try
| {
| applyScoping(context);
| }
| catch (Throwable t)
| {
| removeMetaData(context);
| throw t;
| }
| context.processMetaData();
| }
| }
|
KCC.setBeanInfo() now does not describeVisit() the metadata, instead an explicit call is needed to KCC.processMetaData()
| $svn diff kernel/src/main/java/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java
| Index: kernel/src/main/java/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java
| ===================================================================
| --- kernel/src/main/java/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java (revision 96585)
| +++ kernel/src/main/java/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java (working copy)
| @@ -177,10 +177,15 @@
| public void setBeanInfo(BeanInfo info)
| {
| this.info = info;
| - infoprocessMetaData();
| flushJBossObjectCache();
| }
|
| + public void processMetaData()
| + {
| + infoprocessMetaData();
| + flushJBossObjectCache();
| + }
| +
| public BeanMetaData getBeanMetaData()
| {
| return metaData;
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4267059#4267059
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4267059
More information about the jboss-dev-forums
mailing list