[jboss-dev-forums] [Design of POJO Server] - Re: Generalizing dependency injection
adrian@jboss.org
do-not-reply at jboss.com
Fri Mar 14 08:05:45 EDT 2008
"scott.stark at jboss.org" wrote : So what is the benefit to BeanFactory over an instance factory on the bean ctor metadata?
I wouldn't describe it as a benefit, its a different semantic.
Factory construction is just an alternate way to construct a singleton
| <bean>
| <constructor factroyClass="x.y.z.A" factoryMethod="create"/>
|
A bean factory creates an object that implements BeanFactory
on which you can call create() to create as many instances as you like:
| <beanfactory name="MyFactory">
| ...
|
| public class MyClass
| {
| @Inject("MyFactory")
| public void setFactory(BeanFactory factory) {}
|
| public void doStuff()
| {
| Object one = factory.create();
| Object two = factory.create();
| }
| }
|
The main usecase of beanfactory so far has been to do dependency injection
into aop's advices.
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/GenericBeanAspectFactory.java?revision=61978&view=markup
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4136619#4136619
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4136619
More information about the jboss-dev-forums
mailing list