We add/remove the MetaData with mutable key:
| public void addMetaData(MutableMetaDataRepository repository, ControllerContext
context)
| {
| this.repository = repository;
| ScopeKey scope = getMutableScope();
| MetaDataRetrieval retrieval = repository.getMetaDataRetrieval(scope);
| 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);
| }
|
while we do a lookup with the scope key:
| public MetaData getMetaData()
| {
| if (repository == null)
| return null;
|
| return repository.getMetaData(getScope());
| }
|
In kernel module we go over KernelMetaDataRepository::getMetaData(ControllerContext),
which does similar + a bit more:
| public MetaData getMetaData(ControllerContext context)
| {
| MutableMetaDataRepository repository = getMetaDataRepository();
| ScopeKey scope = context.getScopeInfo().getScope();
| MetaData metaData = repository.getMetaData(scope);
| if (metaData == null)
| {
| initMetaDataRetrieval(context);
| metaData = repository.getMetaData(scope);
| if (metaData == null)
| throw new IllegalStateException("Error initialising metadata state:
" + scope);
| }
| return metaData;
| }
|
| // THE MISSING PIECE
| protected MetaDataRetrieval initMetaDataRetrieval(ControllerContext context)
| {
| MutableMetaDataRepository repository = getMetaDataRepository();
| ScopeInfo scopeInfo = context.getScopeInfo();
| return scopeInfo.initMetaDataRetrieval(repository, context);
| }
|
I guess it's the "missing piece" that makes ScopeInfo::getMetaData work for
Kernel - by luck. :-)
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4267323#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...