cdi

How to retrieve class of generic argument in a CDI producer?

こ雲淡風輕ζ 提交于 2019-12-25 06:57:48
问题 I have a Java class with a generic type. In the business logic of that class, I need to refer to the Class object of the generic type. Therefore, the constructor get the Class object passed as argument: public class MyClass<GENERIC_TYPE>{ private Class<GENERIC_TYPE> genericTypeClass; public MyClass(Class<GENERIC_TYPE> genericTypeClass){ this.genericTypeClass=genericTypeClass; } } I create the instance(s) of this class using a CDI producer, whose squeleton looks like public class

CDI Weld and AspectJ - org.jboss.weld.exceptions.UnproxyableResolutionException

空扰寡人 提交于 2019-12-25 06:32:10
问题 I get this error when using AspectJ and CDI. org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001437 Normal scoped bean class myPackageName.myClassName is not proxyable because the type is final or it contains a final method static final java.lang.String myPackageName.myClassName.myMethodName_aroundBody0(myPackageName.myClassName.,org.aspectj.lang.JoinPoint). If I remove AspectJ it works, but I don't want that. Please Help. 回答1: I got an answer from AspectJ's mailing list, they

Storing a http session attribute in database

不问归期 提交于 2019-12-25 05:52:10
问题 How can I pass an injected http session attribute (see below), along with other values (informe by the user) and save them using JPA? The session attribute is correctly displayed and injected, but I need to pass it using the selected to be stored in the database (actually, it passess null). The JSF: <p:outputLabel value="UserID (the sessionAttribute):" for="userID" /> <p:inputText id="userID" value="#{userBean.myUser.xChave}" title="userID" /> <p:outputLabel value="Type the Reason:" for=

Storing a http session attribute in database

南笙酒味 提交于 2019-12-25 05:52:03
问题 How can I pass an injected http session attribute (see below), along with other values (informe by the user) and save them using JPA? The session attribute is correctly displayed and injected, but I need to pass it using the selected to be stored in the database (actually, it passess null). The JSF: <p:outputLabel value="UserID (the sessionAttribute):" for="userID" /> <p:inputText id="userID" value="#{userBean.myUser.xChave}" title="userID" /> <p:outputLabel value="Type the Reason:" for=

Re-inject CDI bean if some injected property changed

你。 提交于 2019-12-25 03:03:01
问题 I have a bean BeanA with injected property private int url : class BeanA { @Value(${"db.url"}) private String url; private DbConnection connection; } Let us say this Value annotation is similar to Spring Value . During initialization, connection will be initialized by using injected property into url field. And also there is some PostConstruct and PreDestroy methods in BeanA . My question is: is it possible to dynamically reinstantiate BeanA when url property changed. I have mechanism of

Vaadin: CDI Inject is null after referencing

感情迁移 提交于 2019-12-25 00:59:20
问题 Good day. There is an application (using a CDI add on): @VaadinScoped(VaadinScope.APPLICATION) public class AdminApplication extends AbstractCdiApplication { @Inject private Instance<Lang> lang; @Override public void init() { setMainWindow(new LoginWindow(this)); } public void authenticate(String login, String password) throws Exception { lang.get(). ... } ... And the LoginWindow: public class LoginWindow extends Window { ... public LoginWindow(AdminApplication application) { super(

Java EE 7 containers: initialize bean at startup without adding it to beans.xml?

一世执手 提交于 2019-12-24 20:01:16
问题 Is there any bean type or Java EE annotation to get a bean initialized at container startup without adding the bean to beans.xml? 回答1: Yes, there is. This is what I use when I need a singleton, application scoped bean started on deploy: import javax.ejb.Singleton; import javax.ejb.Startup; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import javax.annotation.PostConstruct; @Named( "myBean" ) @ApplicationScoped @Startup @Singleton public class MyBean {

CDI Beans Serialization issue on Cluster

本小妞迷上赌 提交于 2019-12-24 17:28:22
问题 I'm facing a big issue when I tried to run my EJB+CDI+JSF application on Wildfly 9.2 (Also I tried 10.0) on Standalone Clustered mode. The issue happens when my cluster container tries to deserialize my session scoped CDI beans, it throws the following exception : 2016-02-06 02:17:22,650 ERROR [io.undertow.request] (default task-9) UT005071: Undertow request failed HttpServerExchange{ GET /login.xhtml request {Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8]

@InterceptorBinding / CDI/ EJB 3.2 - problems with injection

匆匆过客 提交于 2019-12-24 17:00:14
问题 My dev environment is: WildFly 8.1, CDI, EJB 3.2, JDK 1.7. App is packed as an ear archive (one ejb + one war) because probably it gonna have other web modules in the future. I'm struggling with a custom @InterceptorBinding type used inside my EJB stateless bean. @Inherited @InterceptorBinding @Target({ TYPE, METHOD }) @Retention(RUNTIME) @Documented public @interface DetectIntegrityConstraintsViolation { } @javax.annotation.ManagedBean // make it a CDI bean. @Interceptor itself should be

CDI-Unit @Produces not working

送分小仙女□ 提交于 2019-12-24 11:36:11
问题 First off I googled intensively and according to http://jglue.org/cdi-unit-user-guide/ producing stuff to inject in a unit test should work just fine. My setup: @RunWith(CdiRunner.class) public abstract class CdiUnitBaseTest extends DBUnitBaseTest { @Produces public EntityManager em() { return em; //field from base class filled @BeforeClass } @Produces public Logger logger() { return LogManager.getLogger(); } } public class SurveyBeanTest extends CdiUnitBaseTest { @Inject private SurveyBean