this.instanceManagers = SystemInstance.get().getComponent(TomcatWebAppBuilder.class).getInstanceManagers();
}
@Override
public <T> T getEndpointInstance(final Class<T> clazz) throws InstantiationException {
final InstanceManager instanceManager = instanceManagers.get(clazz.getClassLoader());
if (instanceManager == null) {
return super.getEndpointInstance(clazz);
}
try {
return clazz.cast(instanceManager.newInstance(clazz));
} catch (final Exception e) {
if (InstantiationException.class.isInstance(e)) {
throw InstantiationException.class.cast(e);
}
throw new InstantiationException(e.getMessage());