com.chainkey.jchain.sa.licensor
Class LicenseManager

java.lang.Object
  |
  +--com.chainkey.jchain.sa.licensor.LicenseManager

public final class LicenseManager
extends java.lang.Object

The class for managing the product licenses on licensors' side.

* You don't have to use this API, if the JChain Management Panel is enough for your purpose. Please check out the JChain Management Panel first.

Since:
JChain SA v1.0
Version:
1.6.5
Author:
ChainKey, Inc.

Method Summary
 java.sql.ResultSet executeQuery(java.lang.String sqlStatement)
          Executes SQL query for the user database.
 int executeUpdate(java.lang.String sqlStatement)
          Executes SQL update (INSERT, UPDATE or DELETE) for the user database.
 java.lang.String[] generateSerialNumbers(int productNumber, int num, java.lang.String filePath, boolean append)
          Generates serial numbers at once and writes them to a specified file (either append or overwrite).
 java.lang.String getAppDirPath(int productNumber)
          Gets the absolute path of "app" directory for designated product #.
 int[] getExpirationDate()
          Gets the expiration date of your current licensor key.
static LicenseManager getInstance()
           Gets an instance of the LicenseManager class.
 int getTotalModules(int productNumber)
          Gets the number of modules for a product designated by its "product #".
 int getTotalProducts()
          Gets the number of products that can be protected by your current licensor key of JChain.
 void setInterval(double interval)
          Sets the time-interval of updating the license key by deamon.
 int startKeyUpdateDaemon()
          Manually starts the licensor key updater (i.e.
 void stopKeyUpdateDaemon()
          Manually stops the licensor key updater (i.e.
 int takeInKey(java.lang.String selected)
          Takes in a designated licensor key file and activates your copy of JChain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setInterval

public void setInterval(double interval)
Sets the time-interval of updating your licensor key by deamon.
Parameters:
interval - the interval in hour (e.g. 0.1 means 6 minutes)
See Also:
startKeyUpdateDaemon(), stopKeyUpdateDaemon()

startKeyUpdateDaemon

public int startKeyUpdateDaemon()
Manually starts the licensor key updater (i.e. a thread to update your licensor key at a certain interval).
See Also:
setInterval( double interval ), stopKeyUpdateDaemon()

stopKeyUpdateDaemon

public void stopKeyUpdateDaemon()
Manually stops the licensor key updater (i.e. a thread to update your licensor key at a certain interval).
See Also:
startKeyUpdateDaemon(), setInterval( double interval )

getExpirationDate

public int[] getExpirationDate()
Gets the expiration date of your current licensor key.
Returns:
the date.
1st element: year (e.g. 2003), 2nd: month (e.g. 1 for January), 3rd: day of month.
{0,0,0} if N/A (like in the case of permanent license).

For example Nov. 15, 2003 is represented by {2003, 11, 15}

getInstance

public static LicenseManager getInstance()
Gets an instance of the LicenseManager class.
Returns:
the instance; null if failed to initialize the instance

takeInKey

public int takeInKey(java.lang.String selected)
Takes in a designated licensor key file and activates your copy of JChain.
Parameters:
selected - the absolute path of the key file
Returns:
  • 0: successfully taken in
  • 1: failed to take in

getTotalProducts

public int getTotalProducts()
Gets the number of products that can be protected by your current licensor key of JChain.
Returns:
the number of products

getTotalModules

public int getTotalModules(int productNumber)
Gets the number of modules for a product designated by its "product #". (For a product # N, a folder named "app_N" will be created under the "licensor_tools" directory.)
Parameters:
productNumber - the product number
Returns:
the number of modules

generateSerialNumbers

public java.lang.String[] generateSerialNumbers(int productNumber,
                                                int num,
                                                java.lang.String filePath,
                                                boolean append)
Generates serial numbers at once and writes them to a specified file (either append or overwrite). This method creates new records in the user database. Not to be used for re-issue of license keys. Corresponding records in the product table of the user database are also created by this method.
[Note] You need to create the user database in advance. The user database can be created by the JChain Management Panel.
Parameters:
productNumber - the number indicating the product for which the serial number is issued.
num - the number of serial numbers to generate
filePath - the path of the file to be written. Set null if you don't need such a file.
append - set true to append to the file; false to overwrite.
Returns:
the generated serial numbers; null if failed

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String sqlStatement)
                                throws java.sql.SQLException
Executes SQL query for the user database.
[Note] You need to create the user database in advance. The user database can be created by the JChain Management Panel.
Returns:
the result set; null if fails
Throws:
java.sql.SQLException - - if a database access error occurs

executeUpdate

public int executeUpdate(java.lang.String sqlStatement)
                  throws java.sql.SQLException
Executes SQL update (INSERT, UPDATE or DELETE) for the user database.
[Note] You need to create the user database in advance. The user database can be created by the JChain Management Panel.
Returns:
either the row count for the statements; -1 if fails

getAppDirPath

public java.lang.String getAppDirPath(int productNumber)
Gets the absolute path of "app" directory for designated product #. (The folder name of the N th app directory is "app_N".)
Parameters:
productNumber - the product #
Returns:
the absolute path