Mutual EJB possible?

V

Vjeran Marcinko

Hi folks.
I'm really fresh in EJB stuff, so at first I thought it was just another heavyweight framework, but more I think about it it seems that it is not suitable for every kind of application ...but moew like for stateless (due to nature of HTTP protocol) kind of web apps.

Anyway, is it possible to create something like singleton EJB ? I don't need referencing it through static accessor SingletonClass.getInstance(), I would fetch it from JNDI context, but I need just one instance of it to exist in EJB container ...
More concretly - let's say I want to make some 'ChatRoom' EJB, which would hold references of all connected clients, so it could dispatch messages to all room chatters when some message is placed into chat room ? Is EJB not meant to be used for this kind of applications ?

Regards,
Vjeran
 
M

Michael Borgwardt

Vjeran said:
Anyway, is it possible to create something like singleton EJB ? I don't need referencing it
through static accessor SingletonClass.getInstance(), I would fetch it from JNDI context, but
I need just one instance of it to exist in EJB container ...

In that case, EJB isn't really what you need. At least not the way you seem to plan.

More concretly - let's say I want to make some 'ChatRoom' EJB, which would hold references of all
connected clients, so it could dispatch messages to all room chatters when some message is placed
into chat room ? Is EJB not meant to be used for this kind of applications ?

No, it would be serious overkill and a lot of unnecessary hassle.

EJBs only make sense when you can actually profit from their unique features,
namely the easy clustering and declarative transaction and security management.
 
V

Vjeran Marcinko

Michael Borgwardt said:
No, it would be serious overkill and a lot of unnecessary hassle.

EJBs only make sense when you can actually profit from their unique features,
namely the easy clustering and declarative transaction and security management.

I am user of lightweight frameworks such as Avalon, HiveMind etc... and I thought that people avoid EJBs just because it's too complex to learn and use for everyday needs, but now I see that complexity is not it's only disadvantage, but they also aren't suited for all kind of apps. For instance, "singleton" EJBs would be necessary for apps like chat server where you must have some mutual components for all connected clients.
I agree that for well-suited apps would EJBs offer great part of built-in functionality. Some of them you named above.

Cheers,
Vjeran
 
M

Michael Borgwardt

Vjeran said:
I am user of lightweight frameworks such as Avalon, HiveMind etc... and I thought that people avoid EJBs
just because it's too complex to learn and use for everyday needs, but now I see that complexity is not
it's only disadvantage, but they also aren't suited for all kind of apps. For instance, "singleton"
EJBs would be necessary for apps like chat server where you must have some mutual components for all
connected clients.

Actually, I think that Message-driven EJBs might be just right for that general type of
application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top