org.modeshape.jcr.value.binary.infinispan

## Class InfinispanBinaryStore

- java.lang.Object
- - org.modeshape.jcr.value.binary.AbstractBinaryStore
  - - org.modeshape.jcr.value.binary.infinispan.InfinispanBinaryStore

- All Implemented Interfaces:
    BinaryStore

      @ThreadSafe
      public final class InfinispanBinaryStore
      extends AbstractBinaryStore

  A `BinaryStore` implementation that uses Infinispan for persisting binary values.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `InfinispanBinaryStore.DummyReducer`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Cache<String,byte[]>` | `blobCache`
    `static int` | `DEFAULT_CHUNK_SIZE`
    `protected org.modeshape.jcr.value.binary.infinispan.InfinispanBinaryStore.LockFactory` | `lockFactory`
    `protected Cache<String,Metadata>` | `metadataCache`

    - ### Fields inherited from class org.modeshape.jcr.value.binary.AbstractBinaryStore

      `logger, MEDIUM_BUFFER_SIZE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InfinispanBinaryStore(CacheContainer cacheContainer, boolean dedicatedCacheContainer, String metadataCacheName, String blobCacheName)` Creates a new instance.
    `InfinispanBinaryStore(CacheContainer cacheContainer, boolean dedicatedCacheContainer, String metadataCacheName, String blobCacheName, int chunkSize)` Creates a new instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected BinaryKey` | `binaryKeyFromCacheKey(String key)`
    `protected String` | `dataKeyFrom(BinaryKey key)`
    `Iterable<BinaryKey>` | `getAllBinaryKeys()` Obtain an iterable implementation containing all of the store's binary keys.
    `List<Cache<?,?>>` | `getCaches()`
    `String` | `getExtractedText(BinaryValue binary)` Returns the extracted text of a binary value, or `null` if such text hasn't been stored previously (but the binary value can be found in the store)
    `InputStream` | `getInputStream(BinaryKey binaryKey)` Get an `InputStream` to the binary content with the supplied key.
    `protected String` | `getStoredMimeType(BinaryValue binary)` Returns the stored mime-type of a binary value.
    `protected boolean` | `isMetadataKey(String str)`
    `protected String` | `lockKeyFrom(BinaryKey key)`
    `void` | `markAsUnused(Iterable<BinaryKey> keys)` Mark the supplied binary keys as unused, but key them in quarantine until needed again (at which point they're removed from quarantine) or until `BinaryStore.removeValuesUnusedLongerThan(long, TimeUnit)` is called.
    `protected String` | `metadataKeyFrom(BinaryKey key)`
    `void` | `removeValuesUnusedLongerThan(long minimumAge, TimeUnit unit)` Remove binary values that have been `unused` for at least the specified amount of time.
    `void` | `shutdown()` Shuts down the store.
    `void` | `start()` Initialize the store and get ready for use.
    `void` | `storeExtractedText(BinaryValue binary, String extractedText)` Stores the extracted text of a binary value into this store.
    `protected void` | `storeMimeType(BinaryValue binary, String mimeType)` Stores the given mime-type for a binary value.
    `BinaryValue` | `storeValue(InputStream inputStream)` Store the binary value and return the JCR representation.
    `protected String` | `textKeyFrom(BinaryKey key)`

    - ### Methods inherited from class org.modeshape.jcr.value.binary.AbstractBinaryStore

      `bestBufferSize, detector, extractors, getMimeType, getMinimumBinarySizeInBytes, getText, hasBinary, setMimeTypeDetector, setMinimumBinarySizeInBytes, setTextExtractors, storeValue`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_CHUNK_SIZE

          public static final int DEFAULT_CHUNK_SIZE

      See Also:
        Constant Field Values

    - #### metadataCache

          protected Cache<String,Metadata> metadataCache

    - #### lockFactory

          protected org.modeshape.jcr.value.binary.infinispan.InfinispanBinaryStore.LockFactory lockFactory

    - #### blobCache

          protected Cache<String,byte[]> blobCache

  - ### Constructor Detail

    - #### InfinispanBinaryStore

          public InfinispanBinaryStore(CacheContainer cacheContainer,
                               boolean dedicatedCacheContainer,
                               String metadataCacheName,
                               String blobCacheName)

      Creates a new instance.
      Parameters:
        `cacheContainer` - cache container which used for cache management
        `dedicatedCacheContainer` - true if the cache container should be started/stopped when store is start or stopped
        `metadataCacheName` - name of the cache used for metadata
        `blobCacheName` - name of the cache used for store of chunked binary values

    - #### InfinispanBinaryStore

          public InfinispanBinaryStore(CacheContainer cacheContainer,
                               boolean dedicatedCacheContainer,
                               String metadataCacheName,
                               String blobCacheName,
                               int chunkSize)

      Creates a new instance.
      Parameters:
        `cacheContainer` - cache container which used for cache management
        `dedicatedCacheContainer` - true if the cache container should be started/stopped when store is start or stopped
        `metadataCacheName` - name of the cache used for metadata
        `blobCacheName` - name of the cache used for store of chunked binary values
        `chunkSize` - the size (in bytes) of a chunk

  - ### Method Detail

    - #### lockKeyFrom

          protected final String lockKeyFrom(BinaryKey key)

    - #### metadataKeyFrom

          protected final String metadataKeyFrom(BinaryKey key)

    - #### dataKeyFrom

          protected final String dataKeyFrom(BinaryKey key)

    - #### textKeyFrom

          protected final String textKeyFrom(BinaryKey key)

    - #### isMetadataKey

          protected final boolean isMetadataKey(String str)

    - #### binaryKeyFromCacheKey

          protected final BinaryKey binaryKeyFromCacheKey(String key)

    - #### start

          public void start()

      Description copied from interface: `BinaryStore`
      Initialize the store and get ready for use.
      Specified by:
        `start` in interface `BinaryStore`
      Overrides:
        `start` in class `AbstractBinaryStore`

    - #### shutdown

          public void shutdown()

      Description copied from interface: `BinaryStore`
      Shuts down the store.
      Specified by:
        `shutdown` in interface `BinaryStore`
      Overrides:
        `shutdown` in class `AbstractBinaryStore`

    - #### getCaches

          public List<Cache<?,?>> getCaches()

    - #### storeValue

          public BinaryValue storeValue(InputStream inputStream)
                                 throws BinaryStoreException,
                                        SystemFailureException

      Description copied from interface: `BinaryStore`
      Store the binary value and return the JCR representation. Note that if the binary content in the supplied stream is already persisted in the store, the store may simply return the binary value referencing the existing content.
      Parameters:
        `inputStream` - the stream containing the binary content to be stored; may not be null
      Returns:
        the binary value representing the stored binary value; never null
      Throws:
        `BinaryStoreException` - if there any unexpected problem
        `SystemFailureException`

    - #### getInputStream

          public InputStream getInputStream(BinaryKey binaryKey)
                                     throws BinaryStoreException

      Description copied from interface: `BinaryStore`
      Get an `InputStream` to the binary content with the supplied key.
      Parameters:
        `binaryKey` - the key to the binary content; never null
      Returns:
        the input stream through which the content can be read, `never null`
      Throws:
        `BinaryStoreException` - if there is a problem reading the content from the store or if a valid, non-null `InputStream` cannot be returned for the given key.

    - #### markAsUnused

          public void markAsUnused(Iterable<BinaryKey> keys)
                            throws BinaryStoreException

      Description copied from interface: `BinaryStore`
      Mark the supplied binary keys as unused, but key them in quarantine until needed again (at which point they're removed from quarantine) or until `BinaryStore.removeValuesUnusedLongerThan(long, TimeUnit)` is called. This method ignores any keys for values not stored within this store.
      Parameters:
        `keys` - the keys for the binary values that are no longer needed
      Throws:
        `BinaryStoreException` - if there is a problem marking any of the supplied binary values as unused

    - #### removeValuesUnusedLongerThan

          public void removeValuesUnusedLongerThan(long minimumAge,
                                          TimeUnit unit)
                                            throws BinaryStoreException

      Description copied from interface: `BinaryStore`
      Remove binary values that have been `unused` for at least the specified amount of time.
      Parameters:
        `minimumAge` - the minimum time that a binary value has been `unused` before it can be removed; must be non-negative
        `unit` - the time unit for the minimum age; may not be null
      Throws:
        `BinaryStoreException` - if there is a problem removing the unused values

    - #### getStoredMimeType

          protected String getStoredMimeType(BinaryValue binary)
                                      throws BinaryStoreException

      Description copied from class: `AbstractBinaryStore`
      Returns the stored mime-type of a binary value.
      Specified by:
        `getStoredMimeType` in class `AbstractBinaryStore`
      Parameters:
        `binary` - a `non-null` `BinaryValue`
      Returns:
        either a non-empty `String` if a stored mimetype exists, or `null` if such a value doesn't exist yet.
      Throws:
        `BinaryStoreException` - if there's a problem accessing the binary store or if the binary value cannot be found in the store

    - #### storeMimeType

          protected void storeMimeType(BinaryValue binary,
                           String mimeType)
                                throws BinaryStoreException

      Description copied from class: `AbstractBinaryStore`
      Stores the given mime-type for a binary value.
      Specified by:
        `storeMimeType` in class `AbstractBinaryStore`
      Parameters:
        `binary` - a `non-null` `BinaryValue`
        `mimeType` - a non-empty `String`
      Throws:
        `BinaryStoreException` - if there's a problem accessing the binary store

    - #### getExtractedText

          public String getExtractedText(BinaryValue binary)
                                  throws BinaryStoreException

      Description copied from class: `AbstractBinaryStore`
      Returns the extracted text of a binary value, or `null` if such text hasn't been stored previously (but the binary value can be found in the store)
      Specified by:
        `getExtractedText` in class `AbstractBinaryStore`
      Parameters:
        `binary` - a `non-null` `BinaryValue` instance from which the text was extracted
      Returns:
        a `String` representing the extracted text, or `null` if such text hasn't been stored in this store previously.
      Throws:
        `BinaryStoreException` - if the binary value cannot be found in the store.

    - #### storeExtractedText

          public void storeExtractedText(BinaryValue binary,
                                String extractedText)
                                  throws BinaryStoreException

      Description copied from class: `AbstractBinaryStore`
      Stores the extracted text of a binary value into this store.
      Specified by:
        `storeExtractedText` in class `AbstractBinaryStore`
      Parameters:
        `binary` - a `non-null` `BinaryValue` instance from which the text was extracted
        `extractedText` - a `non-null` and `non-blank` string representing the extracted text
      Throws:
        `BinaryStoreException` - if the operation fails or if the extracted text cannot be stored for the given binary value (regardless of the reason)

    - #### getAllBinaryKeys

          public Iterable<BinaryKey> getAllBinaryKeys()
                                               throws BinaryStoreException

      Description copied from interface: `BinaryStore`
      Obtain an iterable implementation containing all of the store's binary keys. The resulting iterator may be lazy, in the sense that it may determine additional `BinaryKey`s only as the iterator is used.
      Returns:
        the iterable set of binary keys; never null
      Throws:
        `BinaryStoreException` - if anything unexpected happens.

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.