implementationClass = (Class<? extends Component>) classLoader.loadClass(implementationName);
} catch (ClassNotFoundException ex) {
log.error("Proxy implementation not found: " + implementationName, ex);
throw new ProxyException("Proxy implementation not found: " + implementationName, ex);
}
// instantiate proxy implementation
try {
Class<?>[] constructorArgs = new Class<?>[] { ProxyConfig.class };
Constructor<?> constructor = implementationClass.getConstructor(constructorArgs);
this.moProxy = (Proxy) constructor.newInstance(new Object[] { this.proxyConfig });
} catch (NoSuchMethodException ex) {
log.error("Proxy " + implementationName + " does not have a constructor that takes a ProxyConfig object.", ex);
throw new ProxyException("Proxy " + implementationName + " does not have a constructor that takes a ProxyConfig object.", ex);
} catch (InstantiationException ex) {
log.error("Cannot instantiate proxy " + implementationName + ".", ex);
throw new ProxyException("Cannot instantiate proxy " + implementationName + ".", ex);
} catch (IllegalAccessException ex) {
log.error("Illegal access to constructor of proxy " + implementationName + ".", ex);
throw new ProxyException("Illegal access to constructor of proxy " + implementationName + ".", ex);
} catch (InvocationTargetException ex) {
log.error("Cannot invoke constructor of proxy " + implementationName + ".", ex);
throw new ProxyException("Cannot invoke constructor of proxy " + implementationName + ".", ex);
} catch (Exception ex) {
log.error("Cannot construct proxy " + implementationName + ".", ex);
throw new ProxyException("Cannot construct proxy " + implementationName + ".", ex);
}
// init proxy
this.moProxy.init();