in webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java [561:626]
private <T> T createInstance(Class<T> clazz)
{
// skip the reflection for know classes
if (DefaultLoaderService.class == clazz)
{
return clazz.cast(new DefaultLoaderService());
}
if (SimpleSecurityService.class == clazz)
{
return clazz.cast(new SimpleSecurityService());
}
if (DefaultApplicationBoundaryService.class == clazz)
{
return clazz.cast(new DefaultApplicationBoundaryService());
}
if (DefaultBeanArchiveService.class == clazz)
{
return clazz.cast(new DefaultBeanArchiveService());
}
if (DefaultJndiService.class == clazz)
{
return clazz.cast(new DefaultJndiService());
}
if (DefaultContextsService.class == clazz)
{
return clazz.cast(new DefaultContextsService(this));
}
if (DefaultConversationService.class == clazz)
{
return clazz.cast(new DefaultConversationService());
}
// try by reflection for extensions
try
{
// first try constructor that takes this object as an argument
try
{
Constructor<T> constructor = clazz.getConstructor(WebBeansContext.class);
return constructor.newInstance(this);
}
catch (NoSuchMethodException e)
{
}
// then try a no-arg constructor
try
{
Constructor<T> constructor = clazz.getConstructor();
return constructor.newInstance();
}
catch (NoSuchMethodException e)
{
throw new WebBeansException("No suitable constructor : " + clazz.getName(), e.getCause());
}
}
catch (InstantiationException | InvocationTargetException e)
{
throw new WebBeansException("Unable to instantiate class : " + clazz.getName(), e.getCause());
}
catch (IllegalAccessException e)
{
throw new WebBeansException("Illegal access exception in creating instance with class : " + clazz.getName(), e);
}
}