[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: New behaviour of AbstractMetaDataContext.isEmpty()

adrian@jboss.org do-not-reply at jboss.com
Thu Nov 15 13:25:07 EST 2007


"kabir.khan at jboss.com" wrote : 
  | The instanceMetaData.toString() method shows
  | 
  |   | org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge at 1286c00{[JVM=THIS, CLASS=org.jboss.test.microcontainer.matrix.AnnotatedChild, INSTANCE=AnnotatedChild, WORK=1209895]}
  |   | 
  | 

That's clearly wrong. The invocation of:

MetaData instanceMetaData = metaData.getScopeMetaData(CommonLevels.INSTANCE);
should be giving you back a MetaData object that only contains the
INSTANCE=AnnotatedChild.

The bug is fairly obvious.
The single scope metadata shouldn't have a parent! :-)

  |    public MetaData getScopeMetaData(ScopeLevel level)
  |    {
  |       if (level == null)
  |          throw new IllegalArgumentException("Null scope level");
  | 
  |       if (retrieval instanceof MetaDataContext)
  |       {
  |          MetaDataContext context = (MetaDataContext)retrieval;
  |          List<MetaDataRetrieval> matchingRetrievals = new ArrayList<MetaDataRetrieval>();
  |          List<MetaDataRetrieval> localRetrievals = context.getLocalRetrievals();
  |          for (MetaDataRetrieval localRetrieval : localRetrievals)
  |          {
  |             ScopeKey scopeKey = localRetrieval.getScope();
  | 
  |             if (scopeKey.getScopeLevel(level) != null)
  |                matchingRetrievals.add(localRetrieval);
  |          }
  |          if (matchingRetrievals.isEmpty() == false)
  | -            return new MetaDataRetrievalToMetaDataBridge(new AbstractMetaDataContext(context, matchingRetrievals));
  | +            return new MetaDataRetrievalToMetaDataBridge(new AbstractMetaDataContext(null, matchingRetrievals));
  |       }
  |       else if (retrieval.getScope().getScopeLevel(level) != null)
  |          return new MetaDataRetrievalToMetaDataBridge(new AbstractMetaDataContext(retrieval));
  |       return null;
  |    }
  | 

But on a related issue, I don't like the fact that this logic is in the bridge.
The bridge should be just delegating the request to the retrieval.
i.e. a plain retrieval will just match its scope level while a context
will have to filter its local retrievals. It's more OO.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4105165#4105165

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4105165



More information about the jboss-dev-forums mailing list