Power Java
Dynamic Proxy Classes:
Toward Metalevel Programming in Java

Mathias Richter and Takashi Suezawa
Listing 4. MoneyFactory.

public class MoneyFactory
   public static IMoney newMoney(String currency, double amount)
	    IMoney result = null;
         MoneyInvocationHandler handler = null;
         Money primary = new Money( currency, amount );
         handler = new MoneyInvocationHandler (primary);
         result = (IMoney) Proxy.newProxyInstance(primary.getClass().getClassLoader(),
                 new Class[] { IMoney.class }, handler);
	    } catch(Exception e)
          System.out.println( e.getMessage() );
        } finally
          return result;


Most   Popular
Upcoming Events


Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.