@SuppressWarnings("unchecked")
protected ScopeKey getInstallScopeKey(
KernelControllerContext context,
KernelMetaDataRepository repository) throws Throwable
{
ScopeKey scopeKey = context.getScopeInfo().getInstallScope();
if (scopeKey != null)
return scopeKey;
MetaData retrieval = repository.getMetaData(context);
if (retrieval != null)
{
Annotation[] annotations = retrieval.getAnnotations();
if (annotations != null && annotations.length > 0)
{
Collection<Scope> scopes = new HashSet<Scope>();
for (Annotation annotation : annotations)
{
if (annotation.annotationType().isAnnotationPresent(ScopeFactoryLookup.class))
{
ScopeFactoryLookup sfl = annotation.annotationType().getAnnotation(ScopeFactoryLookup.class);
ScopeFactory scf = getScopeFactory(sfl.value());
Scope scope = scf.create(annotation);
scopes.add(scope);
}
}
if (scopes.size() > 0)
{
return new ScopeKey(scopes);
}
}
}
return null;
}