Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

CDI With Or Without EJB 3.1

DZone's Guide to

CDI With Or Without EJB 3.1

· Java Zone
Free Resource

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

Java EE 6 comes with EJB 3.1 and CDI. You could work exclusively with EJB 3.1 or CDI, but you will not end up with the simplest possible solution. CDI comes with typesafe and scalable (=start easy, but sky is the limit) DI, events, decorators and "glue" logic.

CDI, however, is missing some EJB 3.1 features:

  1. Timers
  2. Asynchronous, transactional execution with Future support
  3. Pooling: important for throttling and prevention of denial of service attacks
  4. Monitoring - all EJBs are exposed via JMX and can be so monitored with JConsole
  5. Declarative, "Convention Over Configuration" transactions. Without EJB 3 you will end up in a considerable bloat

EJB 3.1 and CDI are both part of Java EE 6. The "KISSiest" thing you can do is to deploy a EJB 3.1 boundary and use e.g. CDI behinds behind.

You could also implement all aspects (transactions, jmx, throttling) by your own - but this would introduce additional complexity to your project (and: don't re-invent the wheel).

From http://www.adam-bien.com/roller/abien/entry/cdi_with_or_without_ejb

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}