[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Property lookup interceptors

alesj do-not-reply at jboss.com
Fri Jul 20 08:37:01 EDT 2007


"adrian at jboss.org" wrote : 
  | But I don't think the value factory needs to know the default value,
  | it just returns "null" when it doesn't have the property.
  | 
  |   | <property name="x">
  |   |    <value-factory bean="LDAPLookup" method="getValue" default="mydefault">
  |   |       <parameter>foo.bar.prop</parameter>
  |   |    </value-factory>
  |   | </property>
  |   | 
  | 
Value factory can take as many parameters as it wants, and return whatever you implement.
What I meant was that LDAPLookup is something like this:

  | public class LDAPLookup {
  | 
  |    public String getValue(String key, String default)
  |    {
  |       String value = LDAP.lookup(key);
  |       return value != null ? value : default;
  |    }
  | 
  | }
  | 

So your version would just be:

  | public class LDAPLookup {
  | 
  |    public String getValue(String key)
  |    {
  |       return getValue(key, null);
  |    }
  | 
  |    public String getValue(String key, String default)
  |    {
  |       String value = LDAP.lookup(key);
  |       return value != null ? value : default;
  |    }
  | 
  | }
  | 

"adrian at jboss.org" wrote : 
  | We should probably still have the shorthand mechanism for simple one
  | parameter methods.
  | 
  | 
  |   | <property name="x">
  |   |    <value-factory bean="LDAPLookup" method="getValue" parameter="foo.bar.prop" default="mydefault"/>
  |   | </property>
  |   | 
  | 
That sounds reasonable.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4066168#4066168

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4066168



More information about the jboss-dev-forums mailing list