Class DefaultMOPersistenceProvider

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getDefaultURI​()
      Gets the URI of the default persistent storage for this provider.
      java.lang.String getPersistenceProviderID​()
      Returns an unique ID of the persistence provider which should identify the format and type of the persistence provider.
      boolean isValidPersistenceURI​(java.lang.String uri)
      Checks whether the supplied URI string is valid for this persistence provider.
      void restore​(java.lang.String uri, int importMode)
      Restore (load) agent state from the specified file URI or file name.
      void store​(java.lang.String uri)
      Stores the current agent state to persistent storage specified by the supplied URI.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultMOPersistenceProvider

        public DefaultMOPersistenceProvider​(MOServer[] server,
                                            java.lang.String defaultURI)
        Creates a persistence provider for the supplied MOServer instances. The content and state of the managed objects of those servers are subject to store(java.lang.String) and restore(java.lang.String, int) operations.
        Parameters:
        server - an array of MOServer instances (possibly empty).
        defaultURI - the (optional) default URI (i.e., file path) to be used for this persistence provider.
    • Method Detail

      • getPersistenceProviderID

        public java.lang.String getPersistenceProviderID​()
        Returns an unique ID of the persistence provider which should identify the format and type of the persistence provider.
        Specified by:
        getPersistenceProviderID in interface MOPersistenceProvider
        Returns:
        "default".
      • isValidPersistenceURI

        public boolean isValidPersistenceURI​(java.lang.String uri)
        Checks whether the supplied URI string is valid for this persistence provider.
        Specified by:
        isValidPersistenceURI in interface MOPersistenceProvider
        Parameters:
        uri - a string identifying a persistent storage location for this storage provider.
        Returns:
        true if the uri is valid, false otherwise.
      • restore

        public void restore​(java.lang.String uri,
                            int importMode)
                     throws java.io.IOException
        Restore (load) agent state from the specified file URI or file name.
        Specified by:
        restore in interface MOPersistenceProvider
        Parameters:
        uri - a string pointing to the persistent storage file from which the agent state should be restored from. The format of he string is either a simple file name or an URI starting with "file:".
        importMode - specifies how the agent's current state should be update while restoring a previous state.
        Throws:
        java.io.IOException - if the restore operation fails.
      • store

        public void store​(java.lang.String uri)
                   throws java.io.IOException
        Stores the current agent state to persistent storage specified by the supplied URI.
        Specified by:
        store in interface MOPersistenceProvider
        Parameters:
        uri - a string pointing to the persistent storage file to use. The format of he string is either a simple file name or an URI starting with "file:".
        Throws:
        java.io.IOException - if the store operation fails.
      • getDefaultURI

        public java.lang.String getDefaultURI​()
        Description copied from interface: MOPersistenceProvider
        Gets the URI of the default persistent storage for this provider.
        Specified by:
        getDefaultURI in interface MOPersistenceProvider
        Returns:
        the URI (e.g. file path) for the default persistent storage location of this provider. A provider may use a different one. A null value indicates that there is no default location.