Java Code Examples for javassist.util.proxy.Proxy#setHandler()

The following examples show how to use javassist.util.proxy.Proxy#setHandler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProxyFactoryFactoryImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public Object getProxy() {
	try {
		final Proxy proxy = (Proxy) proxyClass.newInstance();
		proxy.setHandler( new PassThroughHandler( proxy, proxyClass.getName() ) );
		return proxy;
	}
	catch ( Throwable t ) {
		throw new HibernateException( "Unable to instantiated proxy instance" );
	}
}
 
Example 2
Source File: TestProxyResource.java    From jax-rs-pac4j with Apache License 2.0 5 votes vote down vote up
@Path("proxied/class")
public TestClassLevelResource proxiedResource() {
    try {
        final ProxyFactory factory = new ProxyFactory();
        factory.setSuperclass(TestClassLevelResource.class);
        final Proxy proxy = (Proxy) factory.createClass().newInstance();
        proxy.setHandler((self, overridden, proceed, args) -> {
            return proceed.invoke(self, args);
        });

        return (TestClassLevelResource) proxy;
    } catch (InstantiationException | IllegalAccessException e) {
        throw new AssertionError(e);
    }
}