[jboss-user] [JBoss Microcontainer Development] New message: "Using MetaDataRetrievalFactory is missing addition"
Ales Justin
do-not-reply at jboss.com
Thu Feb 4 09:55:06 EST 2010
User development,
A new message was posted in the thread "Using MetaDataRetrievalFactory is missing addition":
http://community.jboss.org/message/524180#524180
Author : Ales Justin
Profile : http://community.jboss.org/people/alesj
Message:
--------------------------------------------------------------
When we use an explicit MetaDataRetrievalFactory to create MDRetrieval for scope level,
we never actually add the newly created retrieval to repository.
This results in retrieval override, since the factory is invoked for every lookup.
Just follow PreInstallAction and its MD::addMetaData invocation.
AbstractKernelScopeInfo
public void addMetaData(MutableMetaDataRepository repository, ControllerContext context)
{
this.repository = repository;
ScopeKey scope = getMutableScope();
MetaDataRetrieval retrieval = repository.getMetaDataRetrieval(scope); // HERE -- factory creates it
MutableMetaDataLoader mutable;
if (retrieval == null)
{
mutable = initMutableMetaDataRetrieval(repository, context, scope);
repository.addMetaDataRetrieval(mutable);
addedScopes.add(scope);
}
else
{
mutable = getMutableMetaDataLoader(retrieval);
}
if (mutable == null)
{
log.warn("MetaData context is not mutable: " + retrieval + " for " + context.toShortString());
return;
}
updateMetaData(repository, context, mutable, true);
}
BasicMetaDataRepository
public MetaDataRetrieval getMetaDataRetrieval(ScopeKey key)
{
MetaDataRetrieval result = retrievals.get(key);
if (result != null)
return result;
// Is this a single level?
Collection<Scope> scopes = key.getScopes();
if (scopes.size() != 1)
return null;
// See if we have a factory
Scope scope = scopes.iterator().next();
ScopeLevel scopeLevel = scope.getScopeLevel();
MetaDataRetrievalFactory factory = getMetaDataRetrievalFactory(scopeLevel);
if (factory == null)
return null;
// We have a factory, use it
return factory.getMetaDataRetrieval(scope); // HERE -- created, but never added
}
I currently fixed it by adding the newly created retrieval in the MDRFactory itself.
But what should be the right place to do it? Or how?
Since AbstractKernelScopeInfo only cares about getting the MDRetrieval.
Perhaps a getOrCreateAndAdd method on MutableMetaDataRepository?
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/524180#524180
More information about the jboss-user
mailing list