Package java.lang.reflect

Examples of java.lang.reflect.InvocationHandler


                    return null;
                }
            }

            // create the proxy
            final InvocationHandler handler = new SlingRepositoryProxyHandler(delegatee, usingBundle);
            return Proxy.newProxyInstance(cl, interfaces, handler);
        }
View Full Code Here


    @SuppressWarnings("rawtypes")
    @Override
    public Flow connect(FlowDef flowDef) {
        final Flow flow = super.connect(flowDef);
        Flow proxy = (Flow) Proxy.newProxyInstance(Flow.class.getClassLoader(), new Class[] { Flow.class }, new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        Object invocation = ReflectionUtils.invoke(method, flow, args);
                        if ("complete".equals(method.getName())) {
                            printStats(flow);
View Full Code Here

/**
* @author <a href="mailto:cdewolf@redhat.com">Carlo de Wolf</a>
*/
public class ExampleRunner {
    private static <T> T createProxy(MBeanServerConnection mbeanServer, String lookupName, Class<T> intf) {
        final InvocationHandler handler = new TestMBeanInvocationHandler(mbeanServer, lookupName);
        final Class<?>[] interfaces = {intf};
        return intf.cast(Proxy.newProxyInstance(intf.getClassLoader(), interfaces, handler));
    }
View Full Code Here

public abstract class StatsUtils {

    @SuppressWarnings("rawtypes")
    public static Flow proxy(final Flow flow) {
        Flow proxy = (Flow) Proxy.newProxyInstance(Flow.class.getClassLoader(), new Class[] { Flow.class }, new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        Object invocation = ReflectionUtils.invoke(method, flow, args);
                        if ("complete".equals(method.getName())) {
                            printStats(flow);
View Full Code Here

         {
            // postpone the inevitable
            //ClassLoader cl = AccessController.doPrivileged(currentContextClassLoader());
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            Class<?> interfaces[] = { Context.class };
            InvocationHandler handler = new InvocationHandler() {
               public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
               {
                  try
                  {
                     if(encFactory == null)
View Full Code Here

        for(int i = 0; i < numInterfaces; i++) {
            interfaces[i] = (Class)in.readObject();
            implementations[i] = (SerializableState)in.readObject();
        }

        InvocationHandler handler =
            new InterfaceHandler(interfaces, implementations);

        theObject =
            Proxy.newProxyInstance(JAI.class.getClassLoader(),
                                   interfaces,
View Full Code Here

    if (notifs!=null && notifs.length!=0) isBroadcaster=true;
    //We first create the proxy for the remote mbean. If broadcasting supported, then it adds the broadcasting interface
    Object proxy=MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, iface, isBroadcaster);
    //We get the underlying invocation handler, needed for the wrapper handler. The wrapper adds the mbean interface functionality
    //and integrates JMX invocation handler.
    InvocationHandler h=Proxy.getInvocationHandler(proxy);
    InvocationHandler wrapper=new JMXInvocationHandler(oname,mbeanServer, mbeanServer.getMBeanInfo(objectName), h);
    Class[] ifaces;
    if (isBroadcaster) {
      ifaces=new Class[]{iface, NotificationEmitter.class, MBean.class};
    }else ifaces=new Class[]{iface, MBean.class};
    //finally, we create the proxy with the appropriate classloader, the interfaces and the invocation handler
View Full Code Here

    if (proxied.isEmpty()) return new AdapterPeripheral(methods, target);

    Set<Class<?>> allImplemented = Sets.newHashSet(proxied);
    allImplemented.add(IPeripheral.class);

    InvocationHandler handler = new ProxyAdapterPeripheral(methods, target);

    Class<?>[] interfaces = allImplemented.toArray(new Class<?>[allImplemented.size()]);

    return (IPeripheral)Proxy.newProxyInstance(targetClass.getClassLoader(), interfaces, handler);
  }
View Full Code Here

    public Announcer(Class<? extends T> listenerType) {
        proxy = listenerType.cast(Proxy.newProxyInstance(
                listenerType.getClassLoader(),
                new Class<?>[]{listenerType},
                new InvocationHandler() {
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        announce(method, args);
                        return null;
                    }
                }));
View Full Code Here

                    }
                }
            }
        }
       
        InvocationHandler h = new Handler(m);
        return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[] { clazz }, h);
    }
View Full Code Here

TOP

Related Classes of java.lang.reflect.InvocationHandler

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.