<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FDevelopment_Class%2FDynamic_Proxy</id>
		<title>Java/Development Class/Dynamic Proxy - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FDevelopment_Class%2FDynamic_Proxy"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Development_Class/Dynamic_Proxy&amp;action=history"/>
		<updated>2026-04-19T05:42:46Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Development_Class/Dynamic_Proxy&amp;diff=8363&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Development_Class/Dynamic_Proxy&amp;diff=8363&amp;oldid=prev"/>
				<updated>2010-06-01T07:00:14Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 07:00, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Development_Class/Dynamic_Proxy&amp;diff=8362&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Development_Class/Dynamic_Proxy&amp;diff=8362&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:46Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Demonstrates a dangerous use of proxy names ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
$Proxy0&lt;br /&gt;
$Proxy0&lt;br /&gt;
*/&lt;br /&gt;
import java.lang.reflect.InvocationHandler;&lt;br /&gt;
import java.lang.reflect.InvocationTargetException;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.lang.reflect.Proxy;&lt;br /&gt;
/*&lt;br /&gt;
 *&lt;br /&gt;
 * This software is granted under the terms of the Common Public License,&lt;br /&gt;
 * CPL, which may be found at the following URL:&lt;br /&gt;
 * http://www-124.ibm.ru/developerworks/oss/CPLv1.0.htm&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright(c) 2003-2005 by the authors indicated in the @author tags.&lt;br /&gt;
 * All Rights are Reserved by the various authors.&lt;br /&gt;
 *&lt;br /&gt;
########## DO NOT EDIT ABOVE THIS LINE ########## */&lt;br /&gt;
/**  &lt;br /&gt;
 * Demonstrates a dangerous use of proxy names.&lt;br /&gt;
 * &lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * According to the JDK, the unqualified name of a proxy class is undefined so using it&lt;br /&gt;
 * in code like this could cause you grief.&lt;br /&gt;
 * &amp;lt;/p&amp;gt;&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
 * @version $Revision: 1.2 $&lt;br /&gt;
 * &lt;br /&gt;
 * @see java.lang.reflect.InvocationHandler&lt;br /&gt;
 */&lt;br /&gt;
