All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nakedobjects.headlessviewer.viewer.internal.JavaProxyFactory Maven / Gradle / Ivy

The newest version!
package org.nakedobjects.headlessviewer.viewer.internal;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

import org.nakedobjects.headlessviewer.applib.ViewObject;



public class JavaProxyFactory implements IProxyFactory {
    @SuppressWarnings("unchecked")
    public T createProxy(final T toProxy, final InvocationHandler handler) {
        final Class proxyClass = (Class) toProxy.getClass();
        return (T) Proxy.newProxyInstance(proxyClass.getClassLoader(), new Class[] { proxyClass }, handler);
    }

    @SuppressWarnings("unchecked")
    public T createProxy(final Class toProxy, final InvocationHandler handler) {
        return (T) Proxy.newProxyInstance(toProxy.getClassLoader(), new Class[] { toProxy, ViewObject.class }, handler);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy