Package org.hotswap.agent.javassist.util.proxy

Examples of org.hotswap.agent.javassist.util.proxy.ProxyFactory$UniqueName


    public SessionFactory proxy(SessionFactory sessionFactory, ServiceRegistry serviceRegistry) {
        this.currentInstance = sessionFactory;
        this.serviceRegistry = serviceRegistry;

        ProxyFactory factory = new ProxyFactory();
        factory.setSuperclass(SessionFactoryImpl.class);
        factory.setInterfaces(new Class[]{SessionFactory.class});

        MethodHandler handler = new MethodHandler() {
            @Override
            public Object invoke(Object self, Method overridden, Method forwarder,
                                 Object[] args) throws Throwable {
                return overridden.invoke(currentInstance, args);
            }
        };


        Object instance;
        try {
            Constructor constructor = ReflectionFactory.getReflectionFactory().newConstructorForSerialization(factory.createClass(), Object.class.getDeclaredConstructor(new Class[0]));
            instance = constructor.newInstance();
            ((Proxy) instance).setHandler(handler);
        } catch (Exception e) {
            throw new Error("Unable instantiate SessionFactory proxy", e);
        }
View Full Code Here

TOP

Related Classes of org.hotswap.agent.javassist.util.proxy.ProxyFactory$UniqueName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.