Class CMPBeanHelper
java.lang.Object
com.sun.jdo.spi.persistence.support.ejb.cmp.CMPBeanHelper
Provides static helper methods for CMP bean implementation to simplify
the generated code.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertCollectionNotNull(Collection c, String beanName) Called from a CMP bean to verify that the argument for a Collection set method is not null.static voidCalled from a 1.1 CMP bean to verify that the bean method is not called in a container transaction.static voidassertPersistenceManagerIsNull(com.sun.jdo.api.persistence.support.PersistenceManager pm, Object bean, StringBuffer buf) Called from a CMP bean to verify that the PersistenceManager is null.static voidassertPersistenceManagerNotNull(com.sun.jdo.api.persistence.support.PersistenceManager pm, Object bean) Called from a CMP bean to verify that the PersistenceManager is not null.static voidassertPersistent(com.sun.jdo.api.persistence.support.PersistenceCapable pc, String beanName) Called from a CMP bean to verify that the PersistenceCapable instance is already persistent.static voidhandleCloneException(Object primaryKey, String beanName, Exception ex) Throws EJBException on failed clone of persistence state in read-only beans.static voidhandleJDODuplicateObjectIdAsDuplicateKeyException(String beanName, String paramList, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to process JDODuplicateObjectIdException.static voidhandleJDODuplicateObjectIdAsEJBException(String beanName, String paramList, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to process JDODuplicateObjectIdException.static voidhandleJDOObjectNotFoundException(Object primaryKey, String beanName, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to process JDOObjectNotFoundException.static voidhandleUpdateNotAllowedException(String beanName) Throws EJBException on attempted updates to the calling bean.static voidlogFinderException(int level, String beanName, Exception ex) Called from a CMP bean to log JDOException message thrown from a any finder or selector method, with the FinderLogger.static StringlogJDOExceptionFromPKSetter(String beanName, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to log JDOException message thrown from a PK setter method, with the InternalLogger.static voidlogJDOExceptionWithFinderLogger(String beanName, Object[] params, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to log JDOException message thrown from a any finder or selector method, with the FinderLogger.static voidlogJDOExceptionWithInternalLogger(String beanName, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to log JDOException message thrown from a any getter or setter method, with the InternalLogger.static voidlogJDOExceptionWithLifecycleLogger(String key, String beanName, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to log JDOException message with the LifecycleLogger.static voidlogJDOExceptionWithLifecycleLogger(String key, String beanName, String paramList, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to log JDOException message with the LifecycleLogger.
-
Constructor Details
-
CMPBeanHelper
public CMPBeanHelper()
-
-
Method Details
-
logJDOExceptionWithLifecycleLogger
public static void logJDOExceptionWithLifecycleLogger(String key, String beanName, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to log JDOException message with the LifecycleLogger.- Parameters:
key- the key for the corresponding Bundle.beanName- the name of the calling bean.ex- the JDOException.
-
logJDOExceptionWithLifecycleLogger
public static void logJDOExceptionWithLifecycleLogger(String key, String beanName, String paramList, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to log JDOException message with the LifecycleLogger.- Parameters:
key- the key for the corresponding Bundle.beanName- the name of the calling bean.paramList- the list of the concatenated parameters.ex- the JDOException.
-
logJDOExceptionWithInternalLogger
public static void logJDOExceptionWithInternalLogger(String beanName, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to log JDOException message thrown from a any getter or setter method, with the InternalLogger.- Parameters:
beanName- the name of the calling bean.ex- the JDOException.
-
logJDOExceptionWithFinderLogger
public static void logJDOExceptionWithFinderLogger(String beanName, Object[] params, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to log JDOException message thrown from a any finder or selector method, with the FinderLogger.- Parameters:
beanName- the name of the calling bean.params- the Object[] of the parameter values for the finder or selector method.ex- the JDOException.
-
logFinderException
Called from a CMP bean to log JDOException message thrown from a any finder or selector method, with the FinderLogger.- Parameters:
level- the logging level as int.beanName- the name of the calling bean.ex- the Exception.
-
logJDOExceptionFromPKSetter
public static String logJDOExceptionFromPKSetter(String beanName, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to log JDOException message thrown from a PK setter method, with the InternalLogger. Returns generated message to the caller to be used for a IllegalStateException.- Parameters:
beanName- the name of the calling bean.ex- the JDOException.- Returns:
- logged message as String.
-
assertPersistent
public static void assertPersistent(com.sun.jdo.api.persistence.support.PersistenceCapable pc, String beanName) Called from a CMP bean to verify that the PersistenceCapable instance is already persistent. Throws IllegalStateException otherwise.- Parameters:
pc- the PersistenceCapable instance to be checked.beanName- the name of the caller bean.- Throws:
IllegalStateException- if the instance is not persistent.
-
assertCollectionNotNull
Called from a CMP bean to verify that the argument for a Collection set method is not null. Throws IllegalArgumentException if the argument is null.- Parameters:
c- the Collection to check.beanName- the name of the caller bean.- Throws:
IllegalArgumentException- if the argument is null.
-
assertPersistenceManagerNotNull
public static void assertPersistenceManagerNotNull(com.sun.jdo.api.persistence.support.PersistenceManager pm, Object bean) Called from a CMP bean to verify that the PersistenceManager is not null. Throws IllegalStateException if the argument is null.- Parameters:
pm- the PersistenceManager to check.bean- the calling bean instance.- Throws:
IllegalStateException- if the PersistenceManager is null.
-
assertPersistenceManagerIsNull
public static void assertPersistenceManagerIsNull(com.sun.jdo.api.persistence.support.PersistenceManager pm, Object bean, StringBuffer buf) Called from a CMP bean to verify that the PersistenceManager is null. Throws IllegalStateException if the argument is not null.- Parameters:
pm- the PersistenceManager to check.bean- the calling bean instance.- Throws:
IllegalStateException- if the PersistenceManager is not null.
-
assertNotContainerTransaction
Called from a 1.1 CMP bean to verify that the bean method is not called in a container transaction. Throws IllegalStateException otherwise.- Parameters:
bean- the calling bean instance.- Throws:
IllegalStateException- if the bean method is called in a container transaction.
-
handleJDODuplicateObjectIdAsDuplicateKeyException
public static void handleJDODuplicateObjectIdAsDuplicateKeyException(String beanName, String paramList, com.sun.jdo.api.persistence.support.JDOException ex) throws jakarta.ejb.DuplicateKeyException Called from a CMP bean to process JDODuplicateObjectIdException. Logs the message and throws DuplicateKeyException.- Parameters:
beanName- the name of the calling bean.paramList- the list of the concatenated parameters.ex- the JDOException.- Throws:
jakarta.ejb.DuplicateKeyException
-
handleJDODuplicateObjectIdAsEJBException
public static void handleJDODuplicateObjectIdAsEJBException(String beanName, String paramList, com.sun.jdo.api.persistence.support.JDOException ex) Called from a CMP bean to process JDODuplicateObjectIdException. Logs the message and throws EJBException.- Parameters:
beanName- the name of the calling bean.paramList- the list of the concatenated parameters.ex- the JDOException.
-
handleJDOObjectNotFoundException
public static void handleJDOObjectNotFoundException(Object primaryKey, String beanName, com.sun.jdo.api.persistence.support.JDOException ex) throws jakarta.ejb.ObjectNotFoundException Called from a CMP bean to process JDOObjectNotFoundException. Logs the message and throws ObjectNotFoundException- Parameters:
primaryKey- the PrimaryKey instance.beanName- the name of the calling bean.ex- the JDOException.- Throws:
jakarta.ejb.ObjectNotFoundException
-
handleUpdateNotAllowedException
Throws EJBException on attempted updates to the calling bean.- Parameters:
beanName- the name of the calling bean.
-
handleCloneException
Throws EJBException on failed clone of persistence state in read-only beans.- Parameters:
primaryKey- the PrimaryKey instance.beanName- the name of the calling bean.ex- the Exception.
-