Package javassist.util.proxy

Examples of javassist.util.proxy.ProxyObject


      // Should probably create a Factory but required a lot of duplicated
      // code and there is potential for a spring bean to provide
      // different interfaces at different times in an application. If
      // need is great I can create a Factory and assume the same
      // interfaces all the time.
      ProxyObject po = Component.createProxyFactory(ComponentType.JAVA_BEAN, beanClass, interfaces).newInstance();
      po.setHandler(interceptor);
      interceptor.postConstruct();
      return po;
   }
View Full Code Here


      interfaces[0] = serviceRole;
      interfaces[1] = ServiceProxy.class;
      factory.setInterfaces( interfaces );

      Class proxyClass = factory.createClass();
      ProxyObject proxyObject = (ProxyObject) proxyClass.newInstance();
      proxyObject.setHandler( new ServiceProxyMethodInterceptor<T>( (T)proxyObject, serviceRole, serviceRegistry ) );
      return (T) proxyObject;
    }
    catch (Exception e) {
      throw new ServiceProxyGenerationException( "Unable to make service proxy", e );
    }
View Full Code Here

        });

        final Class<T> proxySubclass = proxyFactory.createClass();
        try {
            final T newInstance = proxySubclass.newInstance();
            final ProxyObject proxyObject = (ProxyObject) newInstance;
            proxyObject.setHandler(methodHandler);

            return newInstance;
        } catch (final InstantiationException e) {
            throw new IsisException(e);
        } catch (final IllegalAccessException e) {
View Full Code Here

      proxyClass = factory.createClass();
    }

    public Object getProxy() {
      try {
        ProxyObject proxy = ( ProxyObject ) proxyClass.newInstance();
        proxy.setHandler( new PassThroughHandler( proxy, proxyClass.getName() ) );
        return proxy;
      }
      catch ( Throwable t ) {
        throw new HibernateException( "Unable to instantiated proxy instance" );
      }
View Full Code Here

      interfaces[0] = serviceRole;
      interfaces[1] = ServiceProxy.class;
      factory.setInterfaces( interfaces );

      Class proxyClass = factory.createClass();
      ProxyObject proxyObject = (ProxyObject) proxyClass.newInstance();
      proxyObject.setHandler( new ServiceProxyMethodInterceptor<T>( (T)proxyObject, serviceRole, serviceRegistry ) );
      return (T) proxyObject;
    }
    catch (Exception e) {
      throw new ServiceProxyGenerationException( "Unable to make service proxy", e );
    }
View Full Code Here

  public boolean isProxy(Object o) {
  return o != null && ProxyObject.class.isAssignableFrom(o.getClass());
  }
 
  private <T> void setHandler(Object proxyInstance, final MethodInvocation<? super T> handler) {
  ProxyObject proxyObject = (ProxyObject) proxyInstance;

  proxyObject.setHandler(new MethodHandler() {
    public Object invoke(final Object self, final Method thisMethod, final Method proceed, Object[] args)
    throws Throwable {

    return handler.intercept((T) self, thisMethod, args, new SuperMethod() {
      public Object invoke(Object proxy, Object[] args) {
View Full Code Here

  ProxyFactory factory = new ProxyFactory();
  factory.setSuperclass(pojo.getClass());
 
  Class<?> proxyClass = factory.createClass();
  Object proxyInstance = new ObjenesisInstanceCreator().instanceFor(proxyClass);
  ProxyObject proxyObject = (ProxyObject) proxyInstance;
  proxyObject.setHandler(new MethodHandler() {
    public Object invoke(final Object self, final Method thisMethod, final Method proceed, Object[] args)
      throws Throwable {
    return pojo;
    }
  })
View Full Code Here

     
      try
      {
         if (comp==null)
         {
            ProxyObject proxy = Component.createProxyFactory(
                  ComponentType.STATEFUL_SESSION_BEAN,
                  beanClass,
                  Component.getBusinessInterfaces(beanClass)
               ).newInstance();
            proxy.setHandler(this);
            return proxy;
         }
         else
         {
            return comp.wrap(bean, this);
View Full Code Here

     
      try
      {
         if (comp==null)
         {
            ProxyObject proxy = Component.createProxyFactory(
                  ComponentType.JAVA_BEAN,
                  beanClass,
                  Component.getBusinessInterfaces(beanClass)
               ).newInstance();
            proxy.setHandler(this);
            return proxy;
         }
         else
         {
            return comp.wrap(bean, this);
View Full Code Here

   /**
    * Wrap a CGLIB interceptor around an instance of the component
    */
   public Object wrap(Object bean, MethodHandler interceptor) throws Exception
   {
      ProxyObject proxy = getProxyFactory().newInstance();
      proxy.setHandler(interceptor);
      return proxy;
   }
View Full Code Here

TOP

Related Classes of javassist.util.proxy.ProxyObject

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.