}
@SuppressWarnings("unchecked")
protected ContextFactory createContextFactory(String name, JavaImplementation javaImpl, Scope scope) {
Class implClass = null;
JavaContextFactory contextFactory;
try {
implClass = javaImpl.getImplementationClass();
contextFactory = new JavaContextFactory(name, JavaIntrospectionHelper
.getDefaultConstructor(implClass), scope);
List<Injector> injectors = new ArrayList<Injector>();
List<Object> elements = javaImpl.getComponentType().getExtensibilityElements();
for (Object element : elements) {
if (element instanceof InitInvokerExtensibilityElement) {
InitInvokerExtensibilityElement invokerElement = (InitInvokerExtensibilityElement) element;
EventInvoker<Object> initInvoker = invokerElement.getEventInvoker();
boolean eagerInit = invokerElement.isEager();
contextFactory.setEagerInit(eagerInit);
contextFactory.setInitInvoker(initInvoker);
} else if (element instanceof DestroyInvokerExtensibilityElement) {
DestroyInvokerExtensibilityElement invokerElement = (DestroyInvokerExtensibilityElement) element;
EventInvoker<Object> destroyInvoker = invokerElement.getEventInvoker();
contextFactory.setDestroyInvoker(destroyInvoker);
} else if (element instanceof ComponentNameExtensibilityElement) {
ComponentNameExtensibilityElement nameElement = (ComponentNameExtensibilityElement) element;
injectors.add(nameElement.getEventInvoker(name));
} else if (element instanceof ContextExtensibilityElement) {
ContextExtensibilityElement contextElement = (ContextExtensibilityElement) element;
injectors.add(contextElement.getInjector(contextFactory));
}else if (element instanceof InjectorExtensibilityElement){
InjectorExtensibilityElement injectorElement = (InjectorExtensibilityElement)element;
injectors.add(injectorElement.getInjector(contextFactory));
}
}
contextFactory.setSetters(injectors);
return contextFactory;
} catch (BuilderException e) {
e.addContextName(name);
throw e;
} catch (NoSuchMethodException e) {