[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: How to reliably determine if BeanMetaData contains depen
kabir.khan@jboss.com
do-not-reply at jboss.com
Fri Feb 6 12:50:58 EST 2009
With the following hacked KCC initialVisit() works here. I have only showed methods that I was forced to return something from to stop NPEs. The dependencies are picked out correctly now, and the failing tests pass, but it is horrible. I don't think I should need to create KCC's when reading the metadata?
| private boolean hasInjectedBeans(BeanMetaData beanMetaData)
| {
| DependencyBeanMetaDataVisitor visitor = new DependencyBeanMetaDataVisitor(beanMetaData);
|
| beanMetaData.initialVisit(visitor);
| return visitor.getHasDependencies();
| }
|
| private static class DependencyBeanMetaDataVisitor extends AbstractMetaDataVisitor
| {
| private boolean hasDependencies;
|
| protected DependencyBeanMetaDataVisitor(BeanMetaData bmd)
| {
| super(bmd, new DependencyMetaDataKernelControllerContext(bmd));
| }
|
| public boolean getHasDependencies()
| {
| return hasDependencies;
| }
|
| public void addDependency(DependencyItem dependency)
| {
| if (!((String)dependency.getIDependOn()).startsWith("jboss.kernel:service="))
| {
| //TODO revisit
| //Ignore the kernel dependencies
| hasDependencies = true;
| }
| }
| }
|
| private static class DependencyMetaDataKernelControllerContext extends JBossObject implements KernelControllerContext
| {
| private static final Kernel kernel = new Kernel();
| private BeanMetaData beanMetaData;
|
| public DependencyMetaDataKernelControllerContext(BeanMetaData beanMetaData)
| {
| this.beanMetaData = beanMetaData;
| }
|
| public BeanMetaData getBeanMetaData()
| {
| return beanMetaData;
| }
|
| public Kernel getKernel()
| {
| return kernel;
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4207809#4207809
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4207809
More information about the jboss-dev-forums
mailing list