0

I recently was fascinated by a migration scheme presented by the Talend http://coders.talend.com/ (I guess) via talk record here and presentation from the talk made by Andrei Shakirin. I'va seen a lot publications made by his colleague Christian Schneider as well.

And, of course, the part of the subject matter is Christian's blueprint-maven-plugin. The presentation linked above says how it is possible to continuously deploy same code base to either common Java EE container like Tomcat and to OSGi container like Karaf which is exactly what I am interested in (not Tomcat but Wildfly or Glassfish for instance) So, I wonder:

  1. How blueprint-maven-plugin handles @Stateful, @Stateless annotations and @ApplicationScoped, @SessionScoped, @RequestScoped etc. on beans while producing blueprint file
  2. Also, say I have a new code to write which would use CDI and I want that to be also deployable to Karaf. How should I then write that piece? Should I avoid @Stateful, @Stateless annotations ?
  3. How those annotations (if they for any reason irrelevant for the case when I deploy to OSGi) would be interpreted by that OSGi container (Karaf) since those annotations DO present in the code ?
SoBeRich
  • 682
  • 2
  • 8
  • 15
  • I found this also useful https://stackoverflow.com/a/3568041/8305572 because the context of the questions is about being less coupled to particular container / environment .. even when we skeak about OSGi vs. Non-OSGi deployment. And @ST.Kee 's answer of course I belive would become the answer as there are no more of them. – SoBeRich Feb 12 '18 at 18:52

1 Answers1

0
  1. After a quick scan on the maven-blueprint-plugin source code. Seems like EJB annotations Stateless,Stateful and *Scope isn't handled by the plugin.
  2. @Stateless and @Stateful isn't really part of CDI but an extension to it (EJB). If you really love what EJB do, consider using the OpenEJB feature in karaf. You should be able to do @Inject without these annotation as long as that is a valid bean.

  3. Annotations are just a marker to source code (in other word, they don't do anything), it doesn't do anything unless there's a processor registered to handle them.

E.g. you can instantiate an EJB with new keyword and perform unit test on it (fulfill all injection with setter of course)

Disclaimer: I don't really use this plugin myself, and there might be a newer version of plugin support these ejb annotations.

ST. Kee
  • 256
  • 2
  • 8