Package java.lang.reflect

Examples of java.lang.reflect.InvocationHandler


            if (isInterface) {
                String impl = context.getGlobalContext().getBeanImplementationMap().get(clazz);

                if (impl == null) {
                    InvocationHandler handler = new InterfaceInvocationHandler();
                    object = Proxy.newProxyInstance(clazz.getClassLoader(), new Class[] {
                        clazz
                    }, handler);
                    target = handler;
                } else {
View Full Code Here


  @Override
  public synchronized void register(final Callback callback) {
    callbacks.add((Callback) Proxy.newProxyInstance(
        callback.getClass().getClassLoader(), new Class<?>[] { Callback.class },
        new InvocationHandler() {
          @Override
          public Object invoke(Object proxy, Method method, Object[] args)
              throws Throwable {
            try {
              return method.invoke(callback, args);
View Full Code Here

   * @return an instance.
   */
  protected <T> T newProxy(Class<T> c) {
    ClassLoader loader = c.getClassLoader();
    Class<?>[] types = {c};
    InvocationHandler handler = new InvocationHandler() {
      @Override
      public Object invoke(Object proxy, Method method, Object[] args)
          throws Throwable {
        calls.add(callToString(method.getName(), args));
       
View Full Code Here

     * @param connection May be a {@code ConnectionLogger} proxy
     * @return the original JDBC {@code Connection}
     */
    private Connection unwrapConnection(Connection connection) {
        if (Proxy.isProxyClass(connection.getClass())) {
            InvocationHandler handler = Proxy.getInvocationHandler(connection);
            if (handler instanceof ConnectionLogger) {
                return ((ConnectionLogger) handler).getConnection();
            }
        }
        return connection;
View Full Code Here

      // set application name
      System.setProperty("com.apple.mrj.application.apple.menu.about.name", title);

      // create an implementation of the ApplicationListener interface
      Class<?> applicationListenerInterface = Class.forName("com.apple.eawt.ApplicationListener");
      Object applicationListenerInstance = Proxy.newProxyInstance(MacSupport.class.getClassLoader(), new Class<?>[] { applicationListenerInterface }, new InvocationHandler() {
        @Override
        public Object invoke(Object proxy, Method method, Object[] arguments) throws Throwable {
          // the name of the invoked method
          String methodName = method.getName();
View Full Code Here

        if(target == null) {
          target = new SingleInstanceDispatcher(proxy);
        }
      }
    } else {
      InvocationHandler ih = getInvocationHandler(proxy);
     
      if (ih instanceof ProxyHandler) {
        target = ((ProxyHandler)ih).getTarget();
      }
    }
View Full Code Here

  @Override
  protected InvocationHandler getInvocationHandler(Object proxy)
  {
    Class<?> type = proxy.getClass();
    InvocationHandler ih = null;
   
    if (ProxySubclassGenerator.isProxySubclass(type)) {
      ih = ProxySubclassGenerator.getInvocationHandler(proxy);
    } else if (Proxy.isProxyClass(type)) {
      ih = Proxy.getInvocationHandler(proxy);
View Full Code Here

        // know about all services in the domain so if the service isn't found then it doesn't exist
        if (foundDomain) {
            throw new NoSuchServiceException(serviceName);
        }
       
        InvocationHandler handler = new SCAClientHandler(getDomainURI().toString(), serviceName, serviceInterface);
        return (T)Proxy.newProxyInstance(serviceInterface.getClassLoader(), new Class[]{serviceInterface}, handler);
    }
View Full Code Here

        }
       
    }
   
    private Book createCglibProxy(final Book book) {
        final InvocationHandler handler = new InvocationHandler() {

            public Object invoke(Object object, Method method, Object[] args) throws Throwable {
                return method.invoke(book, args);
            }
           
View Full Code Here

    public void createInterceptor(InterceptorStack stack, Module invokingModule, Object parameters)
    {
        Log log = stack.getServiceLog();

        InvocationHandler handler = new ProxyLoggingInvocationHandler(log, stack.peek());

        Object interceptor =
            Proxy.newProxyInstance(
                invokingModule.getClassResolver().getClassLoader(),
                new Class[] { stack.getServiceInterface()},
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.