class MethodCountingHandler implements InvocationHandler {&lt;br /&gt;
  /** The implementation object for this proxy. */&lt;br /&gt;
  private final Object impl;&lt;br /&gt;
  /** Holds the invocation count. */&lt;br /&gt;
  private int invocationCount = 0;&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates a new MethodCOuntingHandler object.&lt;br /&gt;
   * &lt;br /&gt;
   * @param impl&lt;br /&gt;
   */&lt;br /&gt;
  public MethodCountingHandler(final Object impl) {&lt;br /&gt;
    this.impl = impl;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Gets the value of the property invocationCount.&lt;br /&gt;
   * &lt;br /&gt;
   * @return The current value of invocationCount&lt;br /&gt;
   */&lt;br /&gt;
  public int getInvocationCount() {&lt;br /&gt;
    return invocationCount;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object,&lt;br /&gt;
   *      java.lang.reflect.Method, java.lang.Object[])&lt;br /&gt;
   */&lt;br /&gt;
  public Object invoke(Object proxy, Method meth, Object[] args) throws Throwable {&lt;br /&gt;
    try {&lt;br /&gt;
      this.invocationCount++;&lt;br /&gt;
      Object result = meth.invoke(impl, args);&lt;br /&gt;
      return result;&lt;br /&gt;
    } catch (final InvocationTargetException ex) {&lt;br /&gt;
      throw ex.getTargetException();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Demonstrates a dynamic proxy ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
joeyin&lt;br /&gt;
Our Proxy works!&lt;br /&gt;
2&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 *&lt;br /&gt;
 * This software is granted under the terms of the Common Public License,&lt;br /&gt;
 * CPL, which may be found at the following URL:&lt;br /&gt;
 * http://www-124.ibm.ru/developerworks/oss/CPLv1.0.htm&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright(c) 2003-2005 by the authors indicated in the @author tags.&lt;br /&gt;
 * All Rights are Reserved by the various authors.&lt;br /&gt;
 *&lt;br /&gt;
 ########## DO NOT EDIT ABOVE THIS LINE ########## */&lt;br /&gt;
import java.lang.reflect.InvocationHandler;&lt;br /&gt;
import java.lang.reflect.InvocationTargetException;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.lang.reflect.Proxy;&lt;br /&gt;
import java.util.logging.Logger;&lt;br /&gt;
/**&lt;br /&gt;
 * Demonstrates a dynamic proxy.&lt;br /&gt;
 * &lt;br /&gt;
 * @author &lt;br /&gt;
 * @version $Revision: 1.2 $&lt;br /&gt;
 * &lt;br /&gt;
 * @see java.lang.reflect.InvocationHandler&lt;br /&gt;
 */&lt;br /&gt;
class MethodCountingHandler implements InvocationHandler {&lt;br /&gt;
  /** The implementation object for this proxy. */&lt;br /&gt;
  private final Object impl;&lt;br /&gt;
  /** Holds the invocation count. */&lt;br /&gt;
  private int invocationCount = 0;&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates a new MethodCOuntingHandler object.&lt;br /&gt;
   * &lt;br /&gt;
   * @param impl&lt;br /&gt;
   */&lt;br /&gt;
  public MethodCountingHandler(final Object impl) {&lt;br /&gt;
    this.impl = impl;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Gets the value of the property invocationCount.&lt;br /&gt;
   * &lt;br /&gt;
   * @return The current value of invocationCount&lt;br /&gt;
   */&lt;br /&gt;
  public int getInvocationCount() {&lt;br /&gt;
    return invocationCount;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object,&lt;br /&gt;
   *      java.lang.reflect.Method, java.lang.Object[])&lt;br /&gt;
   */&lt;br /&gt;
  public Object invoke(Object proxy, Method meth, Object[] args) throws Throwable {&lt;br /&gt;
    try {&lt;br /&gt;
      this.invocationCount++;&lt;br /&gt;
      Object result = meth.invoke(impl, args);&lt;br /&gt;
      return result;&lt;br /&gt;
    } catch (final InvocationTargetException ex) {&lt;br /&gt;
      throw ex.getTargetException();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Demonstrates the basic concept of proxies generated by clients to the proxies ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Fred&lt;br /&gt;
Our Proxy works!&lt;br /&gt;
*/&lt;br /&gt;
import java.lang.reflect.InvocationHandler;&lt;br /&gt;
import java.lang.reflect.InvocationTargetException;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.lang.reflect.Proxy;&lt;br /&gt;
/*&lt;br /&gt;
 *&lt;br /&gt;
 * This software is granted under the terms of the Common Public License,&lt;br /&gt;
 * CPL, which may be found at the following URL:&lt;br /&gt;
 * http://www-124.ibm.ru/developerworks/oss/CPLv1.0.htm&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright(c) 2003-2005 by the authors indicated in the @author tags.&lt;br /&gt;
 * All Rights are Reserved by the various authors.&lt;br /&gt;
 *&lt;br /&gt;
########## DO NOT EDIT ABOVE THIS LINE ########## */&lt;br /&gt;
/**  &lt;br /&gt;
 * Demonstrates the basic concept of proxies generated by clients to the proxies.&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
 * @version $Revision: 1.2 $&lt;br /&gt;
 * &lt;br /&gt;
 * @see java.lang.reflect.InvocationHandler&lt;br /&gt;
 */&lt;br /&gt;
class MethodCountingHandler implements InvocationHandler {&lt;br /&gt;
  /** The implementation object for this proxy. */&lt;br /&gt;
  private final Object impl;&lt;br /&gt;
  /** Holds the invocation count. */&lt;br /&gt;
  private int invocationCount = 0;&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates a new MethodCOuntingHandler object.&lt;br /&gt;
   * &lt;br /&gt;
   * @param impl&lt;br /&gt;
   */&lt;br /&gt;
  public MethodCountingHandler(final Object impl) {&lt;br /&gt;
    this.impl = impl;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Gets the value of the property invocationCount.&lt;br /&gt;
   * &lt;br /&gt;
   * @return The current value of invocationCount&lt;br /&gt;
   */&lt;br /&gt;
  public int getInvocationCount() {&lt;br /&gt;
    return invocationCount;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object,&lt;br /&gt;
   *      java.lang.reflect.Method, java.lang.Object[])&lt;br /&gt;
   */&lt;br /&gt;
  public Object invoke(Object proxy, Method meth, Object[] args) throws Throwable {&lt;br /&gt;
    try {&lt;br /&gt;
      this.invocationCount++;&lt;br /&gt;
      Object result = meth.invoke(impl, args);&lt;br /&gt;
      return result;&lt;br /&gt;
    } catch (final InvocationTargetException ex) {&lt;br /&gt;
      throw ex.getTargetException();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Demonstrates the usage of a counting proxy ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
joeyin&lt;br /&gt;
Our Proxy works!&lt;br /&gt;
Method Invocation Count = 2&lt;br /&gt;
*/&lt;br /&gt;
import java.lang.reflect.InvocationHandler;&lt;br /&gt;
import java.lang.reflect.InvocationTargetException;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.lang.reflect.Proxy;&lt;br /&gt;
/**  &lt;br /&gt;
 * Demonstrates the usage of a counting proxy.&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
 * @version $Revision: 1.2 $&lt;br /&gt;
 * &lt;br /&gt;
 * @see java.lang.reflect.InvocationHandler&lt;br /&gt;
 */&lt;br /&gt;
class MethodCountingHandler implements InvocationHandler {&lt;br /&gt;
  /** The implementation object for this proxy. */&lt;br /&gt;
  private final Object impl;&lt;br /&gt;
  /** Holds the invocation count. */&lt;br /&gt;
  private int invocationCount = 0;&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates a new MethodCOuntingHandler object.&lt;br /&gt;
   * &lt;br /&gt;
   * @param impl&lt;br /&gt;
   */&lt;br /&gt;
  public MethodCountingHandler(final Object impl) {&lt;br /&gt;
    this.impl = impl;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Gets the value of the property invocationCount.&lt;br /&gt;
   * &lt;br /&gt;
   * @return The current value of invocationCount&lt;br /&gt;
   */&lt;br /&gt;
  public int getInvocationCount() {&lt;br /&gt;
    return invocationCount;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object,&lt;br /&gt;
   *      java.lang.reflect.Method, java.lang.Object[])&lt;br /&gt;
   */&lt;br /&gt;
  public Object invoke(Object proxy, Method meth, Object[] args) throws Throwable {&lt;br /&gt;
    try {&lt;br /&gt;
      this.invocationCount++;&lt;br /&gt;
      Object result = meth.invoke(impl, args);&lt;br /&gt;
      return result;&lt;br /&gt;
    } catch (final InvocationTargetException ex) {&lt;br /&gt;
      throw ex.getTargetException();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Demonstrates the use of factories to generate proxies ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
joeyin&lt;br /&gt;
Our Proxy works!&lt;br /&gt;
*/&lt;br /&gt;
import java.lang.reflect.InvocationHandler;&lt;br /&gt;
import java.lang.reflect.InvocationTargetException;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.lang.reflect.Proxy;&lt;br /&gt;
/*&lt;br /&gt;
 *&lt;br /&gt;
 * This software is granted under the terms of the Common Public License,&lt;br /&gt;
 * CPL, which may be found at the following URL:&lt;br /&gt;
 * http://www-124.ibm.ru/developerworks/oss/CPLv1.0.htm&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright(c) 2003-2005 by the authors indicated in the @author tags.&lt;br /&gt;
 * All Rights are Reserved by the various authors.&lt;br /&gt;
 *&lt;br /&gt;
########## DO NOT EDIT ABOVE THIS LINE ########## */&lt;br /&gt;
/**  &lt;br /&gt;
 * Demonstrates the use of factories to generate proxies.&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
 * @version $Revision: 1.2 $&lt;br /&gt;
 * &lt;br /&gt;
 * @see java.lang.reflect.InvocationHandler&lt;br /&gt;
 */&lt;br /&gt;
class MethodCountingHandler implements InvocationHandler {&lt;br /&gt;
  /** The implementation object for this proxy. */&lt;br /&gt;
  private final Object impl;&lt;br /&gt;
  /** Holds the invocation count. */&lt;br /&gt;
  private int invocationCount = 0;&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates a new MethodCOuntingHandler object.&lt;br /&gt;
   * &lt;br /&gt;
   * @param impl&lt;br /&gt;
   */&lt;br /&gt;
  public MethodCountingHandler(final Object impl) {&lt;br /&gt;
    this.impl = impl;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Gets the value of the property invocationCount.&lt;br /&gt;
   * &lt;br /&gt;
   * @return The current value of invocationCount&lt;br /&gt;
   */&lt;br /&gt;
  public int getInvocationCount() {&lt;br /&gt;
    return invocationCount;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object,&lt;br /&gt;
   *      java.lang.reflect.Method, java.lang.Object[])&lt;br /&gt;
   */&lt;br /&gt;
  public Object invoke(Object proxy, Method meth, Object[] args) throws Throwable {&lt;br /&gt;
    try {&lt;br /&gt;
      this.invocationCount++;&lt;br /&gt;
      Object result = meth.invoke(impl, args);&lt;br /&gt;
      return result;&lt;br /&gt;
    } catch (final InvocationTargetException ex) {&lt;br /&gt;
      throw ex.getTargetException();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Demonstrates the use of interface based proxies ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
joeyin&lt;br /&gt;
Our Proxy works!&lt;br /&gt;
*/&lt;br /&gt;
import java.lang.reflect.InvocationHandler;&lt;br /&gt;
import java.lang.reflect.InvocationTargetException;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.lang.reflect.Proxy;&lt;br /&gt;
/*&lt;br /&gt;
 *&lt;br /&gt;
 * This software is granted under the terms of the Common Public License,&lt;br /&gt;
 * CPL, which may be found at the following URL:&lt;br /&gt;
 * http://www-124.ibm.ru/developerworks/oss/CPLv1.0.htm&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright(c) 2003-2005 by the authors indicated in the @author tags.&lt;br /&gt;
 * All Rights are Reserved by the various authors.&lt;br /&gt;
 *&lt;br /&gt;
########## DO NOT EDIT ABOVE THIS LINE ########## */&lt;br /&gt;
/**  &lt;br /&gt;
 * Demonstrates the use of interface based proxies.&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
 * @version $Revision: 1.2 $&lt;br /&gt;
 * &lt;br /&gt;
 * @see java.lang.reflect.InvocationHandler&lt;br /&gt;
 */&lt;br /&gt;
class MethodCountingHandler implements InvocationHandler {&lt;br /&gt;
  /** The implementation object for this proxy. */&lt;br /&gt;
  private final Object impl;&lt;br /&gt;
  /** Holds the invocation count. */&lt;br /&gt;
  private int invocationCount = 0;&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates a new MethodCOuntingHandler object.&lt;br /&gt;
   * &lt;br /&gt;
   * @param impl&lt;br /&gt;
   */&lt;br /&gt;
  public MethodCountingHandler(final Object impl) {&lt;br /&gt;
    this.impl = impl;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Gets the value of the property invocationCount.&lt;br /&gt;
   * &lt;br /&gt;
   * @return The current value of invocationCount&lt;br /&gt;
   */&lt;br /&gt;
  public int getInvocationCount() {&lt;br /&gt;
    return invocationCount;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object,&lt;br /&gt;
   *      java.lang.reflect.Method, java.lang.Object[])&lt;br /&gt;
   */&lt;br /&gt;
  public Object invoke(Object proxy, Method meth, Object[] args) throws Throwable {&lt;br /&gt;
    try {&lt;br /&gt;
      this.invocationCount++;&lt;br /&gt;
      Object result = meth.invoke(impl, args);&lt;br /&gt;
      return result;&lt;br /&gt;
    } catch (final InvocationTargetException ex) {&lt;br /&gt;
      throw ex.getTargetException();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Dynamic Action Hookup Test ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.awt.event.WindowAdapter;&lt;br /&gt;
import java.awt.event.WindowEvent;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.swing.JButton;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import javax.swing.JLabel;&lt;br /&gt;
public class DynamicHookupTest extends JFrame {&lt;br /&gt;
  DynamicActionAdapter actionAdapter = new DynamicActionAdapter();&lt;br /&gt;
  JLabel label = new JLabel(&amp;quot;Ready...&amp;quot;, JLabel.CENTER);&lt;br /&gt;
  int count;&lt;br /&gt;
  public DynamicHookupTest() {&lt;br /&gt;
    JButton launchButton = new JButton(&amp;quot;Launch!&amp;quot;);&lt;br /&gt;
    getContentPane().add(launchButton, &amp;quot;South&amp;quot;);&lt;br /&gt;
    getContentPane().add(label, &amp;quot;Center&amp;quot;);&lt;br /&gt;
    actionAdapter.hookup(launchButton, this, &amp;quot;launchTheMissiles&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void launchTheMissiles() {&lt;br /&gt;
    label.setText(&amp;quot;Launched: &amp;quot; + count++);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    JFrame f = new DynamicHookupTest();&lt;br /&gt;
    f.addWindowListener(new WindowAdapter() {&lt;br /&gt;
      public void windowClosing(WindowEvent we) {&lt;br /&gt;
        System.exit(0);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    f.setSize(150, 150);&lt;br /&gt;
    f.setVisible(true);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class DynamicActionAdapter implements ActionListener {&lt;br /&gt;
  Hashtable actions = new Hashtable();&lt;br /&gt;
  public void hookup(Object sourceObject, Object targetObject, String targetMethod) {&lt;br /&gt;
    actions.put(sourceObject, new Target(targetObject, targetMethod));&lt;br /&gt;
    invokeReflectedMethod(sourceObject, &amp;quot;addActionListener&amp;quot;, new Object[] { this },&lt;br /&gt;
        new Class[] { ActionListener.class });&lt;br /&gt;
  }&lt;br /&gt;
  public void actionPerformed(ActionEvent e) {&lt;br /&gt;
    Target target = (Target) actions.get(e.getSource());&lt;br /&gt;
    if (target == null)&lt;br /&gt;
      throw new RuntimeException(&amp;quot;unknown source&amp;quot;);&lt;br /&gt;
    invokeReflectedMethod(target.object, target.methodName, null, null);&lt;br /&gt;
  }&lt;br /&gt;
  private void invokeReflectedMethod(Object target, String methodName, Object[] args,&lt;br /&gt;
      Class[] argTypes) {&lt;br /&gt;
    try {&lt;br /&gt;
      Method method = target.getClass().getMethod(methodName, argTypes);&lt;br /&gt;
      method.invoke(target, args);&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      throw new RuntimeException(&amp;quot;invocation problem: &amp;quot; + e);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  class Target {&lt;br /&gt;
    Object object;&lt;br /&gt;
    String methodName;&lt;br /&gt;
    Target(Object object, String methodName) {&lt;br /&gt;
      this.object = object;&lt;br /&gt;
      this.methodName = methodName;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>