com.sun.jdo.spi.persistence.support.ejb.cmp
Class JDOEJB11HelperImpl

java.lang.Object
  extended by com.sun.jdo.spi.persistence.support.ejb.cmp.JDOEJB11HelperImpl
All Implemented Interfaces:
JDOEJB11Helper
Direct Known Subclasses:
JDOEJB20HelperImpl

public abstract class JDOEJB11HelperImpl
extends Object
implements JDOEJB11Helper


Field Summary
protected static Logger logger
           
protected static ResourceBundle messages
          I18N message handler
 
Constructor Summary
JDOEJB11HelperImpl()
           
 
Method Summary
abstract  void assertInstanceOfRemoteInterfaceImpl(Object o)
          Validates that this instance is of the correct implementation class of a remote interface type.
protected  void assertInstanceOfRemoteInterfaceImpl(Object o, String beanName)
          Validates that this instance is of the correct implementation class of bean remote interface.
protected  void assertObjectIdNotNull(Object oid)
          Validates that the object id instance is not null.
 void assertPrimaryKeyFieldNotNull(Object pkfield, String pkfieldName, String beanName)
          Validates that the primary key field of an Object type is not null.
protected  void assertPrimaryKeyNotNull(Object pk)
          Validates that the primary key instance is not null.
 Collection convertCollectionEJBObjectToPC(Collection coll, PersistenceManager pm, boolean validate)
          Converts Collection of EJBObjects to a Collection of persistence-capable instances.
 Collection convertCollectionObjectIdToPrimaryKey(Collection oids)
          Converts Collection of Object Id's of persistence-capable instances to a Collection of of the PrimaryKey instances.
 Collection convertCollectionPCToEJBObject(Collection pcs, PersistenceManager pm)
          Converts Collection of persistence-capable instances to a Collection of EJBObjects.
 Set convertCollectionPCToEJBObjectSet(Collection pcs, PersistenceManager pm)
          Converts Collection of persistence-capable instances to a Set of EJBObjects.
 Collection convertCollectionPCToPrimaryKey(Collection pcs, PersistenceManager pm)
          Converts Collection of persistence-capable instances to a Collection of the PrimaryKey Class instances.
 Collection convertCollectionPrimaryKeyToObjectId(Collection keys)
          Converts Collection of PrimaryKey instances to a Collection of Object Id's of a corresponding persistence-capable Class.
 Object convertEJBObjectToPC(EJBObject o, PersistenceManager pm, boolean validate)
          Converts EJBObject to persistence-capable instance.
abstract  Object convertObjectIdToPrimaryKey(Object objectId)
          Converts Object Id of a persistence-capable instance to an instance of the PrimaryKey Class.
 EJBObject convertPCToEJBObject(Object pc, PersistenceManager pm)
          Converts persistence-capable instance to EJBObject.
 Object convertPCToPrimaryKey(Object pc, PersistenceManager pm)
          Converts persistence-capable instance to an instance of the PrimaryKey Class.
abstract  Object convertPrimaryKeyToObjectId(Object key)
          Converts instance of a PrimaryKey Class to an instance of the Object Id of a corresponding persistence-capable Class.
protected  Object convertPrimaryKeyToPC(Object key, PersistenceManager pm, boolean validate)
          Converts PrimaryKey object to persistence-capable instance.
 NumericConverter getNumericConverter()
          Return NumericConverter for conversion from Number to BigDecimal or BigInteger for this bean type.
abstract  Class getPCClass()
          Returns the class object of the corresponding persistence-capable class of the concrete bean class.
 Serializable readSerializableObjectFromByteArray(byte[] byteArray)
          Constructs a Serializable object from byteArray.
 byte[] writeSerializableObjectToByteArray(Serializable serializableObject)
          Serializes serializableObject into a byte array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.jdo.spi.persistence.support.sqlstore.ejb.JDOEJB11Helper
getContainer
 

Field Detail

messages

protected static final ResourceBundle messages
I18N message handler


logger

protected static final Logger logger
Constructor Detail

JDOEJB11HelperImpl

public JDOEJB11HelperImpl()
Method Detail

convertPCToEJBObject

public EJBObject convertPCToEJBObject(Object pc,
                                      PersistenceManager pm)
Converts persistence-capable instance to EJBObject.

