public ScopeInfo getScopeInfo() { String className = null; Object target = getTarget(); if (target != null) className = target.getClass().getName(); return new AbstractScopeInfo(getName(), className); }
public MetaData getMetaData() { if (repository == null) return null; MetaData metaData = repository.getMetaData(getScope()); if (metaData == null && context != null) { initMetaDataRetrieval(repository, context); metaData = repository.getMetaData(getScope()); } return metaData; }
/** * Create a new AbstractScopeInfo. * * @param key the scope key * @param mutable the mutable scope key */ public AbstractScopeInfo(ScopeKey key, ScopeKey mutable) { setScope(key); setMutableScope(mutable); }
public MetaDataRetrieval initMetaDataRetrieval(MutableMetaDataRepository repository, ControllerContext context) { ScopeKey scopeKey = getScope(); List<MetaDataRetrieval> retrievals = new ArrayList<MetaDataRetrieval>(); for (Scope scope : scopeKey.getScopes()) { ScopeKey thisScope = new ScopeKey(scope); MetaDataRetrieval retrieval = repository.getMetaDataRetrieval(thisScope); if (retrieval == null) { retrieval = initMetaDataRetrieval(repository, context, scope); if (retrieval == null) { retrieval = initMutableMetaDataRetrieval(repository, context, thisScope); repository.addMetaDataRetrieval(retrieval); addedScopes.add(thisScope); } } retrievals.add(0, retrieval); } MetaDataRetrieval metaDataRetrieval = createMetaDataRetrieval(context, retrievals); repository.addMetaDataRetrieval(metaDataRetrieval); addedScopes.add(metaDataRetrieval.getScope()); return metaDataRetrieval; }
public void addMetaData(MutableMetaDataRepository repository, ControllerContext context) { this.repository = repository; // only keep ref on the owning context if (context != null && context.getScopeInfo() == this) this.context = context; 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); }
public void removeMetaData(MutableMetaDataRepository repository, ControllerContext context) { ScopeKey mutableScope = getMutableScope(); MetaDataRetrieval retrieval = repository.getMetaDataRetrieval(mutableScope); if (retrieval != null) { MutableMetaDataLoader mutable = getMutableMetaDataLoader(retrieval); if (mutable != null) updateMetaData(repository, context, mutable, false); } for (ScopeKey scope : addedScopes) { try { repository.removeMetaDataRetrieval(scope); } catch (Exception e) { log.trace("Ignored", e); } } addedScopes.clear(); if (context != null && context.getScopeInfo() == this) this.context = null; this.repository = null; }
ScopeKey key = super.getScope(); Scope scope = key.getScope(CommonLevels.CLASS); if (scope == null)
@Override protected MetaDataRetrieval createMetaDataRetrieval(ControllerContext context, List<MetaDataRetrieval> retrievals) { Controller controller = context.getController(); if (controller instanceof KernelController) { KernelController kernelController = (KernelController) controller; MetaDataRetrieval result = kernelController.getKernel().getMetaDataRepository().createMetaDataRetrieval(context, retrievals); if (result != null) return result; } return super.createMetaDataRetrieval(context, retrievals); } }
/** * Initialise the scope info */ protected void initScopeInfo() { String className = null; Object target = getTarget(); if (target != null) className = target.getClass().getName(); setScopeInfo(new AbstractScopeInfo(getName(), className)); }
/** * Create a new AbstractScopeInfo. * * @param name the name * @param className the class name */ public AbstractScopeInfo(Object name, String className) { if (name == null) throw new IllegalArgumentException("Null scope"); ScopeKey scopeKey = ScopeKey.DEFAULT_SCOPE.clone(); scopeKey.addScope(CommonLevels.INSTANCE, name.toString()); if (className != null) scopeKey.addScope(CommonLevels.CLASS, className); setScope(scopeKey); setMutableScope(new ScopeKey(CommonLevels.INSTANCE, name.toString())); }