jboss-weld

CDI: beans.xml, where do I put you?

风格不统一 提交于 2019-11-27 00:36:35
I am using Weld as CDI implementation. My integration test, that tries to assemble object graph instantiating Weld container works well , when I have empty beans.xml in src/test/java/META-INF/beans.xml . Here is that simple test: public class WeldIntegrationTest { @Test public void testInjector() { new Weld().initialize(); // shouldn't throw exception } } Now when I run mvn clean install , I always get: Missing beans.xml file in META-INF! My root folders are "src" and "web" which contains WEB-INF folder, but I also tried to use default maven structure and renamed "web" to "webapp" and moved it

Injecting a Spring bean using CDI @Inject

空扰寡人 提交于 2019-11-26 23:09:38
问题 I'm trying to inject a bean defined in a Spring context into a CDI managed component but I'm not successful. The bean is not injected, instead a new instance gets created each time the injection should be performed. My environment is Tomcat 7 with JBoss Weld. The Spring ApplicationContext is straighforward: <beans> ... <bean id="testFromSpring" class="test.Test" /> ... </bean> The CDI managed bean looks like this: @javax.inject.Named("testA") public class TestA { @javax.inject.Inject private

ManagedProperty in CDI @Named bean returns null

旧巷老猫 提交于 2019-11-26 20:14:06
I'm trying to deal with @ManagedProperty but without success ! I've been following this guide, and it not seems that hard. But my code simply won't work! Here's a little snippet @ManagedBean @SessionScoped public class LoginBean { @EJB private LoginUserLocal loginUser; private boolean loggedIn = false; private User user; private StreamedContent image; . . . //-- @Named(value = "messagesBean") @RequestScoped public class MessagesBean { @ManagedProperty(value = "#{loginBean}") private LoginBean loginBean; public LoginBean getLoginBean() { return loginBean; } public void setLoginBean(LoginBean

How to create and destroy CDI (Weld) Managed Beans via the BeanManager?

别说谁变了你拦得住时间么 提交于 2019-11-26 18:29:53
问题 I'm trying to create instances of CDI managed beans using the BeanManager rather than Instance .select().get(). This was suggested as a workaround to an issue I've been having with ApplicationScoped beans and garbage collection of their dependents - see CDI Application and Dependent scopes can conspire to impact garbage collection? for background and this suggested workaround. If you use the Instance programmatic lookup method on an ApplicationScoped bean, the Instance object and any beans

How to create a modular JSF 2.0 application?

試著忘記壹切 提交于 2019-11-26 17:05:23
I have an application with a well defined interface. It uses CDI for resolution of the modules, (Specifically it uses Instance<> injection points on API interfaces to resolve modules) and passes various data back and fourth via the interfaces without issue. I've intentionally kept the API and implementation separate, and the modules only inherit from the API to avoid tight coupling, and the application only knows of the modules through runtime dependancies, and data passing accomplished via the APIs. The application runs fine without the modules, which can be added simply by dropping the jar

Are @ManagedBeans obsolete in JavaEE6 because of @Named in CDI/Weld?

≯℡__Kan透↙ 提交于 2019-11-26 15:54:09
Because of CDI (and its implementation Weld), every POJO in JEE6 can be annotated with @Named , which makes the POJO accessible to the view. Does that mean that ManagedBeans are completely obsolete now? Or did I miss something where @ManagedBean still makes sense? In short, @ManagedBean makes sense for applications that use JSF but do not use JSR 299 (whatever the reason is). Below a longer explanation from Gavin King: Re: Comparisons to @ManagedBean annotations in JSF2? : While looking through the Weld examples, and the older WebBeans documentation, it looks like a competitor to the new

How to programmatically inject a Java CDI managed bean into a local variable in a (static) method

℡╲_俬逩灬. 提交于 2019-11-26 12:26:33
问题 How can I programmatically inject a Java CDI 1.1+ managed bean into a local variable in a static method? 回答1: To inject an instance of class C : javax.enterprise.inject.spi.CDI.current().select(C.class).get() This is available in CDI 1.1+ 回答2: Use for instance this utility class. You basically have to obtain instance of BeanManager and than grab the bean you want from it (imagine something like JNDI lookup). Update You could also use CDI utility class offered in CDI 1.1 SomeBean bean = CDI

CDI: beans.xml, where do I put you?

自闭症网瘾萝莉.ら 提交于 2019-11-26 09:27:36
问题 I am using Weld as CDI implementation. My integration test, that tries to assemble object graph instantiating Weld container works well , when I have empty beans.xml in src/test/java/META-INF/beans.xml . Here is that simple test: public class WeldIntegrationTest { @Test public void testInjector() { new Weld().initialize(); // shouldn\'t throw exception } } Now when I run mvn clean install , I always get: Missing beans.xml file in META-INF! My root folders are \"src\" and \"web\" which

ManagedProperty in CDI @Named bean returns null

爱⌒轻易说出口 提交于 2019-11-26 07:32:46
问题 I\'m trying to deal with @ManagedProperty but without success ! I\'ve been following this guide, and it not seems that hard. But my code simply won\'t work! Here\'s a little snippet @ManagedBean @SessionScoped public class LoginBean { @EJB private LoginUserLocal loginUser; private boolean loggedIn = false; private User user; private StreamedContent image; . . . //-- @Named(value = \"messagesBean\") @RequestScoped public class MessagesBean { @ManagedProperty(value = \"#{loginBean}\") private

How to create a modular JSF 2.0 application?

人盡茶涼 提交于 2019-11-26 05:01:04
问题 I have an application with a well defined interface. It uses CDI for resolution of the modules, (Specifically it uses Instance<> injection points on API interfaces to resolve modules) and passes various data back and fourth via the interfaces without issue. I\'ve intentionally kept the API and implementation separate, and the modules only inherit from the API to avoid tight coupling, and the application only knows of the modules through runtime dependancies, and data passing accomplished via