@Override
protected DeploymentConfiguration createDeploymentConfiguration(
Properties initParameters) {
// Get the original configuration from the super class
final DeploymentConfiguration originalConfiguration = super
.createDeploymentConfiguration(initParameters);
// And then create a proxy instance that delegates to the original
// configuration or a customized version
return (DeploymentConfiguration) Proxy.newProxyInstance(
DeploymentConfiguration.class.getClassLoader(),
new Class[] { DeploymentConfiguration.class },
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method,
Object[] args) throws Throwable {
if (method.getDeclaringClass() == DeploymentConfiguration.class) {
// Find the configuration instance to delegate to
DeploymentConfiguration configuration = findDeploymentConfiguration(originalConfiguration);
return method.invoke(configuration, args);
} else {
return method.invoke(proxy, args);
}