Examples of InvocationHandler


Examples of java.lang.reflect.InvocationHandler

   */
  public Object create(Class api, ClassLoader loader, Map options)
  {
    if (api == null)
      throw new NullPointerException("api must not be null for HessianProxyFactory.create()");
    InvocationHandler handler = null;

    handler = new AsyncHessianProxy(this, api, options);
    if (options.get("sync") != null)
      handler = new SyncHessianProxy(handler);

View Full Code Here

Examples of java.lang.reflect.InvocationHandler

     */
    public static WorkingMemory createProxy(final WorkingMemory workingMemory) {
        return (WorkingMemory) Proxy.newProxyInstance(
                WorkingMemory.class.getClassLoader(),
                new Class[]{WorkingMemory.class},
                new InvocationHandler() {
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        synchronized(workingMemory) {
                            return method.invoke(workingMemory, args);
                        }
                    }
View Full Code Here

Examples of java.lang.reflect.InvocationHandler

  /**
   * @param proxy The proxy object
   * @return The actual target object, behind the proxy
   */
  public static Object getTargetObject (Object proxy) {
    InvocationHandler ih = Proxy.getInvocationHandler(proxy);
    if (ih instanceof ReflectiveObjectProxy) {
      return ((ReflectiveObjectProxy)ih).object;
    } else
      throw new IllegalArgumentException(proxy + " is not handled by ReflectiveObjectProxy");
  }
View Full Code Here

Examples of java.lang.reflect.InvocationHandler

   * @param argument The regular or proxy object
   * @return The possibly translated boundary object
   */
  public static Object translateArgument (Object argument) {
    if (argument != null && Proxy.isProxyClass(argument.getClass())) {
      InvocationHandler ih = Proxy.getInvocationHandler(argument);
      if (ih instanceof ReflectiveProxy) {
        return ((ReflectiveProxy)ih).getTarget();
      }
    }
    return argument;
View Full Code Here

Examples of java.lang.reflect.InvocationHandler

  public void removeListener(Object pojoListener) {
    EventListener l = null;
    for (EventListener listener : listeners) {
      if (Proxy.isProxyClass(listener.getClass())) {
        InvocationHandler handler = Proxy.getInvocationHandler(listener);
        if (handler instanceof EventDelegator) {
          if (pojoListener == ((EventDelegator) handler).getTarget()) {
            l = listener; break;
          }
        }
View Full Code Here

Examples of java.lang.reflect.InvocationHandler

        final Ruby ruby = getRuntime();
        if (!asClass.isInterface()) {
            throw ruby.newTypeError(asClass.getCanonicalName() + " is not an interface");
        }

        return MiniJava.javaToRuby(ruby, Proxy.newProxyInstance(Ruby.getClassLoader(), new Class[] {asClass}, new InvocationHandler() {
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                IRubyObject[] rubyArgs = new IRubyObject[args.length + 1];
                rubyArgs[0] = RubySymbol.newSymbol(ruby, method.getName());
                for (int i = 1; i < rubyArgs.length; i++) {
                    rubyArgs[i] = MiniJava.javaToRuby(ruby, args[i - 1]);
View Full Code Here

Examples of java.lang.reflect.InvocationHandler

                throw recv.getRuntime().newArgumentError("Java interface expected. got: " + args[i]);
            }
            interfaces[i] = ((JavaClass) args[i]).javaClass();
        }

        return JavaObject.wrap(recv.getRuntime(), Proxy.newProxyInstance(recv.getRuntime().getJRubyClassLoader(), interfaces, new InvocationHandler() {

            private Map parameterTypeCache = new ConcurrentHashMap();

            public Object invoke(Object proxy, Method method, Object[] nargs) throws Throwable {
                Class[] parameterTypes = (Class[]) parameterTypeCache.get(method);
View Full Code Here

Examples of java.lang.reflect.InvocationHandler

                throw runtime.newTypeError("Exception instantiating generated interface impl:\n" + ie);
            } catch (IllegalAccessException iae) {
                throw runtime.newTypeError("Exception instantiating generated interface impl:\n" + iae);
            }
        } else {
            return JavaObject.wrap(recv.getRuntime(), Proxy.newProxyInstance(recv.getRuntime().getJRubyClassLoader(), interfaces, new InvocationHandler() {
                private Map parameterTypeCache = new ConcurrentHashMap();

                public Object invoke(Object proxy, Method method, Object[] nargs) throws Throwable {
                    String methodName = method.getName();
                    int length = nargs == null ? 0 : nargs.length;
View Full Code Here

Examples of java.lang.reflect.InvocationHandler

        params.length == 1 && params[0].equals(Object.class)) {
      Object value = args[0];
      if (value == null || ! Proxy.isProxyClass(value.getClass()))
        return Boolean.FALSE;

      InvocationHandler handler = Proxy.getInvocationHandler(value);

      if (! (handler instanceof HessianJMSProxy))
        return new Boolean(false);

      String otherOutboundName = ((HessianJMSProxy) handler).getOutboundName();
View Full Code Here

Examples of java.lang.reflect.InvocationHandler

  public <T> T getPort(QName portName, Class<T> sei)
  {
    String url = portName.getNamespaceURI();
    try {
      InvocationHandler ih =
        new ServiceImplInvocationHandler(sei, url);
      Class proxyClass =
        Proxy.getProxyClass(sei.getClassLoader(),
                            new Class[] { sei });
      T t = (T) proxyClass
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.