jsr299

How to inject objects of the same class with different scopes?

时光总嘲笑我的痴心妄想 提交于 2019-12-20 06:25:01
问题 In terms of simplicity and correctness, what is the best way to inject objects of the same class with different scopes? In a servlet I want to have injected objects of the same class with different scopes. Still don't know if going to use jsf. Simplicity: Making a Qualifier and a producer method for each scope is too much; making an interface, two classes and adding and alternative in beans.xml is also too much; having an Address#isCurrent() method doesn't make sense. Correctness: JSR299, 3

how to instantiate more then one CDI/Weld bean for one class?

佐手、 提交于 2019-12-19 06:46:20
问题 In Spring it was possible to instantiate any class by defining the corresponding bean in xml conf. It was also possible to instantiate more then one bean for the same class with different parameters..... Are the such features in CDI as well, namely is it possible to create different instances of the same class with different initialization parameters? Is it also possible to create a bean without changing the class....I mean without adding annotation? ADDED Let me make an example. <bean id=

how to instantiate more then one CDI/Weld bean for one class?

陌路散爱 提交于 2019-12-19 06:46:08
问题 In Spring it was possible to instantiate any class by defining the corresponding bean in xml conf. It was also possible to instantiate more then one bean for the same class with different parameters..... Are the such features in CDI as well, namely is it possible to create different instances of the same class with different initialization parameters? Is it also possible to create a bean without changing the class....I mean without adding annotation? ADDED Let me make an example. <bean id=

Can Spring understand @Inject replacing Weld as a JSR-299 implementation?

雨燕双飞 提交于 2019-12-10 13:38:11
问题 I have noticed from several web pages that apparently Spring 3.0 supports @Inject from JSR-330. As we would really like to use JSR-299 syntax for dependency injection in our libraries for both web apps and stand-alone applications, and have alternatives to Weld, it would be nice if Spring could do this. Being a novice to Spring, I tried downloading the Spring Framework distribution and put all jars on the Eclipse build path. No Inject annotation so my existing test project using Weld did not

How to inject objects of the same class with different scopes?

纵然是瞬间 提交于 2019-12-02 09:50:31
In terms of simplicity and correctness, what is the best way to inject objects of the same class with different scopes? In a servlet I want to have injected objects of the same class with different scopes. Still don't know if going to use jsf. Simplicity: Making a Qualifier and a producer method for each scope is too much; making an interface, two classes and adding and alternative in beans.xml is also too much; having an Address#isCurrent() method doesn't make sense. Correctness: JSR299, 3.11 says: The use of @Named as an injection point qualifier is not recommended. Still don't know why.

how to instantiate more then one CDI/Weld bean for one class?

柔情痞子 提交于 2019-12-01 05:19:54
In Spring it was possible to instantiate any class by defining the corresponding bean in xml conf. It was also possible to instantiate more then one bean for the same class with different parameters..... Are the such features in CDI as well, namely is it possible to create different instances of the same class with different initialization parameters? Is it also possible to create a bean without changing the class....I mean without adding annotation? ADDED Let me make an example. <bean id="someBean1" class="org.mm.MyBean"> <property name="x" value="xx"/> <property name="y" value="yy"/>

Why use @PostConstruct?

安稳与你 提交于 2019-11-26 00:20:12
问题 In a managed bean, @PostConstruct is called after the regular Java object constructor. Why would I use @PostConstruct to initialize by bean, instead of the regular constructor itself? 回答1: because when the constructor is called, the bean is not yet initialized - i.e. no dependencies are injected. In the @PostConstruct method the bean is fully initialized and you can use the dependencies. because this is the contract that guarantees that this method will be invoked only once in the bean