Package com.iizix.license
Class LicenseSystem
- java.lang.Object
- com.iizix.license.LicenseSystem
public class LicenseSystem extends java.lang.ObjectInstance used to load the license system.- Author:
- Christopher Mindus
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]PRODUCTSThe product names according to:
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
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.IOExceptionPrepares 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.IOExceptionPrepares 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.ThrowableGets 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.IOExceptionConverts 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.IOExceptionReturns 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.