1. Managed Resources

Managed Resource is one of the most important concepts in JEE. Managed Resource Factory is a factory that is governed by Container. Usually it means that Container: takes care of security, administrates, pools, integrates with transaction and provides easy access to Resources. Managed Resource is a resource, for instance a connection, produced by Managed Resource Factory. It is managed by Container. Usually it means that Container reuse resource, if properly used then guarantees synchronized access, can intercept invocations, listens for life cycle changes.

Read More

Advertisement

Usually patterns provide indirections and abstractions, invoker and invokee are separated. This pattern acts opposite, exposes feature that is internal by its nature. Persistence Contexts are internal features of any EJB. The aim is to externalize it, to make it remote, a part of distributed environment.

This pattern was presented in Adam Bien’s Real World Java EE Patterns  – Rethinking Best Practices and contributions belong to the author. The name Gateway comes from this publication.

Read More

Stateful Session Beans are the least use type of EJBs. I saw a few usages of Stateful Session Beans but most of them were improper. Stateful Session Beans are the least understood type of EJBs. What are they for? Or better: show me use cases where Stateful Session Beans are essential solution! The internet gives several answers but not always proper. We will investigate those answers.

Read More

Singleton is the only type of Session Beans that admits concurrent access. This way bottlenecks are avoided. There are two manners of synchronizing access, bean synchronization and container synchronization. Default is container managed synchronization. We spare a few words on container managed synchronization.

Read More

If EJB instance, other than Singleton, throws system exception, which is non application runtime exception, then EJB Container immediately discards the instance without calling @PreDestroy method.

This is not a problem if calling @PreDestroy is not essential to an application. If it is, then it was proposed to provide additional application pool of resources or beans and periodically clean up abandoned resources or beans. We do it other way.

Read More