Class LicenseSystem


  • public class LicenseSystem
    extends java.lang.Object
    Instance used to load the license system.
    Author:
    Christopher Mindus
    • Field Summary

      Fields 
      Modifier and TypeFieldDescription
      static java.lang.String[]PRODUCTS
      The product names according to:
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static voidassignWebServerRoot​(java.io.File root)
      Assigns the web server root directory for the license system.
      voidcleanUp()
      Cleans up any temporary files and directories.
      static java.lang.StringformatProduct​(int product)
      Formats the product.
      static LicenseSystemgetInstance()
      Gets the instance of license system.
      static LicenseSystemgetInstance​(java.lang.Object caller)
      Gets the instance of license system.
      <T> TgetInstanceImplementation​(java.lang.Object caller, java.lang.Class<T> implClass)
      Gets the instance of the license system implementation.
      static java.lang.StringgetProfilePictureAsString​(java.io.File file)
      Converts a profile picture file of file extension ".png", ".jpg" or ".jpeg" to a Base64 encoded string with the file name.
      static byte[]getProfilePictureFromString​(java.lang.String string, java.lang.StringBuilder buf)
      Returns a Base64 encoded profile picture as a byte array that can be written to file.
      booleanprepare​(java.lang.Object lock)
      Prepares the license system.
      booleanprepare​(java.lang.Object lock, java.lang.Class<?> loader)
      Prepares the license system.
      • Methods inherited from class java.lang.Object

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

      • PRODUCTS

        public static final java.lang.String[] PRODUCTS
        The product names according to:

        0=other,
        1=designer,
        2=development server,
        3=standard production server,
        4=container production server (J2EE or other), or
        5=cluster.

    • Method Detail

      • formatProduct

        public static java.lang.String formatProduct​(int product)
        Formats the product.
        Parameters:
        product - The produce code as:

        0=other,
        1=designer,
        2=development server,
        3=standard production server,
        4=container production server (J2EE or other), or
        5=cluster.

        Returns:
        The name of the product.
      • getInstance

        public static LicenseSystem getInstance()
        Gets the instance of license system.
        Returns:
        The instance of the LicenseSystem.
      • getInstance

        public static LicenseSystem getInstance​(java.lang.Object caller)
        Gets the instance of license system.
        Parameters:
        caller - The special caller Object for testing, null for none.
        Returns:
        The instance of the LicenseSystem.
      • assignWebServerRoot

        public static void assignWebServerRoot​(java.io.File root)
        Assigns the web server root directory for the license system.
        Parameters:
        root - The root directory.
      • prepare

        public boolean prepare​(java.lang.Object lock)
                        throws java.io.IOException
        Prepares the license system.
        Parameters:
        lock - The lock object for synchronization.
        Returns:
        Success flag (or failure).
        Throws:
        java.io.IOException - For I/O exception preparing the license system.
      • prepare

        public boolean prepare​(java.lang.Object lock,
                               java.lang.Class<?> loader)
                        throws java.io.IOException
        Prepares the license system.
        Parameters:
        lock - The lock object for synchronization.
        loader - The class used for class loading, null for default.
        Returns:
        Success flag (or failure).
        Throws:
        java.io.IOException - For I/O exception preparing the license system.
      • getInstanceImplementation

        public <T> T getInstanceImplementation​(java.lang.Object caller,
                                               java.lang.Class<T> implClass)
                                        throws java.lang.Throwable
        Gets the instance of the license system implementation.
        Parameters:
        caller - The caller.
        implClass - The implementation interface class.
        Throws:
        java.lang.Throwable - For errors in initialization.
      • cleanUp

        public void cleanUp()
        Cleans up any temporary files and directories.
      • getProfilePictureAsString

        public static java.lang.String getProfilePictureAsString​(java.io.File file)
                                                          throws java.io.IOException
        Converts a profile picture file of file extension ".png", ".jpg" or ".jpeg" to a Base64 encoded string with the file name.
        Parameters:
        file - The profile picture file (maximum size 1 MB).
        Returns:
        The Base64 encoded String that includes the file name part.
        Throws:
        java.io.FileNotFoundException - If file is not found.
        java.io.IOException - For read errors.
      • getProfilePictureFromString

        public static byte[] getProfilePictureFromString​(java.lang.String string,
                                                         java.lang.StringBuilder buf)
                                                  throws java.io.IOException
        Returns a Base64 encoded profile picture as a byte array that can be written to file.
        Parameters:
        string - The Base64 encoded string of the profile picture.
        buf - Buffer that is filled with the file name upon return, null for none (file name is ignored).
        Throws:
        java.io.IOException - If the string is badly encoded.