Class SerialisedLocalFileMapping

  • All Implemented Interfaces:
    MappingCallbacks

    public class SerialisedLocalFileMapping
    extends JavaTypeMapping
    implements MappingCallbacks
    Mapping where we want to serialise a (Serializable) field to a local file. Since the field will be stored in the local file system then this will have no "datastore mapping" (i.e column) as such. The user defines the folder in which values of this field will be stored in metadata, and the filename in that folder is basically the "id" of the owning object. Assumes that the user is not storing multiple fields in the same folder.

    Handling roll back

    Whenever an insert/update/delete is performed it registers a listener on any active transaction and allows a hook to attempt to roll back any changes to the value before that operation.
    • Constructor Detail

      • SerialisedLocalFileMapping

        public SerialisedLocalFileMapping()
    • Method Detail

      • initialize

        public void initialize​(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                               Table table,
                               org.datanucleus.ClassLoaderResolver clr)
        Description copied from class: JavaTypeMapping
        Initialize this JavaTypeMapping for the supplied table and field/property metadata. Subclasses should override this method to perform any datastore initialization operations. Assumes the "roleForMember" is already set
        Overrides:
        initialize in class JavaTypeMapping
        Parameters:
        mmd - MetaData for the field/property to be mapped (if any)
        table - The table storing this mapping (if any)
        clr - the ClassLoaderResolver
      • includeInFetchStatement

        public boolean includeInFetchStatement()
        Description copied from class: JavaTypeMapping
        Accessor for whether this mapping is to be included in any fetch statement.
        Overrides:
        includeInFetchStatement in class JavaTypeMapping
        Returns:
        Whether to include this mapping in a fetch statement
      • includeInUpdateStatement

        public boolean includeInUpdateStatement()
        Description copied from class: JavaTypeMapping
        Accessor for whether this mapping is to be included in the update statement.
        Overrides:
        includeInUpdateStatement in class JavaTypeMapping
        Returns:
        Whether to include in update statement
      • includeInInsertStatement

        public boolean includeInInsertStatement()
        Description copied from class: JavaTypeMapping
        Accessor for whether this mapping is to be included in the insert statement.
        Overrides:
        includeInInsertStatement in class JavaTypeMapping
        Returns:
        Whether to include in insert statement
      • getJavaType

        public Class getJavaType()
        Description copied from class: JavaTypeMapping
        Accessor for the java type being mapped. This is the java type that the mapping represents. Some examples :
        • if the field is of type "MyClass" then the mapping will be OIDMapping (or subclass) the javaType will be OID, and the type will be MyClass.
        • if the field is of type "int" then the mapping will be IntegerMapping, the javaType will be Integer, and the type will be int.
        The "java type" is the java-type name used in the plugin.xml mapping file
        Specified by:
        getJavaType in class JavaTypeMapping
        Returns:
        The java type
      • postInsert

        public void postInsert​(org.datanucleus.state.DNStateManager sm)
        Description copied from interface: MappingCallbacks
        Method called after the insert of the object so that additional operations can be performed if necessary.
        Specified by:
        postInsert in interface MappingCallbacks
        Parameters:
        sm - StateManager of the owner
      • postFetch

        public void postFetch​(org.datanucleus.state.DNStateManager sm)
        Description copied from interface: MappingCallbacks
        Method called after the retrieval of the object, so that additional operations can be performed if necessary.
        Specified by:
        postFetch in interface MappingCallbacks
        Parameters:
        sm - StateManager of the owner
      • postUpdate

        public void postUpdate​(org.datanucleus.state.DNStateManager sm)
        Description copied from interface: MappingCallbacks
        Method called after the update of the object, so that additional operations can be performed if necessary.
        Specified by:
        postUpdate in interface MappingCallbacks
        Parameters:
        sm - StateManager of the owner
      • preDelete

        public void preDelete​(org.datanucleus.state.DNStateManager sm)
        Description copied from interface: MappingCallbacks
        Method called before the delete of objects, so that additional operations can be performed if necessary.
        Specified by:
        preDelete in interface MappingCallbacks
        Parameters:
        sm - StateManager of the owner
      • getFilenameForStateManager

        protected String getFilenameForStateManager​(org.datanucleus.state.DNStateManager sm)
      • serialiseFieldValue

        protected void serialiseFieldValue​(org.datanucleus.state.DNStateManager sm,
                                           Object value)
        Method to serialise the value from StateManager to file.
        Parameters:
        sm - StateManager
        value - The value being serialised
      • deserialiseFieldValue

        protected Object deserialiseFieldValue​(org.datanucleus.state.DNStateManager sm)
        Method to deserialise the value from file and return it.
        Parameters:
        sm - StateManager to get the value for
        Returns:
        The value currently stored