This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Sharing of Resource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Sharing of Resource" Watch "Sharing of Resource" New topic
Author

Sharing of Resource

nitin pai
Ranch Hand

Joined: May 30, 2006
Posts: 185
Its given in the core specs(pg 425),that,


The value of the res-sharing-scope element
is Shareable or Unshareable. If the res-sharing-scope element is not specified, connections
are assumed to be shareable.
A resource manager connection factory reference is scoped to the enterprise bean whose declaration
contains the resource-ref element.


If the resource manager is scoped to the bean in which it is declared, then how can it be shared?



nitin pai
Ranch Hand

Joined: May 30, 2006
Posts: 185
any ideas?
J J Wright
Ranch Hand

Joined: Jul 02, 2008
Posts: 254
A resource manager connection factory reference may be scoped to a component but multiple components can reference the same connection factory - i.e. you define a single datasource in your app server then reference it from multiple components.

When a connection is marked as sharable it can be reused by multiple components executing in the same transaction. For example EJB1 starts a transaction, obtains a JDBC connection, uses it, and then invokes a method on EJB2. EJB2 also uses a JBDC connection with same connection properties as the one used EJB1. If the connection is shareable EJB2 will reuse the same connection, as opposed to creating a new one.

Check out the JCA spec if this still isn't clear.


SCJP, SCWCD, SCBCD, SCEA 5
 
 
subject: Sharing of Resource
 
Similar Threads
res-sharing-scope of resource-ref, how to share?
Contradicting statements
Example of resource-ref in DD?
res-sharing-scope in resouce-ref tag
Shareable or Unshareable