Interface ApiAdapter

All Superinterfaces:
Serializable

public interface ApiAdapter extends Serializable
Adapter to allow the core runtime to expose multiple APIs to clients.
  • Method Details

    • getName

      String getName()
      Accessor for the name of the API. JDO, JPA, Jakarta etc
      Returns:
      Name of the API
    • isMemberDefaultPersistent

      boolean isMemberDefaultPersistent(Class type)
      Accessor for whether this member type is default persistent.
      Parameters:
      type - Member type
      Returns:
      Whether it is by default persistent
    • getXMLMetaDataForClass

      String getXMLMetaDataForClass(AbstractClassMetaData cmd, String prefix, String indent)
    • getDefaultMappingFileLocation

      String getDefaultMappingFileLocation()
      Method to return any default location that doesn't need specifying for "mapping-file" in the persistence.xml. With JPA/Jakarta this is META-INF/orm.xml. With JDO we don't have such a location.
      Returns:
      The default location to try for a mapping-file for this API
    • isManaged

      default boolean isManaged(Object pc)
      Whether the provided object is currently managed (has an ExecutionContext).
      Parameters:
      pc - The persistable object
      Returns:
      Whether it is managed
    • getStateManager

      default StateManager getStateManager(Object pc)
      Accessor for the state manager for the object.
      Parameters:
      pc - The object
      Returns:
      The StateManager managing this object
    • getExecutionContext

      ExecutionContext getExecutionContext(Object pc)
      Method to return the ExecutionContext (if any) associated with the passed object. Supports persistable objects, and PersistenceManager.
      Parameters:
      pc - The object
      Returns:
      The ExecutionContext
    • getLifeCycleState

      LifeCycleState getLifeCycleState(int stateType)
      Returns the LifeCycleState for the state constant.
      Parameters:
      stateType - the type as integer
      Returns:
      the type as LifeCycleState object
    • isPersistent

      default boolean isPersistent(Object obj)
      Accessor for whether the passed object is persistent.
      Parameters:
      obj - The object
      Returns:
      Whether it is persistent
    • isNew

      default boolean isNew(Object obj)
      Accessor for whether the passed object is new.
      Parameters:
      obj - The object
      Returns:
      Whether it is new
    • isDirty

      default boolean isDirty(Object obj)
      Accessor for whether the passed object is dirty.
      Parameters:
      obj - The object
      Returns:
      Whether it is dirty
    • isDeleted

      default boolean isDeleted(Object obj)
      Accessor for whether the passed object is deleted.
      Parameters:
      obj - The object
      Returns:
      Whether it is deleted
    • isDetached

      default boolean isDetached(Object obj)
      Accessor for whether the passed object is detached.
      Parameters:
      obj - The object
      Returns:
      Whether it is detached
    • isTransactional

      default boolean isTransactional(Object obj)
      Accessor for whether the passed object is transactional.
      Parameters:
      obj - The object
      Returns:
      Whether it is transactional
    • isPersistable

      default boolean isPersistable(Object obj)
      Method to return if the passed object is persistable using this API.
      Parameters:
      obj - The object
      Returns:
      Whether it is persistable
    • isPersistable

      default boolean isPersistable(Class cls)
      Utility method to check if the specified class is of a type that can be persisted for this API.
      Parameters:
      cls - The class to check
      Returns:
      Whether the class is persistable using this API.
    • isDetachable

      default boolean isDetachable(Object obj)
      Method to return if the passed object is detachable using this API.
      Parameters:
      obj - The object
      Returns:
      Whether it is detachable
    • getObjectState

      default String getObjectState(Object pc)
      Accessor for the object state.
      Parameters:
      pc - Persistable object
      Returns:
      The state ("persistent-clean", "detached-dirty" etc)
    • makeDirty

      default void makeDirty(Object obj, String member)
      Method to make the member of the persistable object dirty.
      Parameters:
      obj - The object
      member - Name of the member
    • getIdForObject

      default Object getIdForObject(Object obj)
      Method to return the object identity for the passed persistable object. Returns null if it is not persistable, or has no identity.
      Parameters:
      obj - The object
      Returns:
      The identity
    • getVersionForObject

      default Object getVersionForObject(Object obj)
      Method to return the object version for the passed persistable object. Returns null if it is not persistable, or not versioned.
      Parameters:
      obj - The object
      Returns:
      The version
    • isValidPrimaryKeyClass

      boolean isValidPrimaryKeyClass(Class pkClass, AbstractClassMetaData cmd, ClassLoaderResolver clr, int noOfPkFields, MetaDataManager mmgr)
      Utility to check if a primary-key class is valid. Will throw a InvalidPrimaryKeyException if it is invalid, otherwise returning true.
      Parameters:
      pkClass - The Primary Key class
      cmd - AbstractClassMetaData for the persistable class
      clr - the ClassLoaderResolver
      noOfPkFields - Number of primary key fields
      mmgr - MetaData manager
      Returns:
      Whether it is valid
    • copyKeyFieldsFromIdToObject

      default void copyKeyFieldsFromIdToObject(Object pc, Persistable.ObjectIdFieldConsumer fm, Object id)
      Method to set the pk fields of the object from the provided identity.
      Parameters:
      pc - The persistable object
      fm - ObjectIdFieldConsumer
      id - The identity
    • allowPersistOfDeletedObject

      boolean allowPersistOfDeletedObject()
      Whether the API allows (re-)persistence of a deleted object.
      Returns:
      Whether you can call persist on a deleted object
    • allowDeleteOfNonPersistentObject

      boolean allowDeleteOfNonPersistentObject()
      Whether the API allows deletion of a non-persistent object.
      Returns:
      Whether you can call delete on an object not yet persisted
    • allowReadFieldOfDeletedObject

      boolean allowReadFieldOfDeletedObject()
      Whether the API allows reading a field of a deleted object.
      Returns:
      Whether you can read after deleting
    • clearLoadedFlagsOnDeleteObject

      boolean clearLoadedFlagsOnDeleteObject()
      Whether the API requires clearing of the fields of an object when it is deleted.
      Returns:
      Whether to clear loaded fields at delete
    • getDefaultCascadePersistForField

      boolean getDefaultCascadePersistForField()
      Method to return the default setting for cascading persist of a field
      Returns:
      default persist cascade setting.
    • getDefaultCascadeDeleteForField

      boolean getDefaultCascadeDeleteForField()
      Method to return the default setting for cascading delete of a field
      Returns:
      default cascade delete setting.
    • getDefaultCascadeAttachForField

      boolean getDefaultCascadeAttachForField()
      Method to return the default setting for cascading attach of a field
      Returns:
      default cascade attach setting.
    • getDefaultCascadeDetachForField

      boolean getDefaultCascadeDetachForField()
      Method to return the default setting for cascading detach of a field
      Returns:
      default cascade detach setting.
    • getDefaultCascadeRefreshForField

      boolean getDefaultCascadeRefreshForField()
      Method to return the default setting for cascading refresh of a field
      Returns:
      default cascade refresh setting.
    • getDefaultDFGForPersistableField

      boolean getDefaultDFGForPersistableField()
      Method to return the default DFG setting for a persistable field.
      Returns:
      DFG default for persistable field
    • getDefaultFactoryProperties

      Map<String,Object> getDefaultFactoryProperties()
      Method to return a set of default properties for the factory (PMF, EMF, etc)
      Returns:
      The default properties (if any) for this API
    • getDefaultPersistentPropertyWhenNotSpecified

      boolean getDefaultPersistentPropertyWhenNotSpecified()
      Whether we should add in metadata when using persistent properties and a property is not specified. True means we add in metadata when not explicitly specified. False means if a property is not defined then it is not persistent.
      Returns:
      Whether to default it (JDO = false, JPA/Jakarta = true)
    • getApiExceptionForNucleusException

      RuntimeException getApiExceptionForNucleusException(NucleusException ne)
      Convenience method to convert the passed NucleusException into an exception for the API.
      Parameters:
      ne - The NucleusException
      Returns:
      The Api Exception
    • getUserExceptionForException

      RuntimeException getUserExceptionForException(String msg, Exception e)
      Convenience method to return a user exception appropriate for this API when an unexpected exception occurs.
      Parameters:
      msg - The message
      e - The cause (if any)
      Returns:
      The API exception
    • getDataStoreExceptionForException

      RuntimeException getDataStoreExceptionForException(String msg, Exception e)
      Convenience method to return a datastore exception appropriate for this API.
      Parameters:
      msg - The message
      e - The cause (if any)
      Returns:
      The exception