Oracle Application Server TopLink API Reference
10g Release 2 (10.1.2)

B15903-01


oracle.toplink.ejb.cmp.wls11
Class SessionAccessor

java.lang.Object
  extended byoracle.toplink.ejb.cmp.wls11.SessionAccessor


public class SessionAccessor
extends java.lang.Object

PUBLIC

This class provides access to TopLink's Session and UnitOfWork and can be used at runtime by a bean to manage aspects of caching etc. that are not generally available in EJB.

If a bean has references to regular Java objects that are made persistent through TopLink, this class can be used to properly manage various serialized versions of the Java objects.


Constructor Summary
SessionAccessor()

Method Summary
static oracle.toplink.publicinterface.UnitOfWork getCurrentUnitOfWorkFor(javax.ejb.EntityContext context)
PUBLIC Returns the active TopLink unit of work for the context.
static oracle.toplink.publicinterface.Session getSessionFor(javax.ejb.EntityContext context)
PUBLIC Returns the active TopLink session for the context.
static oracle.toplink.publicinterface.Session getSessionFor(java.lang.String name)
PUBLIC Returns the active TopLink session for the project.
static java.lang.Object registerOrMergeAttribute(java.lang.Object value, java.lang.String attributeName, javax.ejb.EntityContext ctx)
PUBLIC Merge the changes from the remote clone into the server version of the object(s) for a bean's attribute.
static java.lang.Object registerOrMergeObject(java.lang.Object value, javax.ejb.EntityContext ctx)
PUBLIC Merge the changes from the remote clone into the server version of the object(s) for a bean's attribute.

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

SessionAccessor

public SessionAccessor()

Method Detail

getCurrentUnitOfWorkFor

public static oracle.toplink.publicinterface.UnitOfWork getCurrentUnitOfWorkFor(javax.ejb.EntityContext context)

PUBLIC

Returns the active TopLink unit of work for the context. This can be accessed to give access to advanced TopLink API on the server.

WARNING - Only in rare instances should this method ever be used, and if so, caution must be taken to ensure that the unit of work is not misused.

Parameters:
context - the entity context for the bean
Returns:
The unit of work active for this bean

getSessionFor

public static oracle.toplink.publicinterface.Session getSessionFor(javax.ejb.EntityContext context)

PUBLIC

Returns the active TopLink session for the context. This can be accessed to give access to advanced TopLink API on the server.

Returns:
The Session used by all of the descriptors in the project

getSessionFor

public static oracle.toplink.publicinterface.Session getSessionFor(java.lang.String name)

PUBLIC

Returns the active TopLink session for the project. This can be accessed to give access to advanced TopLink API on the server.

Parameters:
name - the project identifier of the project associated with the session
Returns:
The Session used by all of the descriptors in the given project

registerOrMergeObject

public static java.lang.Object registerOrMergeObject(java.lang.Object value,
                                                     javax.ejb.EntityContext ctx)

PUBLIC

Merge the changes from the remote clone into the server version of the object(s) for a bean's attribute. The object should not be a collection.

Here is an example of how this method can be used within an EJB setter method.

public void setAddress(Address addressFromClient) { this.address = (Address)SessionAccessor.registerOrMergeObject(addressFromClient, this.ctx); }

Parameters:
value - the attribute object to merge
ctx - the entity context of the bean
Returns:
The merged object

registerOrMergeAttribute

public static java.lang.Object registerOrMergeAttribute(java.lang.Object value,
                                                        java.lang.String attributeName,
                                                        javax.ejb.EntityContext ctx)

PUBLIC

Merge the changes from the remote clone into the server version of the object(s) for a bean's attribute.

Here is an example of how this method can be used within an EJB setter method.

public void setAddress(Address addressFromClient) { this.address = SessionAccessor.registerOrMergeAttribute(addressFromClient, "address", this.ctx); }

Parameters:
value - the attribute object to merge
attributeName - the name of the field in the bean
ctx - the entity context of the bean
Returns:
The merged object

Copyright © 1998, 2005 Oracle Corporation. All Rights Reserved.