All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alachisoft.ncache.licensing.LicenseLogger Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
package com.alachisoft.ncache.licensing;

/**
 * ***********************************************************************
 * Author: Hasan Khan Date created: 06-05-2008
 * 

* Modified By: Last modified by: Date modified: /************************************************************************ */ //C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java: //#if NCPEX //#else //#endif public class LicenseLogger { private java.util.ArrayList licenses; private boolean autoSave; private ILicenseSink sink; private Object syncRoot = new Object(); private boolean enabled; public LicenseLogger() { // licenses = new java.util.ArrayList(); // autoSave = false; // sink = new FileLicenseSink(Path.Combine(GetLogDirPath(), "licenseLog.dat")); // syncRoot = new Object(); } private String GetLogDirPath() { // String logDir = ServicePropValues.LOGS_FOLDER; // String installDir = AppUtil.getInstallDir(); // return installDir + "/" + logDir; return ""; } public final boolean getAutoSave() { return autoSave; } public final void setAutoSave(boolean value) { autoSave = value; } public final boolean getEnabled() { return enabled; } public final void setEnabled(boolean value) { enabled = value; } public final void Load() { synchronized (syncRoot) { // licenses = sink.Load(); } } public final void Save() { synchronized (syncRoot) { try { sink.Dump(licenses); } catch (java.lang.Exception e) { } } } private int Find(LicenseInfo item) { boolean found = false; int i; for (i = 0; i < licenses.size(); i++) { if (licenses.get(i).equals(item)) { found = true; break; } } return found ? i : -1; } public final void Add(LicenseInfo item) { if (!getEnabled()) { return; } synchronized (syncRoot) { int i = Find(item); if (i >= 0) { boolean changed = licenses.get(i).Update(item); if (changed && getAutoSave()) { sink.Dump(licenses); } } else { licenses.add(item); if (getAutoSave()) { sink.Dump(licenses); } } } } public final boolean Contains(LicenseInfo item) { synchronized (syncRoot) { return licenses.contains(item); } } public final LicenseInfo[] getLicenses() { synchronized (syncRoot) { LicenseInfo[] array = new LicenseInfo[licenses.size()]; // licenses.CopyTo(array, 0); return array; } } public final int getCount() { synchronized (syncRoot) { return licenses.size(); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy