• 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

Can a Session bean use URL and URLConnection classes ?

 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please Help:
I am not sure whether EJB can call classes:
URL, URLConnection, ObjectInputStream, DataInputStream, etc since EJB are not allowed to open socket and make network calls.
Please clarify the problem for me,
Thanks
Ruilin
 
Ruilin Yang
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EJB is not allowed to make socket connection. Therefore, I confused if EJB can call URL and URLConnection classes to write to or read from a URL ?
Please help
Thanks
Ruilin
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

From the specification:
20.4.1.3 Standard resource manager connection factory types

The Bean Provider must use the javax.sql.DataSource resource manager connection factory type for obtaining JDBC connections, and the javax.jms.QueueConnectionFactory or the
javax.jms.TopicConnectionFactory for obtaining JMS connections.
The Bean Provider must use the javax.mail.Session resource manager connection factory type
for obtaining JavaMail connections, and the java.net.URL resource manager connection factory
type for obtaining URL connections.
It is recommended that the Bean Provider names JDBC data sources in the java:comp/env/jdbc
subcontext, and JMS connection factories in the java:comp/env/jms subcontext. It is also recom-mended that the Bean Provider names all JavaMail connection factories in the java:comp/env/mail subcontext, and all URL connection factories in the java:comp/env/url subcontext.
The Connector architecture [12] allows an enterprise bean to use the API described in this section to obtain resource objects that provide access to additional back-end systems.

 
Ruilin Yang
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thoms
Thanks
Ruilin
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually the limitation is that an EJB cannot be a socket server -- it's not allowed to wait for connections since that not only suspends the client, but also anyone else queued up waiting to use the EJB.
Use sockets carefully (and in conformance with the EJB spec). Even when they're legal, they tend to slow down response time just because they're sockets. If they slow it down too much, the client may time out.
 
reply
    Bookmark Topic Watch Topic
  • New Topic