Inject EJB into domain object with Java EE 6
How can I inject an EJB into a domain object (an JPA entity) with Java EE 6? ...
How can I inject an EJB into a domain object (an JPA entity) with Java EE 6? ...
I know it is still not quite popular, since the spec was released just a few months ago. I haven't "installed" weld yet, I'm just reading, and by this question I want to make sure I've understood this important point correct: Is resolution of beans that are in 3rd-party jars achieved by declaring them as <alternatives> in your beans.xm...
I've looked at JBoss' Weld Reference Implementation of JSR-299 Contexts and Dependency Injection, and I wanted to know how others CDI implementations compare to each other. Specifically, I know about Weld, Resin CanDI (by Caucho), and Apache OpenWebBeans. ...
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 initializ...
I'm reasonably new to JEE, so this might be stupid.. bear with me pls :D I would like to inject a stateless session bean into a message-driven bean. Basically, the MDB gets a JMS message, then uses a session bean to perform the work. The session bean holds the business logic. Here's my Session Bean: @Stateless public class TestBean im...
Hi I came from the Spring camp , I don't want to use Spring , and am migrating to JavaEE6 , But I have problem testing DAO + JPA , here is my simplified sample : public interface PersonDao { public Person get(long id); } This is a very basic DAO , because I came from Spring , I believe DAO still has its value , so I decided to add...
Since EJB 3 we have embeddable EJB containers, JPA implementations can be used without an application server, there is Weld for contexts and dependency injection and so on. Since on many systems is only Tomcat available, I wonder, if Java EE could be used without an application server but with a Servlet container like Tomcat. What woul...
I have played with the JSR-299 Reference Implementation "Weld" with the purpose of using it in a stand-alone application, and I have had a look at the documentation, and marveled at the magic. My question is how the producer of a given object to be @Inject'ed is found? Either the java compiler produces hints for annotations which is ea...
Weld, the JSR-299 Contexts and Dependency Injection reference implementation, considers itself as a kind of successor of Spring and Guice. CDI was influenced by a number of existing Java frameworks, including Seam, Guice and Spring. However, CDI has its own, very distinct, character: more typesafe than Seam, more stateful and less X...
I'm using the new JSF2 <h:link> tag, with a nested <f:param> to link to a page using a get request. However, the conversation id (cid) is propagated via the query parambeters of the link to the new page. Can one suppress the conversation propagation with an <h:link>? ie. no cid=# in the url...? ...
Hi. I am trying to replace standard logger initialization by some injection 1-st. I was trying to use weld weld logging in stateless bean/webservices @Stateless @WebService public class EchoSSL { @Inject private Logger log; public EchoSSL() { } public String echo(String msg) { log.debug("Log test"); ...
I've got an app that is trying to use @EJB annotation to inject remote references to EJBs in my ejb.jar file. I'm getting inconsistent results. In one case, I have a listener in web.xml that gets called and apparently has the EJB injected correctly, since I can see it connecting to the EJB and calling methods on it. In another class (...
How can I use JSR-299 CDI to inject (not annotated) beans from external libraries? Examples: Interface X and its implementations come from a third party lib. How can I decide which implementation to use? class A { @Inject private X x; } What if I had several classes using the X interface but different implementations? cl...
Is there a way (in JSF 2) to catch a Conversation timeout and redirect a user to a new page? I'm getting nasty NullPointerExceptions when the conversation times out. I could redirect the user on all NPE's, but that seems like too big a net. ...
I was reading a Wikipedia article about Java EE application servers here: http://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition#Java_EE_5_certified It says that 2 APIs that Java App Services implement are: javax.enterprise.inject javax.enterprise.context These both relate to application context and dependency injection JSR-...
I would like to use RESTful services in a CDI/JSF2 application. I am not very familiar with JAX-RS however I have read that its lifecycle does not play well with CDI/JSF2. Is it possible to incorporate JAX-RS with CDI/JSF2 in a JEE6 stack? If not are there alternatives? thanks ...
I want to create a Producer that makes it possible to inject a java.util.ResourceBundle into any class in order to get localized Strings easily. My ResourceBundle-Producer looks like this: public class ResourceBundleProducer { @Inject public Locale locale; @Inject public FacesContext facesContext; @Produces p...
JSR-299 (CDI) introduces the (unfortunately named) concept of a resource: http://docs.jboss.org/weld/reference/1.0.0/en-US/html/resources.html#d0e4373 You can think of a resource in this nomenclature as a bridge between the Java EE 6 brand of dependency injection (@EJB, @Resource, @PersistenceContext and the like) and CDI's brand of dep...
I would like to have a central weld container that holds all my services and so on. This container would however be wrapped by a second container which contains local settings. The goal is if a dependency cannot be found in the outer container then I would like to then search the inner container. How can I achieve this? I would prefer t...
I like the way Guice makes it fairly straight forward to manually create your own modules each with their own bindings done in code. CDI on the other hand seems to rely more on magic rather than programmatic access to sest bindings. Am i wrong or how can one achieve the same effect with WELD. Any code sample would be appreciated... CLA...