cdi

OSGI - CDI / is it usable right now ? [Oct 2012]

谁说胖子不能爱 提交于 2020-01-25 15:35:56
问题 I'm quite new to Java EE 6 and OSGI concept, and i'm quite excited about it... The most exciting feature is the dynamic dependancy injection at execution time. I've seen some really great presentation where the application is ajaxly updated when a bundle is activated or unactivated, i like that way of decoupling the application in modules and updated it at run time ... Second though, i'm quite boring about XML configuration files, i think Java EE 6 with javax.inject and others annotations is

OSGI - CDI / is it usable right now ? [Oct 2012]

拟墨画扇 提交于 2020-01-25 15:34:43
问题 I'm quite new to Java EE 6 and OSGI concept, and i'm quite excited about it... The most exciting feature is the dynamic dependancy injection at execution time. I've seen some really great presentation where the application is ajaxly updated when a bundle is activated or unactivated, i like that way of decoupling the application in modules and updated it at run time ... Second though, i'm quite boring about XML configuration files, i think Java EE 6 with javax.inject and others annotations is

What is exactly “container managed object” in Java 6 EE world?

穿精又带淫゛_ 提交于 2020-01-25 05:38:04
问题 I tried to use CDI for my struts action running on glassfish. But java dependency injection does not work for it. It works for JSF but not struts. As I read -- container injects dependencies to any instance of container managed bean (bean created by container). So, what is "container managed bean"? Any POJO? Or only jsf back bean, ejb-bean and so on? And how it happens? Glassfish has special class-loader to inject? 回答1: I only can inject your CDI beans in managed classes. Struts creates its

What is exactly “container managed object” in Java 6 EE world?

故事扮演 提交于 2020-01-25 05:38:03
问题 I tried to use CDI for my struts action running on glassfish. But java dependency injection does not work for it. It works for JSF but not struts. As I read -- container injects dependencies to any instance of container managed bean (bean created by container). So, what is "container managed bean"? Any POJO? Or only jsf back bean, ejb-bean and so on? And how it happens? Glassfish has special class-loader to inject? 回答1: I only can inject your CDI beans in managed classes. Struts creates its

Why am I getting a WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped exception?

戏子无情 提交于 2020-01-24 13:53:26
问题 I've looked at other questions relating to this error on the site but most of them are either about SessionScope or are unanswered. The only possibly helpful one is No active contexts for scope type javax.enterprise.context.RequestScoped when invoking a bean from a thread but it's not in the context I have. I'm running a JAX-RS endpoint on Wildfly 10.1 (Java ee 7). Looks something like this: @Path("") public class ServerResource { @Inject Order order; @Resource ManagedExecutorService mes;

HttpServletRequest injection on RequestScoped bean CDI

一曲冷凌霜 提交于 2020-01-24 10:38:19
问题 I'm looking for a way in order to inject a @RequestScoped custom class into my @Stateless JAX-RS endpoint: I want each time the application receives a request my custom class is injected in my JAX-RS endpoint. Custom class: @RequestScoped public class CurrentTransaction { private String user; private String token; @PersistenceContext(name="mysql") protected EntityManager em; @Inject HttpServletRequest request; public CurrentTransaction() { this.user = request.getHeader("user"); this.token =

HttpServletRequest injection on RequestScoped bean CDI

感情迁移 提交于 2020-01-24 10:38:06
问题 I'm looking for a way in order to inject a @RequestScoped custom class into my @Stateless JAX-RS endpoint: I want each time the application receives a request my custom class is injected in my JAX-RS endpoint. Custom class: @RequestScoped public class CurrentTransaction { private String user; private String token; @PersistenceContext(name="mysql") protected EntityManager em; @Inject HttpServletRequest request; public CurrentTransaction() { this.user = request.getHeader("user"); this.token =

RESTEasy, CDI, embedded Jetty, bean validation is ignored

喜你入骨 提交于 2020-01-24 01:04:07
问题 I've a Groovy project where I use RESTEasy with Weld and deploy to embedded Jetty. What I can't seem to get working is bean validation. RESTEasy documentation says that adding resteasy-validator-provider-11 along with hibernate validator dependencies ( hibernate-validator, hibernate-validator-cdi, javax.el-api, javax.el ) is enough. But the bean validation is simply ignored by RESTEasy. I curiously also get the following message in the logs: plugins.validation.ValidatorContextResolver -

Session Fixation and Session Scoped Beans in JSF 2.3 with CDI

…衆ロ難τιáo~ 提交于 2020-01-23 07:34:11
问题 It's a common best practice to renew the HTTP session when logging in a user. This will force a new session ID, avoiding session fixation vulnerabilities. Is there a preferred pattern for implementing this with CDI when @SessionScoped beans are involved? The difficulty is that by invalidating the current HTTP session, you'll then get a different session-scoped bean with the next request, but not until the next request. For example, assume a session bean for storing user login information:

Viewscoped JSF and CDI bean

廉价感情. 提交于 2020-01-23 05:42:25
问题 I'm using Java EE 6 on JBoss EAP 6, and my JSF beans are annotated like this: @ManagedBean @ViewScoped (both from javax.faces.bean package) However, they are also CDI beans (default constructor, use of @Inject , @PreDestroy etc). I'm reading all the time that you can't mix these annotations (JSF and CDI), but it's apparently working fine: Injections are working, preDestroy is called on view change etc). Am I missing something? What is the problem? Why not use? 回答1: The CDI @Inject works