Package javassist.util.proxy

Examples of javassist.util.proxy.ProxyFactory$Find2MethodsArgs


    * @throws Exception
    */
   public void testAbstractProxy() throws Exception
   {
      log.info("+++ testAbstractProxy");
      ProxyFactory factory = new ProxyFactory();
      AThing athing = new AThing();
      ThingMethodHandler handler = new ThingMethodHandler(athing);
      factory.setHandler(handler);
      factory.setSuperclass(AbstractThing.class);
      Class[] sig = {};
      Object[] args = {};
      AbstractThing proxy = (AbstractThing) factory.create(sig, args);
      proxy.method1();
      assertEquals("method1Count", 1, athing.getMethod1Count());
      proxy.method2("testInterfaceProxy");
      assertEquals("method2Count", 1, athing.getMethod2Count());
      proxy.method3(athing);
View Full Code Here


    * @throws Exception
    */
   public void testAbstractJDKClassProxy() throws Exception
   {
      log.info("+++ testAbstractJDKClassProxy");
      ProxyFactory factory = new ProxyFactory();
      HashSet aset = new HashSet();
      MyCollectionHandler handler = new MyCollectionHandler(aset);
      factory.setHandler(handler);
      factory.setSuperclass(java.util.AbstractCollection.class);
      Class[] sig = {};
      Object[] args = {};
      AbstractCollection proxy = (AbstractCollection) factory.create(sig, args);
      proxy.add("Add");
      assertEquals("size", 1, aset.size());
      proxy.remove("Add");
      assertEquals("size", 0, aset.size());
      assertEquals("isEmpty", true, proxy.isEmpty());
View Full Code Here

      this.manager = manager;
      for (Class<?> c : classes)
      {
         iarray[count++] = c;
      }
      ProxyFactory f = new ProxyFactory();
      Class<?> retType = method.getJavaMember().getReturnType();
      if (retType.isInterface())
      {
         f.setSuperclass(Object.class);
         Class<?>[] ifaces = { retType };
         f.setInterfaces(ifaces);
      }
      else
      {
         f.setSuperclass(retType);
      }

      f.setFilter(new MethodFilter()
      {
         public boolean isHandled(Method m)
         {
            // ignore finalize()
            return !m.getName().equals("finalize");
         }
      });
      proxyClass = cast(f.createClass());
   }
View Full Code Here

   public ServiceHandlerBeanLifecycle(Class<? extends T> classToImplement, Class<H> handlerClass, BeanManager manager)
   {
      handler = new ServiceHandlerManager<H>(handlerClass, manager);

      // create the proxy
      factory = new ProxyFactory();
      if (classToImplement.isInterface())
      {
         Class<?>[] interfaces = new Class[1];
         interfaces[0] = classToImplement;
         factory.setInterfaces(interfaces);
View Full Code Here

                    if (injectionTarget.getDecoratorStack().size() > 0)
                    {
                        Class<?> proxyClass = JavassistProxyFactory.getInterceptorProxyClasses().get(bean);
                        if (proxyClass == null)
                        {
                            ProxyFactory delegateFactory = JavassistProxyFactory.createProxyFactory(bean);
                            proxyClass = JavassistProxyFactory.getProxyClass(delegateFactory);
                            JavassistProxyFactory.getInterceptorProxyClasses().put(bean, proxyClass);
                        }
                        Object delegate = proxyClass.newInstance();
                        delegateHandler = new DelegateHandler(this.bean);
View Full Code Here

    {
       Object result = null;

        try
        {
            ProxyFactory pf = new ProxyFactory();
            pf.setInterfaces(new Class<?>[] {
                    Closable.class,
                    Serializable.class,
                    intf});
           
            pf.setHandler(new JmsProxyHandler(jmsComponent,intf));

            result = JavassistProxyFactory.getProxyClass(pf).newInstance();

        }
        catch (Exception e)
View Full Code Here

    {
        //Will only get called once while defining the bean, so no need to cache
        Class<?> clazz = null;
        try
        {
            ProxyFactory fact = createProxyFactory(bean);
            AbstractDecoratorMethodHandler handler = new AbstractDecoratorMethodHandler();
            fact.setHandler(handler);
            clazz = SecurityUtil.doPrivilegedCreateClass(fact);
        }
        catch(Exception e)
        {
            WebBeansUtil.throwRuntimeExceptions(e);
View Full Code Here

        try
        {
            Class<?> proxyClass = normalScopedBeanProxyClasses.get(bean);
            if (proxyClass == null)
            {
                ProxyFactory fact = createProxyFactory(bean);

                proxyClass = getProxyClass(fact);
                normalScopedBeanProxyClasses.put(bean, proxyClass);
            }
           
View Full Code Here

        try
        {
            Class<?> proxyClass = dependentScopedBeanProxyClasses.get(bean);
            if (proxyClass == null)
            {
                ProxyFactory fact = createProxyFactory(bean);
                proxyClass = getProxyClass(fact);
                dependentScopedBeanProxyClasses.put(bean, proxyClass);
            }
           
            result = proxyClass.newInstance();
View Full Code Here

        }

        Class<?>[] interfaceArray = new Class<?>[interfaceList.size()];
        interfaceArray = interfaceList.toArray(interfaceArray);

        ProxyFactory fact = new ProxyFactory();       
        fact.setInterfaces(interfaceArray);
        fact.setSuperclass(superClass);       

        // turn off caching since this is utterly broken
        // this is a static field, but we do not know who else
        // might turn it on again ...
        ProxyFactory.useCache = false;
View Full Code Here

TOP

Related Classes of javassist.util.proxy.ProxyFactory$Find2MethodsArgs

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.