Package javassist.util.proxy

Examples of javassist.util.proxy.ProxyFactory$Find2MethodsArgs


                     }
                  };

                  Object enhancedResult = null;

                  ProxyFactory f = new ProxyFactory()
                  {
                     @Override
                     protected ClassLoader getClassLoader0()
                     {
                        ClassLoader result = callingLoader;
                        if (!ClassLoaders.containsClass(result, ProxyObject.class))
                           result = super.getClassLoader0();
                        return result;
                     };
                  };

                  f.setUseCache(true);

                  Class<?> first = hierarchy[0];
                  if (!first.isInterface())
                  {
                     f.setSuperclass(Proxies.unwrapProxyTypes(first, callingLoader, delegateLoader));
                     hierarchy = Arrays.shiftLeft(hierarchy, new Class<?>[hierarchy.length - 1]);
                  }

                  int index = Arrays.indexOf(hierarchy, ProxyObject.class);
                  if (index >= 0)
                  {
                     hierarchy = Arrays.removeElementAtIndex(hierarchy, index);
                  }

                  if (!Proxies.isProxyType(first) && !Arrays.contains(hierarchy, ForgeProxy.class))
                     hierarchy = Arrays.append(hierarchy, ForgeProxy.class);

                  if (hierarchy.length > 0)
                     f.setInterfaces(hierarchy);

                  f.setFilter(filter);
                  Class<?> c = f.createClass();
                  enhancedResult = c.newInstance();

                  try
                  {
                     ((ProxyObject) enhancedResult)
View Full Code Here


                        + " because it has at least one non-static, final method with public, protected or default visibility");
               }
            }
            try
            {
               ProxyFactory factory = new ProxyFactory();
               factory.setSuperclass(superClass);
               factory.setFilter(MethodFilterHolder.METHOD_FILTER);
               MethodHandler handler = new MethodHandler()
               {
                  public Object invoke(Object self, Method m, Method proceed, Object[] args) throws Throwable
                  {
                     if ((!Modifier.isPublic(m.getModifiers()) || !Modifier.isPublic(m.getDeclaringClass()
                        .getModifiers())) && !m.isAccessible())
                        m.setAccessible(true);
                     return m.invoke(provider.get(), args);
                  }
               };
               return superClass.cast(factory.create(new Class<?>[0], new Object[0], handler));
            }
            catch (Exception e)
            {
               throw new UnproxyableResolutionException("Cannot create a proxy for the class " + superClass.getName(),
                  e);
View Full Code Here

         socket.setEnabledProtocols(protocols);
      if( cipherSuites != null )
         socket.setEnabledCipherSuites(cipherSuites);

      DomainServerSocket handler = new DomainServerSocket(socket);
      ProxyFactory pf = new ProxyFactory();
      pf.setHandler(handler);
      pf.setSuperclass(SSLServerSocket.class);
      Class[] sig = {};
      Object[] args = {};

      SSLServerSocket proxy = null;
      try
      {
         proxy = (SSLServerSocket) pf.create(sig, args);
      }
      catch (Exception e)
      {
         IOException ioe = new IOException("Failed to create SSLServerSocket proxy");
         ioe.initCause(e);
View Full Code Here

public class TypesTest {
  static class Foo {
  }

  public void shouldDeProxyJavassistProxy() {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setSuperclass(Foo.class);
    Class<?> proxy = proxyFactory.createClass();

    assertEquals(Types.deProxy(proxy), Foo.class);
  }
View Full Code Here

    {
        T result = null;

        try
        {
            ProxyFactory pf = new ProxyFactory();
            pf.setInterfaces(new Class<?>[] {Closable.class,
                    Serializable.class,
                    QueueConnection.class,
                    Queue.class,
                    QueueSender.class,
                    QueueSession.class,
                    Topic.class,
                    TopicConnection.class,
                    TopicSession.class,
                    TopicPublisher.class});
           
            pf.setHandler(new JmsProxyHandler(jmsComponent));

            result = (T)pf.createClass().newInstance();

        }
        catch (Exception e)
        {
            throw new WebBeansException(e);
View Full Code Here

        if (bean.getDecoratorStack().size() > 0) {

            Class<?> proxyClass = webBeansContext.getJavassistProxyFactory().getInterceptorProxyClasses().get((InjectionTargetBean<?>) bean);
            if (proxyClass == null) {
                ProxyFactory delegateFactory = webBeansContext.getJavassistProxyFactory().createProxyFactory(bean);
                proxyClass = webBeansContext.getJavassistProxyFactory().getProxyClass(delegateFactory);
                webBeansContext.getJavassistProxyFactory().getInterceptorProxyClasses().put((InjectionTargetBean<?>) bean, proxyClass);
            }
            Object delegate = proxyClass.newInstance();
            DelegateHandler delegateHandler = new DelegateHandler(bean, ejbContext);
View Full Code Here

                interfaces.add(getContentBackedInterface());
            }

            interfaces.addAll(getAdditionalInterfaces(proxy));
           
            ProxyFactory proxyFactory = new ProxyFactory();
            proxyFactory.setInterfaces(interfaces.toArray(new Class[interfaces.size()]));
            proxyFactory.setSuperclass(ResourceClientProxy.class);
            ResourceClientProxy proxied = null;
            try {
                proxied = (ResourceClientProxy) proxyFactory.create(new Class[]{}, new Object[]{},
                        instantiateMethodHandler(proxy, interfaces, rhqFacade));
            } catch (InstantiationException e) {
                LOG.error("Could not instantiate a ResourceClientProxy, this is a bug.", e);
                throw new IllegalStateException("Could not instantiate a ResourceClientProxy, this is a bug.", e);
            } catch (IllegalAccessException e) {
View Full Code Here

            }

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

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

            if (!(bean instanceof WebBeansDecorator) && !(bean instanceof WebBeansInterceptor))
            {
                fact.setHandler(new InterceptorHandler((AbstractComponent<?>) bean));
            }

            result = fact.createClass().newInstance();

        }
        catch (Exception e)
        {
            throw new WebBeansException(e);
View Full Code Here

    {
        WebBeansAnnotation result = null;

        try
        {
            ProxyFactory pf = new ProxyFactory();
            pf.setInterfaces(new Class<?>[] { annotationType, Annotation.class });
            pf.setSuperclass(WebBeansAnnotation.class);
            pf.setHandler(new WebBeansAnnotation(annotationType));

            result = (WebBeansAnnotation) pf.create(new Class[] { Class.class }, new Object[] { annotationType });

        }
        catch (Exception e)
        {
            throw new WebBeansException(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);
           
            clazz = SecurityUtil.doPrivilegedCreateClass(fact);
        }
        catch(Exception e)
        {
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.