As I explained in “Inject Java EE Beans into Tapestry-5.x“, the AppModule offers a way to configure Tapestry Web Applications directly in Java. In that post, we injected Java EE Beans into Tapestry applications. This time we do the same with Context and Dependency Injection (CDI) Beans. It follows the same procedure. The only difference is the way of looking up a bean. We still use JNDI for a lookup, but this time we retrieve the CDI BeanManager. In a second step we get the bean. For performance reasons we retrieve the bean only once per Thread (see annotation @Scope). It will be cached for subsequent lookups.
Read More
Tag: Dependency Injection
Inject Java EE Beans into Tapestry-5.x
Tapestry uses it’s own Inversion Of Control (IOC) container. Tapestry pages are not Servlets or Servlet Filter (and not another managed class). Therefore they cannot be used for injection of Java EE Beans. But there is the AppModule, which is conceptual some kind of related to Spring Java Config. It allows to configure the Tapestry application directly in Java. Like everything in Tapestry it has an Adaptive API. Hence you have to follow a naming (signature) pattern for your methods and Tapestry finds them. You don’t have to implement an interface.
Read More
Circular Dependencies of Session Beans via Manual EJB Lookup
In my last two posts (Circular Dependencies of Session Beans and Circular injection of Util Classes in EJB 3.0) I wrote, that it is possible to have circular dependencies between session beans via interceptors and manual EJB lookup. In this post I will sketch out how.
Read More
Circular Injection of Util Classes in EJB 3.0
In my last post Circular Dependencies of Session Beans I presented a method to use interceptors in session beans in order to inject beans. This works great until you want to add circular dependencies. Then you have to look up the beans by name and inject them into the bean. But this is kind of cumbersome. So, if it is possible, have a bean structure, which is topologically sortable and inject util classes having circular dependencies between each other. This post shows how to achieve the latter.
Read More
Transaction Propagation for Remote calls
I didn’t find a clear statement whether transactions are propagated for remote calls in Java EE 5. So I tested it by creating two enterprise applications being deployed in different ears to the same JBoss-5.1.0-GA. In short: YES, the transaction is propagated and a rollback on a calling method initiates a rollback on the remote transaction, too. The willing reader might read on in order to get to know the test setup. Read More