<?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%2FReflection%2FProxy</id>
		<title>Java/Reflection/Proxy - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FReflection%2FProxy"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Reflection/Proxy&amp;action=history"/>
		<updated>2026-04-23T22:29:47Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Reflection/Proxy&amp;diff=6091&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Reflection/Proxy&amp;diff=6091&amp;oldid=prev"/>
				<updated>2010-06-01T06:02:02Z</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;Версия 06:02, 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/Reflection/Proxy&amp;diff=6090&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/Reflection/Proxy&amp;diff=6090&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:43Z</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;== A demonstration of a proxy factory ==&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;
 *     file: SomeClassFactory.java&lt;br /&gt;
 *  package: oreilly.hcj.proxies&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;
/**&lt;br /&gt;
 * An invocation handler that counts the number of calls for all methods in the&lt;br /&gt;
 * target class.&lt;br /&gt;
 * &lt;br /&gt;
 * @author &lt;br /&gt;
 * @version $Revision: 1.2 $&lt;br /&gt;
 */&lt;br /&gt;
public class DemoCountingProxy {&lt;br /&gt;
  /**&lt;br /&gt;
   * Run the demonstration.&lt;br /&gt;
   * &lt;br /&gt;
   * @param args&lt;br /&gt;
   *          Command Line Arguments (ignored).&lt;br /&gt;
   */&lt;br /&gt;
  public static final void main(final String[] args) {&lt;br /&gt;
    SomeClassCountingProxy proxy = SomeClassFactory.getCountingProxy();&lt;br /&gt;
    proxy.someMethod();&lt;br /&gt;
    proxy.someOtherMethod(&amp;quot;Our Proxy works!&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot;Method Invocation Count = &amp;quot; + proxy.getInvocationCount());&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/* ########## End of File ########## */&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;
== A dynamic proxy adapter which allows overriding several methods of a target 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;
 * Copyright 2006-2007 The Scriptella Project Team.&lt;br /&gt;
 *&lt;br /&gt;
 * Licensed under the Apache License, Version 2.0 (the &amp;quot;License&amp;quot;);&lt;br /&gt;
 * you may not use this file except in compliance with the License.&lt;br /&gt;
 * You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&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;
 * A dynamic proxy adapter which allows overriding several&lt;br /&gt;
 * methods of a target proxy.&lt;br /&gt;
 * &amp;lt;p&amp;gt;To create a proxy adapter for Interface, create subclass of&lt;br /&gt;
 * ProxyAdapter and define methods from Interface you want to handle,&lt;br /&gt;
 * other methods invocations will be failed.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Fyodor Kupolov&lt;br /&gt;
 * @version 1.0&lt;br /&gt;
 */&lt;br /&gt;
public class ProxyAdapter&amp;lt;T&amp;gt; {&lt;br /&gt;
    private final T proxy;&lt;br /&gt;
    @SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
    public ProxyAdapter(Class... interfaces) {&lt;br /&gt;
        proxy = (T) Proxy.newProxyInstance(getClass().getClassLoader(), interfaces, new InvocationHandler() {&lt;br /&gt;
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {&lt;br /&gt;
                Method m;&lt;br /&gt;
                try {&lt;br /&gt;
                    //Determine if the method has been defined in a subclass&lt;br /&gt;
                    m = ProxyAdapter.this.getClass().getMethod(method.getName(), method.getParameterTypes());&lt;br /&gt;
                    m.setAccessible(true);&lt;br /&gt;
                } catch (Exception e) { //if not found&lt;br /&gt;
                    throw new UnsupportedOperationException(method.toString(), e);&lt;br /&gt;
                }&lt;br /&gt;
                //Invoke the method found and return the result&lt;br /&gt;
                try {&lt;br /&gt;
                    return m.invoke(ProxyAdapter.this, args);&lt;br /&gt;
                } catch (InvocationTargetException e) {&lt;br /&gt;
                    throw e.getCause();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        });&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * @return proxy instance implementing T.&lt;br /&gt;
     */&lt;br /&gt;
    public T getProxy() {&lt;br /&gt;
        return proxy;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Usage example&lt;br /&gt;
     */&lt;br /&gt;
    public static void main(String[] args) throws Exception {&lt;br /&gt;
        //Create adapter for Appendable&lt;br /&gt;
        ProxyAdapter&amp;lt;Appendable&amp;gt; pa = new ProxyAdapter(Appendable.class) {&lt;br /&gt;
            private StringBuilder sb = new StringBuilder();&lt;br /&gt;
            //Override only 2 methods: append and toString&lt;br /&gt;
            public Appendable append(char c) {&lt;br /&gt;
                System.out.println(&amp;quot;Proxy append(char c) method. Append &amp;quot;+c);&lt;br /&gt;
                sb.append(c);&lt;br /&gt;
                return (Appendable) getProxy();&lt;br /&gt;
            }&lt;br /&gt;
            public String toString() {&lt;br /&gt;
                return &amp;quot;Proxy toString method: &amp;quot;+sb;&lt;br /&gt;
            }&lt;br /&gt;
        };&lt;br /&gt;
        final Appendable a = pa.getProxy();&lt;br /&gt;
        a.append(&amp;quot;1&amp;quot;).append(&amp;quot;2&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;a.toString() = &amp;quot; + a.toString());&lt;br /&gt;
        //this invocation fails because no method has been created&lt;br /&gt;
        a.append(&amp;quot;Not implemented&amp;quot;);&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;
== A high-performance factory for dynamic proxy objects ==&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;
 * Copyright 2006 (C) TJDO.&lt;br /&gt;
 * All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is distributed under the terms of the TJDO License version 1.0.&lt;br /&gt;
 * See the terms of the TJDO License in the documentation provided with this software.&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: ProxyFactory.java,v 1.1 2006/08/11 20:41:59 jackknifebarber Exp $&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.lang.ref.Reference;&lt;br /&gt;
import java.lang.ref.SoftReference;&lt;br /&gt;
import java.lang.reflect.Constructor;&lt;br /&gt;
import java.lang.reflect.InvocationHandler;&lt;br /&gt;
import java.lang.reflect.InvocationTargetException;&lt;br /&gt;
import java.lang.reflect.Proxy;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * A high-performance factory for dynamic proxy objects.&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * A ProxyFactory performs the same function as&lt;br /&gt;
 * &amp;lt;tt&amp;gt;java.lang.reflect.Proxy.newProxyInstance()&amp;lt;/tt&amp;gt;, but does so for a single&lt;br /&gt;
 * set of interfaces.&lt;br /&gt;
 * It holds a (soft) reference to the proxy class constructor and so can create&lt;br /&gt;
 * many proxies of the same type with very little overhead.&lt;br /&gt;
 * &amp;lt;p&amp;gt;&lt;br /&gt;
 * The generated proxy class is assigned the same class loader as the&lt;br /&gt;
 * &amp;lt;tt&amp;gt;ProxyFactory&amp;lt;/tt&amp;gt; class itself.&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
 * @version $Revision: 1.1 $&lt;br /&gt;
 */&lt;br /&gt;
public class ProxyFactory&lt;br /&gt;
{&lt;br /&gt;
    private final Class[] interfaces;&lt;br /&gt;
    private Reference ctorRef;&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a factory for proxy objects that implement the specified&lt;br /&gt;
     * interface.&lt;br /&gt;
     *&lt;br /&gt;
     * @param intfc&lt;br /&gt;
     *      the interface for the proxy class to implement&lt;br /&gt;
     */&lt;br /&gt;
    public ProxyFactory(Class intfc)&lt;br /&gt;
    {&lt;br /&gt;
        this(new Class[] { intfc });&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Creates a factory for proxy objects that implement the specified&lt;br /&gt;
     * interface(s).&lt;br /&gt;
     *&lt;br /&gt;
     * @param interfaces&lt;br /&gt;
     *      the list of interfaces for the proxy class to implement&lt;br /&gt;
     */&lt;br /&gt;
    public ProxyFactory(Class[] interfaces)&lt;br /&gt;
    {&lt;br /&gt;
        this.interfaces = interfaces;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns an instance of a proxy class for this factory&amp;quot;s interfaces that&lt;br /&gt;
     * dispatches method invocations to the specified invocation handler. &lt;br /&gt;
     * &amp;lt;tt&amp;gt;ProxyFactory.newInstance&amp;lt;/tt&amp;gt; throws &amp;lt;tt&amp;gt;IllegalArgumentException&amp;lt;/tt&amp;gt;&lt;br /&gt;
     * for the same reasons that &amp;lt;tt&amp;gt;Proxy.getProxyClass&amp;lt;/tt&amp;gt; does.&lt;br /&gt;
     *&lt;br /&gt;
     * @param handler&lt;br /&gt;
     *      the invocation handler to dispatch method invocations to &lt;br /&gt;
     * @return&lt;br /&gt;
     *      a proxy instance with the specified invocation handler of a proxy&lt;br /&gt;
     *      class that implements this factory&amp;quot;s specified interfaces &lt;br /&gt;
     *&lt;br /&gt;
     * @throws IllegalArgumentException&lt;br /&gt;
     *      if any of the restrictions on the parameters that may be passed to&lt;br /&gt;
     *      &amp;lt;tt&amp;gt;getProxyClass&amp;lt;/tt&amp;gt; are violated &lt;br /&gt;
     * @throws NullPointerException&lt;br /&gt;
     *      if the invocation handler is null&lt;br /&gt;
     */&lt;br /&gt;
    public Object newInstance(InvocationHandler handler)&lt;br /&gt;
    {&lt;br /&gt;
        if (handler == null)&lt;br /&gt;
            throw new NullPointerException();&lt;br /&gt;
        try&lt;br /&gt;
        {&lt;br /&gt;
            return getConstructor().newInstance(new Object[] { handler });&lt;br /&gt;
        }&lt;br /&gt;
        catch (InstantiationException e)    { throw new InternalError(e.toString()); }&lt;br /&gt;
        catch (IllegalAccessException e)    { throw new InternalError(e.toString()); }&lt;br /&gt;
        catch (InvocationTargetException e) { throw new InternalError(e.toString()); }&lt;br /&gt;
    }&lt;br /&gt;
    private synchronized Constructor getConstructor()&lt;br /&gt;
    {&lt;br /&gt;
        Constructor ctor = ctorRef == null ? null : (Constructor)ctorRef.get();&lt;br /&gt;
        if (ctor == null)&lt;br /&gt;
        {&lt;br /&gt;
            try&lt;br /&gt;
            {&lt;br /&gt;
                ctor = Proxy.getProxyClass(getClass().getClassLoader(), interfaces)&lt;br /&gt;
                            .getConstructor(new Class[] { InvocationHandler.class });&lt;br /&gt;
            }&lt;br /&gt;
            catch (NoSuchMethodException e)&lt;br /&gt;
            {&lt;br /&gt;
                throw new InternalError(e.toString());&lt;br /&gt;
            }&lt;br /&gt;
            ctorRef = new SoftReference(ctor);&lt;br /&gt;
        }&lt;br /&gt;
        return ctor;&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;
== Creating a Proxy Object ==&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;
import java.lang.reflect.InvocationHandler;&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
import java.lang.reflect.Proxy;&lt;br /&gt;
interface MyInterface {&lt;br /&gt;
  void method();&lt;br /&gt;
}&lt;br /&gt;
class MyInterfaceImpl implements MyInterface {&lt;br /&gt;
  public void method() {&lt;br /&gt;
    System.out.println(&amp;quot;method&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class ProxyClass implements InvocationHandler {&lt;br /&gt;
  Object obj;&lt;br /&gt;
  public ProxyClass(Object o) {&lt;br /&gt;
    obj = o;&lt;br /&gt;
  }&lt;br /&gt;
  public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {&lt;br /&gt;
    Object result = null;&lt;br /&gt;
    try {&lt;br /&gt;
      System.out.println(&amp;quot;before the method is called &amp;quot;);&lt;br /&gt;
      result = m.invoke(obj, args);&lt;br /&gt;
    } catch (Exception eBj) {&lt;br /&gt;
    } finally {&lt;br /&gt;
      System.out.println(&amp;quot;after the method is called&amp;quot;); &lt;br /&gt;
    }&lt;br /&gt;
    return result;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    MyInterface myintf = (MyInterface) Proxy.newProxyInstance(MyInterface.class.getClassLoader(),&lt;br /&gt;
        new Class[] { MyInterface.class }, new ProxyClass(new MyInterfaceImpl()));&lt;br /&gt;
    myintf.method();&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 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;
/*&lt;br /&gt;
 *     file: SomeClassFactory.java&lt;br /&gt;
 *  package: oreilly.hcj.proxies&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;
/**&lt;br /&gt;
 * An invocation handler that counts the number of calls for all methods in the&lt;br /&gt;
 * target class.&lt;br /&gt;
 * &lt;br /&gt;
 * @author &lt;br /&gt;
 * @version $Revision: 1.2 $&lt;br /&gt;
 */&lt;br /&gt;
public class DangerousNames {&lt;br /&gt;
  /** &lt;br /&gt;
   * Run the demonstration.&lt;br /&gt;
   *&lt;br /&gt;
   * @param args Command line arguments (ignored).&lt;br /&gt;
   */&lt;br /&gt;
  public static final void main(final String[] args) {&lt;br /&gt;
    SomeClass proxy = SomeClassFactory.getDynamicSomeClassProxy();&lt;br /&gt;
    System.out.println(proxy.getClass().getName());&lt;br /&gt;
    try {&lt;br /&gt;
      Class cl = Class.forName(&amp;quot;$Proxy0&amp;quot;);  // &amp;lt;== Dangerous!&lt;br /&gt;
      System.out.println(cl.getName());&lt;br /&gt;
    } catch (final ClassNotFoundException ex) {&lt;br /&gt;
      ex.printStackTrace();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/* ########## End of File ########## */&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;
/*&lt;br /&gt;
 *     file: SomeClassFactory.java&lt;br /&gt;
 *  package: oreilly.hcj.proxies&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;
/**&lt;br /&gt;
 * An invocation handler that counts the number of calls for all methods in the&lt;br /&gt;
 * target class.&lt;br /&gt;
 * &lt;br /&gt;
 * @author &lt;br /&gt;
 * @version $Revision: 1.2 $&lt;br /&gt;
 */&lt;br /&gt;
public class DemoClientGeneratedProxy {&lt;br /&gt;
  /** &lt;br /&gt;
   * Run the demonstration.&lt;br /&gt;
   *&lt;br /&gt;
   * @param args Command Line Arguments (ignored).&lt;br /&gt;
   */&lt;br /&gt;
  public static final void main(final String[] args) {&lt;br /&gt;
    SomeClassProxy proxy = new SomeClassProxy(new SomeClassImpl(&amp;quot;Fred&amp;quot;));&lt;br /&gt;
    proxy.someMethod();&lt;br /&gt;
    proxy.someOtherMethod(&amp;quot;Our Proxy works!&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
/* ########## End of File ########## */&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>