Package java.lang.reflect

Examples of java.lang.reflect.InvocationHandler


            throw new CommunicationException(e);
        }  
  } 
 
  public <T> T getService(final Class<T> iface) {
    return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new InvocationHandler() {

      public Object invoke(Object arg0, final Method arg1, final Object[] arg2) throws Throwable {
        if (shutdown) {
          throw ExceptionUtil.convertException(arg1, new TeiidComponentException(RuntimePlugin.Util.getString("LocalTransportHandler.Transport_shutdown"))); //$NON-NLS-1$
        }
View Full Code Here


        }
   
    this.maxObjectSize = maxObjectSize;
   
    // the proxy is used for generating the object based message based on ServiceInvocationStruct class.
    this.odbcProxy = (ODBCServerRemote)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {ODBCServerRemote.class}, new InvocationHandler() {
      @Override
      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (LogManager.isMessageToBeRecorded(LogConstants.CTX_ODBC, MessageLevel.TRACE)) {
          LogManager.logTrace(LogConstants.CTX_ODBC, "invoking server method:", method.getName(), Arrays.deepToString(args)); //$NON-NLS-1$
        }
View Full Code Here

  private ODBCServerRemoteImpl server;
  private ReflectionHelper serverProxy = new ReflectionHelper(ODBCServerRemote.class);
  private ConcurrentLinkedQueue<PGRequest> messageQueue = new ConcurrentLinkedQueue<PGRequest>();
 
  public ODBCClientInstance(final ObjectChannel channel, ODBCServerRemote.AuthenticationType authType, TeiidDriver driver) {
    this.client = (ODBCClientRemote)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {ODBCClientRemote.class}, new InvocationHandler() {
      @Override
      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (LogManager.isMessageToBeRecorded(LogConstants.CTX_ODBC, MessageLevel.TRACE)) {
          LogManager.logTrace(LogConstants.CTX_ODBC, "invoking client method:", method.getName(), Arrays.deepToString(args)); //$NON-NLS-1$
        }
View Full Code Here

     * @return a proxy for the object
     */
    @SuppressWarnings("unchecked")
    protected <T> T assertThrows(final ResultVerifier verifier, final T obj) {
        Class<?> c = obj.getClass();
        InvocationHandler ih = new InvocationHandler() {
            private Exception called = new Exception("No method called");
            public void finalize() {
                if (called != null) {
                    called.printStackTrace(System.err);
                }
View Full Code Here

     * @return Modified capabilities to work correctly when planning with multi-source models
     * @since 4.2
     */
    SourceCapabilities modifyCapabilities(SourceCapabilities caps) {
        // Create a dynamic proxy that intercepts just a couple method calls
        InvocationHandler handler = new MultiSourceHandler(caps);
        return (SourceCapabilities) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] { SourceCapabilities.class }, handler);
    }
View Full Code Here

      return; //no need to distribute events
    }
    channel = this.channelFactory.createMultiplexerChannel(this.multiplexerStack, null);
    channel.connect(this.clusterName);
   
    proxyEventDistributor = (EventDistributor) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {EventDistributor.class}, new InvocationHandler() {
     
      @Override
      public Object invoke(Object proxy, Method method, Object[] args)
          throws Throwable {
        rpcDispatcher.callRemoteMethods(members, new MethodCall(method, args), GroupRequest.GET_NONE, 0);
        return null;
      }
    });
    //wrap the local in a proxy to prevent unintended methods from being called
    rpcDispatcher = new RpcDispatcher(channel, this, this, Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {EventDistributor.class}, new InvocationHandler() {
     
      @Override
      public Object invoke(Object proxy, Method method, Object[] args)
          throws Throwable {
        EventDistributor local = getLocalEventDistributor();
View Full Code Here

 
  public void testProxy() throws SQLException {
   
    final FooImpl fooImpl = new FooImpl();
   
    Foo proxy = (Foo)Proxy.newProxyInstance(TestWrapperImpl.class.getClassLoader(), new Class[] {Foo.class}, new InvocationHandler() {

      public Object invoke(Object arg0, Method arg1, Object[] arg2)
          throws Throwable {
        if (arg1.getName().equals("callMe")) {
          return null;
View Full Code Here

    private static final ClassLoader DEFAULT_CLASS_LOADER = CacheProxy.class.getClassLoader();

    public static Object newProxyInstance(ClassLoader loader, Object target, Class iface, Cache cache) throws IllegalArgumentException
    {

        InvocationHandler handler = null;
        Class[]           ifaces  = new Class[]{ iface };

        handler = new CacheInvocationHandler(target, cache);

        return Proxy.newProxyInstance(loader, ifaces, handler);
View Full Code Here

       
        //The Implementor Should be a proxy class.
        assertTrue("Implemetor Should be a proxy Class",
                     Proxy.isProxyClass(impl.getClass()));

        InvocationHandler implHandler = Proxy.getInvocationHandler(impl);
        assertTrue("Invocation Handler should be instance of SEIImplHandler",
                   implHandler instanceof SEIImplHandler);
        SEIImplHandler seiHandler = (SEIImplHandler)implHandler;
        assertNull("Should have a WebServiceContext set",
                   seiHandler.getContext());
View Full Code Here

           
            //Synchrnization will not be required if the client proxies are thread safe.
            synchronized (this) {
                updateRequestContext(bp.getRequestContext());
               
                InvocationHandler proxyHandler = Proxy.getInvocationHandler(clientProxy);
                try {
                    ret = proxyHandler.invoke(clientProxy, method, args);
                } catch (UndeclaredThrowableException ute) {
                    LOG.log(Level.SEVERE, "PROXY_INVOKE_UNDECLEXCEPTION", method.toString());
                    ex = new ProtocolException(new Message("PROXY_INVOKE_UNDECLEXCEPTION",
                                                           LOG,
                                                           method.toString()).toString(),
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.