The Source for Java Technology Collaboration
User: Password:



Evan Summers

Evan Summers's Blog

Gooey Bean Proxy

Posted by evanx on July 23, 2007 at 06:39 AM | Comments (0)

We expose a "presentation model" bean using an interface, used to create a dynamic proxy, with a backing Map of property/values eg. for GUI prototyping, or otherwise a java.bean.


Code Snippet

We expose the properties of the presentation model using an interface as follows.

public interface PersonInfo extends GObservableBean {
    GProperty<String> username();
    GProperty<String> firstNames();
    GProperty<String> lastName();
    GProperty<String> displayName();
    GProperty<String> email();
    GProperty<Date> birthday();
    GProperty<Date> lastLogin();
    GProperty<BigDecimal> score();
    GProperty<PersonTitle> title();
    GProperty<PersonGender> gender();
    GProperty<PersonMaritalStatus> maritalStatus();
}

In this case, we can use "dynamic proxies" (from java.lang.reflect), to access our bean properties, rather than looking them up using string literal references eg. via BeanInfo. Our proxy object will use the Method name to look up the property.

Also, we have the option of not creating a backing bean for starters, which lends itself towards rapid prototyping, since the above property interface is clearly quite concise.



Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds