Class CMPHelper
- java.lang.Object
-
- com.sun.jdo.spi.persistence.support.sqlstore.ejb.CMPHelper
-
public class CMPHelper extends Object
Provides helper methods for CMP support implementation with the application server specific information. Calls corresponding methods on the registered class which implements ContainerHelper interface.
-
-
Constructor Summary
Constructors Constructor Description CMPHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertValidLocalObject(Object o, Object container)Called in a CMP environment to verify that the specified object is of a valid local interface type.static voidassertValidRemoteObject(Object o, Object container)Called in a CMP environment to verify that the specified object is of a valid remote interface type.static voidbeginInternalTransaction(PersistenceManager pm)Called in a unspecified transaction context of a managed environment.static voidcommitInternalTransaction(PersistenceManager pm)Called in a unspecified transaction context of a managed environment.static voidflush(PersistenceManager pm)Flush transactional changes to the database.static ObjectgetContainer(Object info)Called in a CMP supported environment to get a Container instance that will be passed unchanged to the required methods.static jakarta.ejb.EJBLocalObjectgetEJBLocalObject(Object pk, Object container)Called in a managed environment to get an EJBLocalObject reference for this primary key instance and Container object.static jakarta.ejb.EJBLocalObjectgetEJBLocalObject(Object pk, Object container, jakarta.ejb.EJBContext context)Called in a managed environment to get an EJBLocalObject reference for this primary key instance, Container object, and EJBContext of the calling bean.static jakarta.ejb.EJBObjectgetEJBObject(Object pk, Object container)Called in a CMP supported environment to get an EJBObject reference for this primary key instance and Container object.static longgetNextId()Increments the counter and returns the value.static intgetNumericConverterPolicy(Object container)Called in CMP environment to get NumericConverter policy referenced by this Container instance.static PersistenceManagerFactorygetPersistenceManagerFactory(Object container)Called in a CMP environment to lookup PersistenceManagerFactory referenced by this Container instance as the CMP resource.static booleanisContainerReady()static voidpreSelect(Object container)Called in a CMP supported environment.static voidregisterContainerHelper(ContainerHelper h)Register class that implements ContainerHelper interface Should be called by a static method at class initialization time.static voidremoveByEJBLocalObject(jakarta.ejb.EJBLocalObject ejb, Object container)Called in a managed environment to remove a bean for a given EJBLocalObject, and Container instance.static voidremoveByPK(Object pk, Object container)Called in a managed environment to remove a bean for a given primary key and Container instance.static voidresumeCurrentTransaction(jakarta.transaction.Transaction tx)Called from read-only beans to resume current transaction.static voidrollbackInternalTransaction(PersistenceManager pm)Called in a unspecified transaction context of a managed environment.static voidsetCascadeDeleteAfterSuperEJBRemove(jakarta.ejb.EntityContext context)Called in a managed environment to mark EntityContext of the bean as already removed during cascade-delete operation.static jakarta.transaction.TransactionsuspendCurrentTransaction()Called from read-only beans to suspend current transaction.
-
-
-
Method Detail
-
registerContainerHelper
public static void registerContainerHelper(ContainerHelper h)
Register class that implements ContainerHelper interface Should be called by a static method at class initialization time.- Parameters:
h- application server specific implemetation of the ContainerHelper interface.
-
getNextId
public static long getNextId()
Increments the counter and returns the value. Used to populate primary key columns for EJB with an unknown Primary Key Class.- Returns:
- the next value for the counter.
-
getContainer
public static Object getContainer(Object info)
Called in a CMP supported environment to get a Container instance that will be passed unchanged to the required methods. In a non-managed environment throws JDOFatalInternalException. The info argument can be an array of Objects if necessary.- Parameters:
info- Object with the request information that is application server specific.- Returns:
- a Container instance as an Object.
- Throws:
JDOFatalInternalException- if ContainerHelper instance is not registered.- See Also:
getEJBObject(java.lang.Object,java.lang.Object),getEJBLocalObject(java.lang.Object,java.lang.Object),getEJBLocalObject(java.lang.Object,java.lang.Object,jakarta.ejb.EJBContext),removeByEJBLocalObject(jakarta.ejb.EJBLocalObject,java.lang.Object),removeByPK(java.lang.Object,java.lang.Object)
-
getEJBObject
public static jakarta.ejb.EJBObject getEJBObject(Object pk, Object container)
Called in a CMP supported environment to get an EJBObject reference for this primary key instance and Container object. The Container instance is acquired via #getContainer(Object).- Parameters:
pk- the primary key instance.container- a Container instance for the request.- Returns:
- a corresponding EJBObject (as an Object) to be used by the client.
- See Also:
getContainer(java.lang.Object)
-
getEJBLocalObject
public static jakarta.ejb.EJBLocalObject getEJBLocalObject(Object pk, Object container)
Called in a managed environment to get an EJBLocalObject reference for this primary key instance and Container object. The Container instance is acquired via #getContainer(Object).- Parameters:
pk- the primary key instance.container- a Container instance for the request.- Returns:
- a corresponding EJBLocalObject (as an Object) to be used by the client.
- See Also:
getContainer(java.lang.Object)
-
getEJBLocalObject
public static jakarta.ejb.EJBLocalObject getEJBLocalObject(Object pk, Object container, jakarta.ejb.EJBContext context)
Called in a managed environment to get an EJBLocalObject reference for this primary key instance, Container object, and EJBContext of the calling bean. Allows the container to check if this method is called during ejbRemove that is part of a cascade-delete remove. The Container instance is acquired via #getContainer(Object).- Parameters:
pk- the primary key instance.container- a Container instance for the request.context- an EJBContext of the calling bean.- Returns:
- a corresponding EJBLocalObject (as an Object) to be used by the client.
- See Also:
getContainer(java.lang.Object)
-
removeByEJBLocalObject
public static void removeByEJBLocalObject(jakarta.ejb.EJBLocalObject ejb, Object container)Called in a managed environment to remove a bean for a given EJBLocalObject, and Container instance. The Container instance is acquired via #getContainer(Object).- Parameters:
ejb- the EJBLocalObject for the bean to be removed.container- a Container instance for the request.- See Also:
getContainer(java.lang.Object)
-
removeByPK
public static void removeByPK(Object pk, Object container)
Called in a managed environment to remove a bean for a given primary key and Container instance. The Container instance is acquired via #getContainer(Object).- Parameters:
pk- the primary key for the bean to be removed.container- a Container instance for the request.- See Also:
getContainer(java.lang.Object)
-
setCascadeDeleteAfterSuperEJBRemove
public static void setCascadeDeleteAfterSuperEJBRemove(jakarta.ejb.EntityContext context)
Called in a managed environment to mark EntityContext of the bean as already removed during cascade-delete operation. Called by the generated ejbRemove method before calling ejbRemove of the related beans (via removeByEJBLocalObject) that are to be cascade-deleted. The Container instance is acquired via #getContainer(Object).- Parameters:
context- the EntityContext of the bean beeing removed.
-
getPersistenceManagerFactory
public static PersistenceManagerFactory getPersistenceManagerFactory(Object container)
Called in a CMP environment to lookup PersistenceManagerFactory referenced by this Container instance as the CMP resource. The Container instance is acquired via #getContainer(Object).- Parameters:
container- a Container instance for the request.- See Also:
getContainer(java.lang.Object)
-
assertValidLocalObject
public static void assertValidLocalObject(Object o, Object container)
Called in a CMP environment to verify that the specified object is of a valid local interface type. The Container instance is acquired via #getContainer(Object).- Parameters:
o- the instance to validate.container- a Container instance for the request.- See Also:
getContainer(java.lang.Object)
-
assertValidRemoteObject
public static void assertValidRemoteObject(Object o, Object container)
Called in a CMP environment to verify that the specified object is of a valid remote interface type. The Container instance is acquired via #getContainer(Object).- Parameters:
o- the instance to validate.container- a Container instance for the request.- See Also:
getContainer(java.lang.Object)
-
preSelect
public static void preSelect(Object container)
Called in a CMP supported environment. Notifies the container that ejbSelect had been called. The Container instance is acquired via #getContainer(Object).- Parameters:
container- a Container instance for the request.- See Also:
getContainer(java.lang.Object)
-
getNumericConverterPolicy
public static int getNumericConverterPolicy(Object container)
Called in CMP environment to get NumericConverter policy referenced by this Container instance.- Parameters:
container- a Container instance for the request- Returns:
- a valid NumericConverter policy type
- See Also:
getContainer(java.lang.Object)
-
beginInternalTransaction
public static void beginInternalTransaction(PersistenceManager pm)
Called in a unspecified transaction context of a managed environment. According to p.364 of EJB 2.0 spec, CMP may need to manage its own transaction when its transaction attribute is NotSupported, Never, Supports.- Parameters:
pm- PersistenceManager
-
commitInternalTransaction
public static void commitInternalTransaction(PersistenceManager pm)
Called in a unspecified transaction context of a managed environment. According to p.364 of EJB 2.0 spec, CMP may need to manage its own transaction when its transaction attribute is NotSupported, Never, Supports.- Parameters:
pm- PersistenceManager
-
rollbackInternalTransaction
public static void rollbackInternalTransaction(PersistenceManager pm)
Called in a unspecified transaction context of a managed environment. According to p.364 of EJB 2.0 spec, CMP may need to manage its own transaction when its transaction attribute is NotSupported, Never, Supports.- Parameters:
pm- PersistenceManager
-
suspendCurrentTransaction
public static jakarta.transaction.Transaction suspendCurrentTransaction()
Called from read-only beans to suspend current transaction. This will guarantee that PersistenceManager is not bound to any transaction.- Returns:
- jakarta.transaction.Transaction object representing the suspended transaction. Returns null if the calling thread is not associated with a transaction.
-
resumeCurrentTransaction
public static void resumeCurrentTransaction(jakarta.transaction.Transaction tx)
Called from read-only beans to resume current transaction. This will guarantee that the transaction continues to run after read-only bean accessed its PersistenceManager.- Parameters:
tx- - The jakarta.transaction.Transaction object that represents the transaction to be resumed.
-
flush
public static void flush(PersistenceManager pm)
Flush transactional changes to the database.- Parameters:
pm- PersistenceManager
-
isContainerReady
public static boolean isContainerReady()
- Returns:
- true if the container had been registered correctly.
-
-