File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Qtn regarding setSessioncontext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Qtn regarding setSessioncontext" Watch "Qtn regarding setSessioncontext" New topic

Qtn regarding setSessioncontext

Natarajan Shankar
Ranch Hand

Joined: Jun 10, 2004
Posts: 53
Hello all,
I need clarification regardiong setSessioncontext. I don't understand if in

1. setSessionContext if we can get a reference to EJBHome why not get security information about the client?

2. If we can have special JNDI access like datasource and by uising it If I get ds.getConnection, why I cannot able to use the connection. Does it stops me to do con.createStament() and executng query.

If you have any clarification things pls. help me out. Thanks !

Best Regards<br />N.Shankar<br />SCJP, SCWCD
Christian D. Th. Sellberg

Joined: Apr 02, 2004
Posts: 10
Hi Shankar

For stateless session beans a part of a explanation for question 1 and 2 is that setSessionContext (and ejbCreate) is called by the container when the stateless session beans moves from the state �does not exist� to the state �method-ready pool�, this state transition is not triggered by any client call (see page 89 in the specification). I.e. you have an unspecified transaction context and there is no client to get security information about.

For stateful session beans I think that the spec gives a part of an explanation to your second question in a note on page 76

The ejbCreate and ejbRemove methods are not controlled by a transaction attribute because handling
rollbacks in these methods would greatly complicate the session instance�s state diagram.
setSessionContext is called by the container before ejbCreate so the reasoning in the quote above must apply here as well.

With out the spec actually saying so I get the impression that this note is the explanation for your question as well. I guess the restrictions mentioned in your question apply because otherwise it would make the state diagram of a session bean to complicated. new instance, setSessionContext and ejbCreate are all called in serialization in the state transition from �does not exist� to �method ready�. E.g. in the stateful session bean state diagram on page 77 in the specification you would have to introduce some additional state like �security context ready� before the call to setSessionContext if it should be allowed to access client specific security information in setSessionContext.

Kind regards
Natarajan Shankar
Ranch Hand

Joined: Jun 10, 2004
Posts: 53
Hi Christina,
Thanks a lot for your explanation, I was looking for any specific reason for not able to access the method. From your explanation i understood thre might some more extra features need to be added from by container providers.

Thanks for sharing your knowledge.
I agree. Here's the link:
subject: Qtn regarding setSessioncontext
It's not a secret anymore!