Specified by:
convertPCToEJBObject in interface JDOEJB11Helper
Parameters:
pc - the persistence-capable instance to be converted as an Object.
pm - the associated instance of PersistenceManager.
Returns:
instance of EJBObject.

convertEJBObjectToPC

public Object convertEJBObjectToPC(EJBObject o,
                                   PersistenceManager pm,
                                   boolean validate)
Converts EJBObject to persistence-capable instance.

Specified by:
convertEJBObjectToPC in interface JDOEJB11Helper
Parameters:
o - the EJBObject instance to be converted.
pm - the associated instance of PersistenceManager.
validate - true if the existence of the instance is to be validated.
Returns:
persistence-capable instance.
Throws:
IllegalArgumentException - if validate is true and instance does not exist in the database or is deleted.

convertPrimaryKeyToPC

protected Object convertPrimaryKeyToPC(Object key,
                                       PersistenceManager pm,
                                       boolean validate)
Converts PrimaryKey object to persistence-capable instance.

Parameters:
key - the PrimaryKey object to be converted.
pm - the associated instance of PersistenceManager.
validate - true if the existence of the instance is to be validated.
Returns:
persistence-capable instance.
Throws:
IllegalArgumentException - if validate is true and instance does not exist in the database or is deleted.

convertCollectionPCToEJBObject

public Collection convertCollectionPCToEJBObject(Collection pcs,
                                                 PersistenceManager pm)
Converts Collection of persistence-capable instances to a Collection of EJBObjects.

Specified by:
convertCollectionPCToEJBObject in interface JDOEJB11Helper
Parameters:
pcs - the Collection of persistence-capable instance to be converted.
pm - the associated instance of PersistenceManager.
Returns:
Collection of EJBObjects.

convertCollectionPCToEJBObjectSet

public Set convertCollectionPCToEJBObjectSet(Collection pcs,
                                             PersistenceManager pm)
Converts Collection of persistence-capable instances to a Set of EJBObjects.

Specified by:
convertCollectionPCToEJBObjectSet in interface JDOEJB11Helper
Parameters:
pcs - the Collection of persistence-capable instance to be converted.
pm - the associated instance of PersistenceManager.
Returns:
Set of EJBObjects.

convertCollectionEJBObjectToPC

public Collection convertCollectionEJBObjectToPC(Collection coll,
                                                 PersistenceManager pm,
                                                 boolean validate)
Converts Collection of EJBObjects to a Collection of persistence-capable instances.

Specified by:
convertCollectionEJBObjectToPC in interface JDOEJB11Helper
Parameters:
coll - the Collection of EJBObject instances to be converted.
pm - the associated instance of PersistenceManager.
validate - true if the existence of the instances is to be validated.
Returns:
Collection of persistence-capable instance.
Throws:
IllegalArgumentException - if validate is true and at least one instance does not exist in the database or is deleted.

convertPCToPrimaryKey

public Object convertPCToPrimaryKey(Object pc,
                                    PersistenceManager pm)
Converts persistence-capable instance to an instance of the PrimaryKey Class.

Specified by:
convertPCToPrimaryKey in interface JDOEJB11Helper
Parameters:
pc - the persistence-capable instance to be converted as an Object.
pm - the associated instance of PersistenceManager.
Returns:
instance of the PrimaryKey Class.

convertCollectionPCToPrimaryKey

public Collection convertCollectionPCToPrimaryKey(Collection pcs,
                                                  PersistenceManager pm)
Converts Collection of persistence-capable instances to a Collection of the PrimaryKey Class instances.

Specified by:
convertCollectionPCToPrimaryKey in interface JDOEJB11Helper
Parameters:
pcs - Collection of the persistence-capable instances.
pm - the associated instance of PersistenceManager.
Returns:
Collection of the PrimaryKey Class instances.

convertObjectIdToPrimaryKey

public abstract Object convertObjectIdToPrimaryKey(Object objectId)
Converts Object Id of a persistence-capable instance to an instance of the PrimaryKey Class.

Specified by:
convertObjectIdToPrimaryKey in interface JDOEJB11Helper
Parameters:
objectId - the Object Id to be converted.
Returns:
instance of the PrimaryKey Class.

convertPrimaryKeyToObjectId

public abstract Object convertPrimaryKeyToObjectId(Object key)
Converts instance of a PrimaryKey Class to an instance of the Object Id of a corresponding persistence-capable Class.

