• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

URLConnection within EJB

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic