Interface MkStorage

  • All Known Implementing Classes:
    MkStorage.InFile, MkStorage.Synced

    @Immutable
    public interface MkStorage
    Storage of Github data.
    Since:
    0.5
    Version:
    $Id: 8d3511aa22eca3380a6e4d1da06a28c8a40b9da0 $
    Author:
    Yegor Bugayenko (yegor256@gmail.com)
    Suppressed Checkstyle violations:
    MultipleStringLiteralsCheck (200 lines)
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  MkStorage.InFile
      In file.
      static class  MkStorage.Synced
      Syncronized.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void apply​(Iterable<org.xembly.Directive> dirs)
      Update XML with this directives.
      void lock()
      Locks storage to the current thread.
      void unlock()
      Unlock storage.
      com.jcabi.xml.XML xml()
      Get full XML.
    • Method Detail

      • xml

        com.jcabi.xml.XML xml()
                       throws IOException
        Get full XML.
        Returns:
        XML
        Throws:
        IOException - If there is any I/O problem, or if the current storage is locked by another thread.
      • apply

        void apply​(Iterable<org.xembly.Directive> dirs)
            throws IOException
        Update XML with this directives.
        Parameters:
        dirs - Directives
        Throws:
        IOException - If there is any I/O problem, or if the current storage is locked by another thread.
      • lock

        void lock()
           throws IOException
        Locks storage to the current thread.

        If the lock is available, grant it to the calling thread and block all operations from other threads. If not available, wait for the holder of the lock to release it with unlock() before any other operations can be performed.

        Locking behavior is reentrant, which means a thread can invoke lock() multiple times, where a hold count is maintained.

        Throws:
        IOException - If there is any I/O problem
      • unlock

        void unlock()
             throws IOException
        Unlock storage.

        Locking behavior is reentrant, thus if the thread invoked lock() multiple times, the hold count is decremented. If the hold count reaches 0, the lock is released.

        If the current thread does not hold the lock, an IllegalMonitorStateException will be thrown.

        Throws:
        IOException - If there is any I/O problem