user5182503
user5182503

Reputation:

Business logic: EJB vs OSGi declarative services

I know that EJB is de facto standard in enterprise applications for business logic. However, osgi declarative services can do a lot of things which EJB do. Both are managed by container, both can be used as singleton, both can be used with CDI. The differences which I found are:

  1. EJB has already RMI mechanism but DS don't.
  2. EJB has thread pool but DS don't
  3. DS can require only OSGi but EJB requires JavaEE container (for example if we develop standalone application using JavaEE container will be difficult. Because it will either lead to performance overhead or to necessity to extract EJB container from JavaEE implementation (exm glassfish).

What are other important advantages of EJB explaining its using as standard?

EDIT:
The reason why I asked this question is the following - we want to develop some business logic which can be used both for SE and EE platform. That's why DS seem to be a better solution. However EJB and DS are two universes and we are afraid of missing something important.

Upvotes: 4

Views: 992

Answers (3)

JamesT
JamesT

Reputation: 23

OSGi is more for defining the structure of your application where as EJB's are more concerned with handling the logic and letting the container define the structure.

Seeing as your question is in relation to using business logic in both a JEE and Java SE application EJB sounds like the better option especially given that OSGi JEE support isn't yet ready.

In reality I would actually suggest actually using an ESB like mule or WSO2 and just have the business logic that would be shared server-side, extracted out of your Java SE application.

Upvotes: 0

Paul Verest
Paul Verest

Reputation: 63912

Neither.

Make business logic non dependent on either of those technologies, as they would limit your choices, and you already know you need to run on Java SE.

Good written business logic would have little dependencies and well tested with Unit Test.

And the resulted module jars can be used for both Java EE, and OSGi . If you need to support both, you would have to go with minimal set of common features.

What are other important advantages of EJB explaining its using as standard?

POJO is also standard, but absolute not complicated approach.

Upvotes: 1

Christian Schneider
Christian Schneider

Reputation: 19606

I did a talk at Apachecon 2015 about Enterprise applications on OSGi. It covers mainly DS vs blueprint as Java EE support is not yet fully ready on OSGi. Still you should find the main enterprise use cases and how to do them in DS.

See http://www.slideshare.net/ChristianSchneider3/osgi-productivity-compared-on-apache-karaf

Upvotes: 3

Related Questions