|
From: Colin S. <col...@ex...> - 2003-11-21 03:00:21
|
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?
|