Results 1 to 5 of 5

Thread: Java dynamic proxy

  1. #1
    Join Date
    Feb 2010
    Posts
    188

    Java dynamic proxy

    Hi all,

    I am using Java in a project program. Java is support the dynamic proxy mainly refer to in the java.lang.reflect package under the Proxy class will be used in the course of a package under the same Invocation Handler interface. I want to know more how to use Java dynamic proxy in my program. Please help. Thanks in advance.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Java dynamic proxy

    Proxy class Provides a static method of Object in java. newProxyInstance(ClassLoaderloader, Class<?>[] Interfaces, InvocationHandlerh) is used to generate the proxy object that is the target class loader. Its interfaces the target class implements the interface not necessarily all the interfaces it implements, with Class <?>[] type that can be had. h is the InvocationHandler type of an object. Check and reply.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Java dynamic proxy

    Invocation Handler Interface to provide a method of classObject invoke (Objectproxy,Methodmethod,Object[] Args) throws Throwable Used to call the target method and provide new features: proxy is a proxy object, method is the target method and args is the target method parameter list. The so-called dynamic proxy in fact, is such an object: it is dynamically generated at runtime object is generated when it is you have to provide a set of interfaces to it, and then the object has stated that it implements these interfaces. Of course you can take the object as in any one of these interfaces and use them.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Java dynamic proxy

    Java dynamic proxy is actually a proxy object, it will not make substantive work for you, when generating an instance of it you must provide a handler, it is taken over by the actual work. check the code:

    Code:
    public interface StudentDao123 (
      public void test1 ();
      public void test2 ();
      public void test3 ();
      public void test4 ();
    }
    
    public interface StudentDao211 (
      public void t ();
    }
     
    Target class:
    public class StudentDaoImpl123 implements StudentDao123, StudentDao211 (
        / / Implementation of interface method
    }

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: Java dynamic proxy

    You can use DataSourceImpl class get Connection method to achieve with a normal database connection pool logic in Java dynamic proxy , first of all determine whether there is idle connection, if not, to determine whether the number of connections has exceeded the maximum number of connections, and so some of the logic. But one thing different is get the database connection through the DriverManager is not back in time, but through an intermediary class called _Connection check and then call _Connection.get connection return. Check and reply.

Similar Threads

  1. Replies: 1
    Last Post: 22-05-2011, 03:41 AM
  2. Dynamic and Static Polymorphism in Java
    By Ardent in forum Software Development
    Replies: 4
    Last Post: 19-08-2010, 03:37 PM
  3. Dynamic table in java
    By New ID in forum Software Development
    Replies: 5
    Last Post: 21-02-2010, 04:54 AM
  4. dynamic form with java & php
    By hooy in forum Software Development
    Replies: 0
    Last Post: 16-09-2009, 04:27 PM
  5. Proxy connection: internal error during proxy evaluation
    By Pandya in forum Software Development
    Replies: 3
    Last Post: 19-08-2009, 02:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,727,006,544.50481 seconds with 16 queries