|
From: Rod J. <rod...@in...> - 2003-11-21 07:30:39
|
I really like this idea. No Spring dependency.
I would pull the factory method and class into different XML elements.
Or possibly use a generic factory bean that took the static factory class
and method and optionally args and meant that there was no need for new XML
or changes to existing code. In fact it would be trivial to implement right
now.
<bean id="whatever" class="GenericWhateverFactoryBean" >
<property name="staticFactory"><value>a.b.c.....
<property name="staticMethod"><value>myFactory
It could even work out the type.
Rod
----- Original Message -----
From: "Colin Sampaleanu" <col...@ex...>
To: <spr...@li...>
Sent: Friday, November 21, 2003 3:01 AM
Subject: Re: [Springframework-developer] In BeanFactory, ref to another
bean's properties, not to the other bean directly
> How about this for constructing beans via a static factory method
>
> <bean id="whatever">
> <static-factory method="a.b.c.d.MyClass.myFactory"/>
> </bean>
>
> which would cover static methods with no args. A second step would be:
>
> <bean id="whatever">
> <static-factory method="a.b.c.d.MyClass.myFactory">
> <arg> ... </arg>
> <arg> ... </arg>
> </static-factory>
> </bean>
>
> where arg is basically the same thing as constructor-arg in the current
> dtd...
>
>
> Colin Sampaleanu wrote:
>
> > I keep on running into the case where in defining a bean in a bean
> > factory or context, I need to set a property to the value of a
> > property from another bean, not the bean itself. How are people
> > typically handling this limitation?
> >
> > For that matter, it would be very useful to be able to get a bean into
> > the container via an expression. I am for example using the CCPP
> > processing API from Sun. All the classes use a factory to get a bean
> > instance. So if I need a ProfileFactory, I get one with this code,
> > calling a static method:
> > ProfileFactory pf = ProfileFactoryImpl.getInstance();
> > I have some beans in a context which need this passed in. I would
> > handle this right now by defining a new class which is a FactoryBean,
> > and returns the result of the above, but that's kludgy. Now handling
> > any kind of generic code of this sort needs an expression evaluator,
> > but I think this particular idiom (a static method call on a class)
> > could probably be handled in a simpler fashion, built-in?
> >
> > What do you guys think?
>
>
>
>
>
>
> -------------------------------------------------------
> 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
>
|