|
From: Colin S. <col...@ex...> - 2003-11-21 17:05:32
|
Rod Johnson wrote:
>>Of course, the variant to adding more and more mechanisms to access
>>other objects is to put in some (optional) support for an expresion
>>language inside the bean factory. I've been thinking about this for a
>>while now.
>>
>>
>+1
>
>
>
>>So assuming that there is a generic expression language plugin facility,
>>and which expression language to use is denoted by a prefix, a
>>hypothetical OGNL example for your case would be:
>>
>><bean id="myBean" class="org.me.myClass">
>> <property
>>
>>
>>
>name="myProp"><expr>ognl:@System@getProperties()['my.property.name']</expr><
>/property>
>
>
>></bean>
>>
>>And if you expose the current factory into the OGNL context, then you
>>could have expressions such as:
>>
>><bean id="myBean" class="org.me.myClass">
>> <property
>>
>>
>>
>name="myProp"><expr>ognl:factory.getBean('another-bean-id').someProperty</ex
>pr></property>
>
>
>></bean>
>>
>>
>
>I think it's important that we don't sink under steady feature creep of
>supporting more and more single-scenario solutions. So a more general
>solution would be better.
>
>Another 1.1 feature, perhaps.
>
>
>
There is of course a tradeoff here, where you want to cover the guy
using a basic BeanFactory in an Applet or somewhere like that where
every last byte counts, and get him a minimal set of functionality, but
for the cases where size is not as much of an issue, there are more
powerful/general solutions.
In this particular case (getting a system property), I think this will
be able to be handled by the MethodCallFactoryBean I am writing right
now, in a slightly more verbose fashion...
<bean id="sysProps"
class="org.springframework.beans.factory.config.MethodCallFactoryBean">
<property
name="staticMethod"><value>java.lang.System.getProperties</value></property>
</bean>
<bean id="mySystemProp"
class="org.springframework.beans.factory.config.MethodCallFactoryBean">
<property name="target"><ref local='sysProps'/></property>
<property name="targetMethod"><value>getProperty</value></property>
<property name="args">
<list>
<value>my.property.name</value>
</list>
</bean>
So this would cover people using a base beanfactory, while people
willing to bring in a real expression processor, would have more concise
mechanisms...
|