Hi Wonseok,
Good point about the functionality of updateServerSession(). That
might alleviate the concern I had about renaming the session in the
deploy method.
One of our goals is to provide JPA functionality while still allowing
users to make use of TopLink in the ways they used it before JPA. An
explicit session name is useful for users who want to use TopLink's
non-JPA API. They can look up the session and operate on that session.
Our default session name will take the location of the persistence unit
into account and therefore is a little convoluted, so we provided the
means to specify a easier to use session name.
-Tom
Wonseok Kim wrote:
> Tom,
> Please see below comments...
>
> On 10/13/06, *Tom Ware* <tom.ware_at_oracle.com
> <mailto:tom.ware_at_oracle.com>> wrote:
>
> Marina and Wonsoek,
>
> >
> > 4. (To Tom) This is another concern but related to #3. What is the
> > behaviour of session name property? If I specify the same
> session name
> > of two applications or two persistence units, could I share
> > ServerSession? But it doesn't seem to do it, because in
> > EntityManagerSetupImpl.predeploy() session is always newly created
> > like below regardless of the session name.
> >
> > session = new ServerSession(...);
> >
> > If session name property has no effect in JPA, I think it should be
> > removed and then there will be no confusion in #3.
>
> Session name is used to store the session we use on the
> SessionManager.
> We expect the session name to be unique. If it is not, an exception
> will be thrown when the session is added to the SessionManager. Take a
> look at the addSessionToGlobalSessionManager() method.
>
>
> If a session name is specified by property, current code will set it
> in updateSessionName(). But as you see below, it calls
> removeSessionFromGlobalSessionManager(), therefore non-unique session
> name doesn't appear to throw an exception in
> addSessionToGlobalSessionManager().
>
> protected void updateSessionName(Map m) {
> String newName =
> getConfigPropertyAsStringLogDebug(TopLinkProperties.SESSION_NAME, m,
> session);
> if(newName == null || newName.equals(session.getName ())) {
> return;
> }
>
> removeSessionFromGlobalSessionManager();
> session.setName(newName);
> addSessionToGlobalSessionManager();
> }
>
> Frankly I would like to know what we could get with
> explicitly-specified session name? I couldn't find any usage of the
> session name except for logger hierachy. ServerSessions don't seem to
> be shared. I found some internal code with regard to session name, but
> actually they don't do special things with this(such as
> DatabaseQuery.sessionName). Could you elaborate on this?
>
> Regards
> - Wonseok
>
--
Tom Ware
Principal Software Engineer
Oracle Canada Inc.
Direct: (613) 783-4598
Email: tom.ware_at_oracle.com