EJB questions

  • Thread starter Olivier Scalbert
  • Start date
O

Olivier Scalbert

Hello !

I must write an application used to control several electronic devices
accessed via sockets.This applicationprovides also a lot of other services.
As I need Web client interfaces, log utility, persistence, naming
service, message services, I think I can use EJB technology. It is also
for training and fun!
So I am going to start a little prototype based on jboss.
And of course I have some questions !
In this application, I would like to have a bean acting as a proxy, for
each controled device. The problem is that beans are completly managed
by the bean container. They can be recycled at anytime. I do not want
this because enabling the communication between the proxy and the
controled device takes 30 seconds. So, I would like to have all the
proxies constructed only one time when the application start.
Is it possible ? Or do I have a serious flaw in my design ?
One of this device needs a nearly continuous socket polling, so I need
different threads inside the proxy bean. Is it possible ?
Thanks in advance !

Olivier
 
S

Sudsy

Olivier said:
Hello !

I must write an application used to control several electronic devices
accessed via sockets.This applicationprovides also a lot of other services.
As I need Web client interfaces, log utility, persistence, naming
service, message services, I think I can use EJB technology. It is also
for training and fun!
So I am going to start a little prototype based on jboss.
And of course I have some questions !
<snip>

You might want to consider using stateless session beans and have
the communication to the devices handled by a separate daemon
process. The daemon can be written in either Java or C, depending
on your platform. I'd communicate with the daemon using unix-domain
sockets (obviously this would only apply to *NIX systems).
You could open a connection in the serlvet init() method.
 
O

Olivier Scalbert

Ok,
Thanks !
Sudsy said:
<snip>

You might want to consider using stateless session beans and have
the communication to the devices handled by a separate daemon
process. The daemon can be written in either Java or C, depending
on your platform. I'd communicate with the daemon using unix-domain
sockets (obviously this would only apply to *NIX systems).
You could open a connection in the serlvet init() method.
 
J

John C. Bollinger

Olivier said:
Hello !

I must write an application used to control several electronic devices
accessed via sockets.This applicationprovides also a lot of other services.
As I need Web client interfaces, log utility, persistence, naming
service, message services, I think I can use EJB technology. It is also
for training and fun!

It certainly sounds like you can exercise several aspects of J2EE
technology. Do please recognize that EJB is only part of J2EE -- the
two are not synonymous.

EJBs are not permitted to use sockets directly, although that might or
might not be enforced by any particular EJB container. The "correct"
way for an EJB to talk to a device or external information service is
via a JCA adapter. It is likely that JCA is sufficiently flexible to
support your requirements for device control, but I'm not that familiar
with it.
And of course I have some questions !
In this application, I would like to have a bean acting as a proxy, for
each controled device. The problem is that beans are completly managed
by the bean container. They can be recycled at anytime. I do not want
this because enabling the communication between the proxy and the
controled device takes 30 seconds. So, I would like to have all the
proxies constructed only one time when the application start.
Is it possible ? Or do I have a serious flaw in my design ?

It is not exactly true that any EJB can be recycled by the container at
any time. A stateful session bean will not be reclaimed as long as it
is in use by a client, for instance. If you connect to the proxy beans
at webapp startup and hold a reference in the application context then
the bean instances should never be reclaimed. Perhaps better, though,
is to push the persistent connections below the EJB layer. For
instance, if you do implement JCA adapters then that would be the
appropriate place to do such a thing.
One of this device needs a nearly continuous socket polling, so I need
different threads inside the proxy bean. Is it possible ?

EJBs are not permitted to create threads. The restriction may or may
not be enforced, but you should comply anyway. You may be able to
manage this on the other side of the EJB / JCA boundary, if you choose
to go with JCA, but I'm not certain.


An alternative design would be to keep the instrument interfaces at the
webapp level with the web interface. Objects at that level have
considerably fewer restrictions than objects inside in an EJB container
do. You might still be able to put a variety of J2EE technologies to
good use in such a design.


John Bollinger
(e-mail address removed)
 

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,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top