|
From: Colin S. <col...@ex...> - 2003-11-21 23:54:03
|
As per a previous message, I have added a new FactoryBean implementation
called MethodCallFactoryBean. It's a factory bean which will return the
result of a method call, either on a static class method as specified
via a fully qualified method name
package1.package2.package3.ClassName.MethodName
or alternately the result of a method call on a ref bean in the context.
The factory bean has an internal singleton property, which is true by
default. In this case, the method is only called the first time, and
subsequent invocations of getObject() on the factory will return the
exact same result. If the singleton property is set to false, then the
target method will be invoked on each call to getObject() on the bean.
The following is an example of using the new factory bean to get at a
system property:
<bean id="sysProps"
class="org.springframework.beans.factory.config.MethodCallFactoryBean">
<property
name="staticMethod"><value>java.lang.System.getProperties</value></property>
</bean>
<bean id="javaVersion"
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>|java.version|</value>
</list>
</property>
</bean>
I just realized that most of Spring refers to method invocations, not
method calls. Would people prefer that this class be called
MethodInvocationFactoryBean instead?
Does anybody think the default value for the singleton property should
be false instead of true? My feeling is that most of the time this will
be used to call factories, so you would not want to do a method call on
each getBean() call...
Regards,
Colin
|
|
From: Rod J. <rod...@in...> - 2003-11-22 00:02:09
|
>I just realized that most of Spring refers to method invocations, not method calls. Would people prefer that this class be called MethodInvocationFactoryBean instead? Yes. Probably singleton should default to true, but it would need to be well documented as this could confuse people in odd cases if they didn't realise there was caching. Regards, Rod ----- Original Message ----- From: "Colin Sampaleanu" <col...@ex...> To: <spr...@li...> Sent: Friday, November 21, 2003 11:54 PM Subject: [Springframework-developer] MethodCallFactoryBean added > As per a previous message, I have added a new FactoryBean implementation > called MethodCallFactoryBean. It's a factory bean which will return the > result of a method call, either on a static class method as specified > via a fully qualified method name > package1.package2.package3.ClassName.MethodName > or alternately the result of a method call on a ref bean in the context. > > The factory bean has an internal singleton property, which is true by > default. In this case, the method is only called the first time, and > subsequent invocations of getObject() on the factory will return the > exact same result. If the singleton property is set to false, then the > target method will be invoked on each call to getObject() on the bean. > > The following is an example of using the new factory bean to get at a > system property: > > <bean id="sysProps" > class="org.springframework.beans.factory.config.MethodCallFactoryBean"> > <property > name="staticMethod"><value>java.lang.System.getProperties</value></property> > > </bean> > <bean id="javaVersion" > 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>|java.version|</value> > </list> > </property> > </bean> > > I just realized that most of Spring refers to method invocations, not > method calls. Would people prefer that this class be called > MethodInvocationFactoryBean instead? > > Does anybody think the default value for the singleton property should > be false instead of true? My feeling is that most of the time this will > be used to call factories, so you would not want to do a method call on > each getBean() call... > > Regards, > Colin > > > > > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Colin S. <col...@ex...> - 2003-11-22 00:47:29
|
I've actually renamed it to MethodInvokingFactoryBean, which is hopefully better all around. Docs are now very specific about the singleton default. If anybody else thinks it should not be singleton by default, feel free to speak up. Rod Johnson wrote: >>I just realized that most of Spring refers to method invocations, not >> >> >method calls. Would people prefer that this class be called >MethodInvocationFactoryBean instead? >Yes. > >Probably singleton should default to true, but it would need to be well >documented as this could confuse people in odd cases if they didn't realise >there was caching. > >Regards, >Rod > >----- Original Message ----- >From: "Colin Sampaleanu" <col...@ex...> >To: <spr...@li...> >Sent: Friday, November 21, 2003 11:54 PM >Subject: [Springframework-developer] MethodCallFactoryBean added > > > > >>As per a previous message, I have added a new FactoryBean implementation >>called MethodCallFactoryBean. It's a factory bean which will return the >>result of a method call, either on a static class method as specified >>via a fully qualified method name >> package1.package2.package3.ClassName.MethodName >>or alternately the result of a method call on a ref bean in the context. >> >>The factory bean has an internal singleton property, which is true by >>default. In this case, the method is only called the first time, and >>subsequent invocations of getObject() on the factory will return the >>exact same result. If the singleton property is set to false, then the >>target method will be invoked on each call to getObject() on the bean. >> >>The following is an example of using the new factory bean to get at a >>system property: >> >> <bean id="sysProps" >>class="org.springframework.beans.factory.config.MethodCallFactoryBean"> >> <property >> >> >> >name="staticMethod"><value>java.lang.System.getProperties</value></property> > > >> </bean> >> <bean id="javaVersion" >>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>|java.version|</value> >> </list> >> </property> >> </bean> >> >>I just realized that most of Spring refers to method invocations, not >>method calls. Would people prefer that this class be called >>MethodInvocationFactoryBean instead? >> >>Does anybody think the default value for the singleton property should >>be false instead of true? My feeling is that most of the time this will >>be used to call factories, so you would not want to do a method call on >>each getBean() call... >> >>Regards, >>Colin >> >> >> |