quality@glassfish.java.net

semi-OT: EJB approach resembling OSGi (declarative) services?

From: Kristian Rink <rink_at_planconnect.de>
Date: Mon, 09 Mar 2009 08:37:38 +0100

Folks;

semi-OT as this is more of an EJB(3.x) than an actual glassfish-related
question, maybe I'll however find someone out here capable of providing me
with some input on that: I am generally promoting EJB 3.x as the technology
of choice for server-sided applications, and so far I haven't indeed seen
much up to this, but this weekend I've been into discussion with some fellow
developers who do server-sided OSGi, and at least in terms of services they
do have a pretty good set of tools at hand[1] I have to say:

1. At first, in there I see a pretty good way of defining modules that
depend upon services and dealing with these dependencies, i.e. saying module
(a) requires a service provided by module (b), module (a) never will be
started before module (b) because the service is not available, and module
(a) immediately will go "down" (or to some defined error state) whenever
module (b) and, thus, the service required from that disappears at runtime.


2. I learnt that, in OSGi, there's also a way of defining service
dependencies with a given cardinality, i.e. saying that a class in module
(a) depends upon 1 .. n implementations of a given interface provided by
other modules, both making module (a) not start / fail as long as there is
not at least 1 implementation of this service available, but also, which is
way more elegant in my opinion, making module (a) dynamically register any
other implementation of the desired interface with the class requiring them.


Building something to resemble point (1) so far I have found to be pretty
straightforward with EJB at least to the point to make an EJB automatically
search and, eventually, re-attach another EJB reference as soon as it "got
lost" (i.e. the service providing this application has been restarted). Yet,
so far I have no idea how to do (2) in EJB - how to, say, make an EJB
(optionally) depend upon a couple of other EJBs implementing a given
interface, discovering all of them at runtime, and, in best case, also
"getting to know" newly added implementations of the same interfaces
whenever they appear...

What do you think? Is something like this possible in EJB 3.x? Any
meaningful workarounds? What are your thoughts?

Cheers and thanks in advance,
Kristian


[1]http://www.eclipsezone.com/eclipse/forums/t97690.rhtml


-- 
Kristian Rink
cell    :  +49 176 2447 2771
business: http://www.planconnect.de
personal: http://pictorial.zimmer428.net
"Past midnight. Never knew such silence.
The earth might be uninhabited..."
//beckett / krapp's last tape//