Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

URLConnection within EJB  RSS feed

 
Pearlo Muthukumaran
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would first seek for the apologies of EJB purists. </br>
My query goes as 'can we use URLConnection object within the stateless session bean?'.</br>
My client already has some infrastructure built on ASP, JSP and stuff like that for doing some basic validation that queries database and retrieves the results. </br>
For example, the credit rating of the customer is already available as a HTTP service which is jolly well used by some of the clients' VB applications.Now we are building a different system which we thought could leverage the existing HTTP services available as said above.</br>
Before I jump to the conclusion, please clarify:</br>
1. Is it advisabel to use URLConnection to avail the existing HTTP services within EJB?
2. Has anyone tried this out and were there any pitfalls/problems faced?</br>
3. Could this be used in a transaction context say for instance in the transaction context of Bean Managed Persistence?</br>
Regards</br>
Kala
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. It is okay for an EJB to open a UrlConnection to retrieve information. It just shouldn't accept connections on a socket. The EJB Spec has this to say:
EJB 2.0 Specification
An enterprise bean must not attempt to listen on a socket, accept connections on a socket, or use a socket for multicast.
The EJB architecture allows an enterpise bean instance to be a network socket client, but it does not allow it to be a network server. Allowing the instance to become a network server would conflict with the basic function of the enterprise bean -- to server EJB clients.

2. The biggest problem is pooling the UrlConnections so that a new one is not created upon give request. This however is fairly easy to manage.
3. A UrlConnection is not a transactional resource.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!