O'Reilly logo

Applied Enterprise JavaBeans™ Technology by Kevin Boone

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18.2. Simple connectivity techniques

18.2.1. The Socket API

There is no reason in theory why communication with our quote server should not be implemented directly by an EJB using Java sockets. This technique is specifically allowed for in the EJB Specification [EJB2.0 24.2.1]. If the designer encapsulates the communication inside a dedicated class or EJB, the code will not be particularly objectionable.

In practice, the EJB can execute code something like this:

Socket s = new Socket (’someserver’, somePort); 
//... read and write socket 
s.close(); 

The container has to support this, because method calls between EJBs can be network calls.

The problems with this strategy should be fairly obvious.

  • The developer has to do all the work: The Socket ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required