Class BufferRecyclers


  • public class BufferRecyclers
    extends java.lang.Object
    Helper entity used to control access to simple buffer recyling scheme used for some encoding, decoding tasks.
    Since:
    2.9.2
    See Also:
    BufferRecycler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS
      System property that is checked to see if recycled buffers (see BufferRecycler) should be tracked, for purpose of forcing release of all such buffers, typically during major classloading.
    • Constructor Summary

      Constructors 
      Constructor Description
      BufferRecyclers()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static byte[] encodeAsUTF8​(java.lang.String text)
      Deprecated.
      Since 2.10 (note: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)
      static BufferRecycler getBufferRecycler()
      Main accessor to call for accessing possibly recycled BufferRecycler instance.
      static JsonStringEncoder getJsonStringEncoder()
      Deprecated.
      Since 2.10 (note: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)
      static void quoteAsJsonText​(java.lang.CharSequence input, java.lang.StringBuilder output)
      Deprecated.
      Since 2.10 (note: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)
      static char[] quoteAsJsonText​(java.lang.String rawText)
      Deprecated.
      Since 2.10 (note: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)
      static byte[] quoteAsJsonUTF8​(java.lang.String rawText)
      Deprecated.
      Since 2.10 (note: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)
      static int releaseBuffers()
      Specialized method that will release all recycled BufferRecycler if (and only if) recycler tracking has been enabled (see SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS).
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS

        public static final java.lang.String SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS
        System property that is checked to see if recycled buffers (see BufferRecycler) should be tracked, for purpose of forcing release of all such buffers, typically during major classloading.
        Since:
        2.9.6
        See Also:
        Constant Field Values
    • Constructor Detail

      • BufferRecyclers

        public BufferRecyclers()
    • Method Detail

      • releaseBuffers

        public static int releaseBuffers()
        Specialized method that will release all recycled BufferRecycler if (and only if) recycler tracking has been enabled (see SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS). This method is usually called on shutdown of the container like Application Server to ensure that no references are reachable via ThreadLocals as this may cause unintentional retention of sizable amounts of memory. It may also be called regularly if GC for some reason does not clear up SoftReferences aggressively enough.
        Returns:
        Number of buffers released, if tracking enabled (zero or more); -1 if tracking not enabled.
        Since:
        2.9.6
      • getJsonStringEncoder

        @Deprecated
        public static JsonStringEncoder getJsonStringEncoder()
        Deprecated.
        Since 2.10 (note: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)
        Not to be used any more: call JsonStringEncoder.getInstance() instead.
        Returns:
        JsonStringEncoder instance to use.
      • encodeAsUTF8

        @Deprecated
        public static byte[] encodeAsUTF8​(java.lang.String text)
        Deprecated.
        Since 2.10 (note: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)
        Not to be used any more: call JsonStringEncoder.getInstance() (and then encodeAsUTF8()) instead.
        Parameters:
        text - String to encode
        Returns:
        String encoded as UTF-8 bytes.
      • quoteAsJsonText

        @Deprecated
        public static char[] quoteAsJsonText​(java.lang.String rawText)
        Deprecated.
        Since 2.10 (note: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)
        Not to be used any more: call JsonStringEncoder.getInstance() (and then quoteAsString()) instead.
        Parameters:
        rawText - String to quote
        Returns:
        Quoted text as char[]
      • quoteAsJsonText

        @Deprecated
        public static void quoteAsJsonText​(java.lang.CharSequence input,
                                           java.lang.StringBuilder output)
        Deprecated.
        Since 2.10 (note: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)
        Not to be used any more: call JsonStringEncoder.getInstance() (and then quoteAsString()) instead.
        Parameters:
        input - Textual content to quote
        output - Builder to append quoted content
      • quoteAsJsonUTF8

        @Deprecated
        public static byte[] quoteAsJsonUTF8​(java.lang.String rawText)
        Deprecated.
        Since 2.10 (note: was accidentally removed but reintroduced as deprecated in 2.12.5, to be removed from 3.0)
        Not to be used any more: call JsonStringEncoder.getInstance() (and then quoteAsUTF8()) instead.
        Parameters:
        rawText - String to quote
        Returns:
        Quoted text as byte[]