• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can a Session bean use URL and URLConnection classes ?

 
Ruilin Yang
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thoms
Thanks
Ruilin
 
Tim Holloway
Bartender
Posts: 18412
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!