Interface Initializable

  • All Known Implementing Classes:
    DBInitializer, FSInitializer, MemoryStore.MSInitializer, SQLDBInitializer, StoreInitializer, TableInitializer

    public interface Initializable
    An interface for getting clean semantics on creation, initialization and destruction of things. The issue is that things -- like databases and other persistent stores -- must have a separate creation/initialization mechanisms unlike simple Java object instantiation where both occur at once.
    This interface organizes this.

    NOTE: A failure means that the returned value is false rather than true! In case of bona fide errors applications should throw the specific runtime exception or wrap it in a GeneralException. An example would be if this is implemented against a database and no connection exists.

    Lifecycle

    Generally create and destroy are called at most once in the lifecycle, where init() can be called whenever the state needs to be reset.

    Created by Jeff Gaynor
    on May 10, 2010 at 8:29:51 AM

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean createNew()
      Creates a completely new instance.
      boolean destroy()
      Destroy the object completely.
      boolean init()
      Initialize an existing object.
      boolean isCreated()
      (Optional) Returns true if the object in question has been created.
      boolean isDestroyed()
      (Optional) Returns true if the object in question has been destroyed.
      boolean isInitialized()
      (Optional) Returns true if the object in question has been initialized.
    • Method Detail

      • destroy

        boolean destroy()
        Destroy the object completely. Returns true if the object existed before destroy was called. Further calls to this object must fail after this invocation.
      • init

        boolean init()
        Initialize an existing object. This throws an exception if the object does not exist. The state after this call is exactly as if the system were created for the first time. Calls to the object before invocation have no guarantee of success.
        Returns:
        Returns True if the operation succeeds.
      • createNew

        boolean createNew()
        Creates a completely new instance. Fails if an instance already exists. In that case, call destroy first. For instance, this might create all file system entries or drop then recreate all tables in an SQL database. Compare this with init which might delete any entries in a file store or SQL table.
        Returns:
      • isCreated

        boolean isCreated()
        (Optional) Returns true if the object in question has been created. If this cannot be determined then the call should throw an exception.
        Returns:
      • isInitialized

        boolean isInitialized()
        (Optional) Returns true if the object in question has been initialized. If this cannot be determined this call should throw an exception.
        Returns:
      • isDestroyed

        boolean isDestroyed()
        (Optional) Returns true if the object in question has been destroyed. If this cannot be determined this call should throw an exception.
        Returns: