jboss-weld

What are the best debugging tricks with Weld/CDI?

点点圈 提交于 2019-12-02 18:09:32
One of the beauties with Java EE 6 is the new dependency injection framework - CDI with the Weld reference implementation - which has prompted us to start migrating internally to JSR-330 in an implementation agnostic manner, with the explicit target of being able to have a core jar which is frozen, and then being able to add extra jars providing new modules replacing functionality in the core jar. I am now in the process of making the above work with Weld, and to be frank there is simply too much magic going on behind the covers. Either it works or it doesn't, and it doesn't provide very much

Inject list of objects in CDI (Weld)

落爺英雄遲暮 提交于 2019-12-02 16:36:54
Let's say I have an interface called SocialNetworkService , and three implementations - TwitterService , FacebookService and FriendFeedService . Now I want, whenever my managed bean (or whatever web component) receives a message, to share it in all social networks. I tried: @Inject private List<SocialNetworkService> socialNetworkServices; But it didn't work (deployment error). (Also tried to the @Any qualifier - same result) So, is there a way to inject a list of all (or some) implementations of an interface? I know the rule that a given injection point should not have more than one possible

JBoss 7.1 Weld finds Managed Bean in a jar in the ear, but the war does not

半世苍凉 提交于 2019-12-02 13:10:30
问题 jboss-as-7.1.1, dynamic web module 3.0, JSF 2.0 (Mojarra), Eclipse Indigo sr2 I have an EAR, Ynale.ear, which contains a YnaleImpl.jar and a Ynale.war: Ynale.ear |-YnaleWeb.war | |-META-INF | | |-MANIFEST.MF: | | Manifest-Version: 1.0 | | Class-Path: deployment.Ynale.ear.YnaleImpl | | | |-WEB-INF | | |-beans.xml | | | (empty) | | | | | |-faces-config.xml: | | | <?xml version="1.0" encoding="UTF-8"?> | | | <faces-config version="2.0" | | | xmlns="http://java.sun.com/xml/ns/javaee" | | | xmlns

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.

JBoss 7.1 Weld finds Managed Bean in a jar in the ear, but the war does not

爱⌒轻易说出口 提交于 2019-12-02 03:15:54
jboss-as-7.1.1, dynamic web module 3.0, JSF 2.0 (Mojarra), Eclipse Indigo sr2 I have an EAR, Ynale.ear, which contains a YnaleImpl.jar and a Ynale.war: Ynale.ear |-YnaleWeb.war | |-META-INF | | |-MANIFEST.MF: | | Manifest-Version: 1.0 | | Class-Path: deployment.Ynale.ear.YnaleImpl | | | |-WEB-INF | | |-beans.xml | | | (empty) | | | | | |-faces-config.xml: | | | <?xml version="1.0" encoding="UTF-8"?> | | | <faces-config version="2.0" | | | xmlns="http://java.sun.com/xml/ns/javaee" | | | xmlns:xi="http://www.w3.org/2001/XInclude" | | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | | |

CDI Extensions - Add Interceptors in ProcessAnnotatedType phase

核能气质少年 提交于 2019-12-01 13:18:39
I am trying to add an interceptor programatically. The interceptor is called LogginInterceptor and just logs the name of method it runs on. When using it with annotation @Interceptors(LogginInterceptor.class) on a method, everything works fine. I am however trying to create CDI Extension that adds this @Interceptors(LogginInterceptor) annotation programatically to every method of a certain class (to be simple). So, try it, I've created class Hello with few methods. When these methods are annotated manually, the LogginInterceptor works and prints the name of the method. However, my code to add

CDI Extensions - Add Interceptors in ProcessAnnotatedType phase

▼魔方 西西 提交于 2019-12-01 10:38:19
问题 I am trying to add an interceptor programatically. The interceptor is called LogginInterceptor and just logs the name of method it runs on. When using it with annotation @Interceptors(LogginInterceptor.class) on a method, everything works fine. I am however trying to create CDI Extension that adds this @Interceptors(LogginInterceptor) annotation programatically to every method of a certain class (to be simple). So, try it, I've created class Hello with few methods. When these methods are

Startup POJO On A Weld/Seam3 Application

≡放荡痞女 提交于 2019-12-01 09:33:09
问题 I'm trying to get a POJO starting on startup within my Weld/Seam3 application but not having much luck. I've tried the following but none of them have worked: @Singleton public class StartupJobs { @Inject private Logger log; public void onStartup(@Observes @Initialized ServletContextEvent event) { log.info("Starting startup jobs"); } public void onStartupTwo(@Observes @Initialized WebApplication webApplication) { log.info("Starting startup jobs"); } } - // Guessing this way is no good as I

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"/>

Dynamically fire CDI event with qualifier with members

淺唱寂寞╮ 提交于 2019-12-01 04:27:58
I'm trying to use CDI events in my backend services, on JBoss AS6 - ideally with maximum code reuse. I can see from the docs I can cut down on the qualifier annotation classes I have to create by using a qualifier with members e.g. @Qualifier @Retention(RUNTIME) @Target({METHOD, FIELD, PARAMETER, TYPE}) public @interface Type { TypeEnum value(); } I can observe this with public void onTypeAEvent(@Observes @Type(TypeEnum.TYPEA) String eventMsg) {...} So far, so good. However, to further cut down on the number of classes needed, I want to have one EventFirer class, where the qualifier of the