Package java.lang.reflect

Examples of java.lang.reflect.InvocationHandler


        nodeTypes.add(getNodeTypeProxy(name, superTypeNames));
    }

    private NodeType getNodeTypeProxy(final String name, final String[] superTypeNames) {

        InvocationHandler ih = new InvocationHandler() {

            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

                // NodeType.getName()
View Full Code Here


      value = null;
    }

    final Object finalValue = value;
    Object proxy = Proxy.newProxyInstance(annotation.getClassLoader(),
        new Class<?>[] {annotation}, new InvocationHandler() {
          public Object invoke(Object proxy, Method method, Object[] args)
              throws Throwable {
            String name = method.getName();
            if (name.equals("annotationType")) {
              return annotation;
View Full Code Here

                throw new NoSuchFieldException(fieldName+" is of type "+type+" and it's not an interface");

            try {
                final Object oldObject = f.get(mojo);

                Object newObject = Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type}, new InvocationHandler() {
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        return interceptor.invoke(proxy,method,args,new InvocationHandler() {
                            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                                return method.invoke(oldObject,args);
                            }
                        });
                    }
View Full Code Here

            Class<?> handlerClass = Class.forName(handlerClassName);
            if (action != null) {
                Object aboutHandlerProxy =
                    Proxy.newProxyInstance(OSXSupport.class.getClassLoader(),
                                           new Class[]{handlerClass},
                                           new InvocationHandler() {
                                               @Override
                                               public Object invoke(Object o, Method method, Object[] args) throws Throwable {
                                                   if (method.getName().equals(handlerMethodName)) {
                                                       action.actionPerformed(null);
                                                   }
View Full Code Here

            final Class<?> listenerClass = Class.forName("com.apple.eawt.FullScreenListener");

            Object proxy =
                Proxy.newProxyInstance(OSXFullScreen.class.getClassLoader(),
                                       new Class[]{listenerClass},
                                       new InvocationHandler() {
                                           @Override
                                           public Object invoke(Object o, Method method, Object[] args) throws Throwable {
                                               if (method.getName().equals("windowEnteredFullScreen")) {
                                                   putValue(NAME, LocalisationHelper.getString("main_frame_menuitem_leave_fullscreen"));
                                                   putValue(SHORT_DESCRIPTION, LocalisationHelper.getString("main_frame_menuitem_hint_leave_fullscreen"));
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

    if (type.isInterface() && (ifun = val.testFunction2(3)) != null) {

      final ClassLoader loader = JavaObject.class
          .getClassLoader();
      return
      java.lang.reflect.Proxy.newProxyInstance(loader, new Class[] { type }, new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, final Method method, final Object[] args)
                throws Throwable {
             
              final Mailbox<Object> reply = new Mailbox<Object>(1);
View Full Code Here

     * @param targetService the service to delegate operations to
     * @return proxy which delegates to the given targetService
     */
    @SuppressWarnings("unchecked")
    public static <T> T getProxy(final Class<T> targetService) {
        return (T) Proxy.newProxyInstance(getCurrentLoader(), new Class<?>[] { targetService }, new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                T service = ServiceTracker.getService(targetService);
                if (service == null) {
                    throw new IllegalStateException("Failed to obtain service " + targetService.getSimpleName());
View Full Code Here

        // And then create a proxy instance that delegates to the original
        // configuration or a customized version
        return (DeploymentConfiguration) Proxy.newProxyInstance(
                DeploymentConfiguration.class.getClassLoader(),
                new Class[] { DeploymentConfiguration.class },
                new InvocationHandler() {
                    @Override
                    public Object invoke(Object proxy, Method method,
                            Object[] args) throws Throwable {
                        if (method.getDeclaringClass() == DeploymentConfiguration.class) {
                            // Find the configuration instance to delegate to
View Full Code Here

         {
            // Handle map specially
            if (clazz.isAssignableFrom(Map.class))
               return unwrapCompositeMap(compositeValue);

            InvocationHandler handler = createCompositeValueInvocationHandler(compositeValue);
            Class<?>[] interfaces = new Class[]{clazz};
            return Proxy.newProxyInstance(clazz.getClassLoader(), interfaces, handler);           
         }
         else if(clazz.isAssignableFrom(ObjectName.class))
         {
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.