Specified by:
convertPrimaryKeyToObjectId in interface JDOEJB11Helper
Parameters:
key - the PrimaryKey instance to be converted.
Returns:
instance of the Object Id.

convertCollectionObjectIdToPrimaryKey

public Collection convertCollectionObjectIdToPrimaryKey(Collection oids)
Converts Collection of Object Id's of persistence-capable instances to a Collection of of the PrimaryKey instances.

Specified by:
convertCollectionObjectIdToPrimaryKey in interface JDOEJB11Helper
Parameters:
oids - Collection of the Object Id to be converted.
Returns:
Collection of of the PrimaryKey Class instances.

convertCollectionPrimaryKeyToObjectId

public Collection convertCollectionPrimaryKeyToObjectId(Collection keys)
Converts Collection of PrimaryKey instances to a Collection of Object Id's of a corresponding persistence-capable Class.

Specified by:
convertCollectionPrimaryKeyToObjectId in interface JDOEJB11Helper
Parameters:
keys - Collection of the PrimaryKey instances to be converted.
Returns:
Collection of the Object Id's.

writeSerializableObjectToByteArray

public byte[] writeSerializableObjectToByteArray(Serializable serializableObject)
Serializes serializableObject into a byte array

Specified by:
writeSerializableObjectToByteArray in interface JDOEJB11Helper
Parameters:
serializableObject - Instance of a Serializable Object
Returns:
serializableObject serialized into a byte array

readSerializableObjectFromByteArray

public Serializable readSerializableObjectFromByteArray(byte[] byteArray)
Constructs a Serializable object from byteArray. It is expected that byteArray was constructed using a previous call to writeSerializableObjectToByteArray

Specified by:
readSerializableObjectFromByteArray in interface JDOEJB11Helper
Parameters:
byteArray - Array of byte obtained from a call to writeSerializableObjectToByteArray
Returns:
A Serializable object contructed from byteArray
See Also:
writeSerializableObjectToByteArray(Serializable)

getNumericConverter

public NumericConverter getNumericConverter()
Return NumericConverter for conversion from Number to BigDecimal or BigInteger for this bean type. It is responsible for passing the correct policy value to the NumericConverterFactory.

Specified by:
getNumericConverter in interface JDOEJB11Helper
Returns:
NumericConverter for given object policy

getPCClass

public abstract Class getPCClass()
Returns the class object of the corresponding persistence-capable class of the concrete bean class.

Specified by:
getPCClass in interface JDOEJB11Helper
Returns:
the pc class object

assertInstanceOfRemoteInterfaceImpl

public abstract void assertInstanceOfRemoteInterfaceImpl(Object o)
Validates that this instance is of the correct implementation class of a remote interface type.

Specified by:
assertInstanceOfRemoteInterfaceImpl in interface JDOEJB11Helper
Parameters:
o - the instance to validate.
Throws:
IllegalArgumentException - if validation fails.

assertInstanceOfRemoteInterfaceImpl

protected void assertInstanceOfRemoteInterfaceImpl(Object o,
                                                   String beanName)
Validates that this instance is of the correct implementation class of bean remote interface. Throws IllegalArgumentException if the argument is of a wrong type.

Parameters:
o - the instance to validate.
beanName - as String.
Throws:
IllegalArgumentException - if validation fails.

assertPrimaryKeyNotNull

protected void assertPrimaryKeyNotNull(Object pk)
Validates that the primary key instance is not null. Throws IllegalArgumentException otherwise.

Parameters:
pk - the primary key instance to validate.
Throws:
IllegalArgumentException - if validation fails.

assertPrimaryKeyFieldNotNull

public void assertPrimaryKeyFieldNotNull(Object pkfield,
                                         String pkfieldName,
                                         String beanName)
Validates that the primary key field of an Object type is not null. Throws IllegalArgumentException otherwise.

Parameters:
pkfield - the primary key field instance to validate.
pkfieldName - the primary key field name.
beanName - the EJB name.
Throws:
IllegalArgumentException - if validation fails.

assertObjectIdNotNull

protected void assertObjectIdNotNull(Object oid)
Validates that the object id instance is not null. Throws JDOFatalInternalException otherwise.

Parameters:
oid - the object id instance to validate.
Throws:
JDOFatalInternalException - if validation fails.


Copyright © 2012. All Rights Reserved.