From: <cl...@hy...> - 2008-12-29 21:03:54
|
Author: clee Date: 2008-12-29 13:03:47 -0800 (Mon, 29 Dec 2008) New Revision: 12101 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=12101 Added: branches/HQ_4_0/src/org/hyperic/hq/common/LicenseManager.java Modified: branches/HQ_4_0/src/org/hyperic/hq/product/ProductPluginManager.java Log: [HQ-1548] Add LicenseManager API so that excluded plugins can be checked Copied: branches/HQ_4_0/src/org/hyperic/hq/common/LicenseManager.java (from rev 12100, trunk/src/org/hyperic/hq/common/LicenseManager.java) =================================================================== --- branches/HQ_4_0/src/org/hyperic/hq/common/LicenseManager.java (rev 0) +++ branches/HQ_4_0/src/org/hyperic/hq/common/LicenseManager.java 2008-12-29 21:03:47 UTC (rev 12101) @@ -0,0 +1,30 @@ +/* + * NOTE: This copyright does *not* cover user programs that use HQ + * program services by normal system calls through the application + * program interfaces provided as part of the Hyperic Plug-in Development + * Kit or the Hyperic Client Development Kit - this is merely considered + * normal use of the program, and does *not* fall under the heading of + * "derived work". + * + * Copyright (C) [2004-2008], Hyperic, Inc. + * This file is part of HQ. + * + * HQ is free software; you can redistribute it and/or modify + * it under the terms version 2 of the GNU General Public License as + * published by the Free Software Foundation. This program is distributed + * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + */ + +package org.hyperic.hq.common; + +public interface LicenseManager { + public boolean isPluginEnabled(String name); +} Modified: branches/HQ_4_0/src/org/hyperic/hq/product/ProductPluginManager.java =================================================================== --- branches/HQ_4_0/src/org/hyperic/hq/product/ProductPluginManager.java 2008-12-29 20:58:50 UTC (rev 12100) +++ branches/HQ_4_0/src/org/hyperic/hq/product/ProductPluginManager.java 2008-12-29 21:03:47 UTC (rev 12101) @@ -29,6 +29,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.InputStream; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.Comparator; @@ -39,6 +40,7 @@ import java.util.Properties; import org.hyperic.hq.agent.AgentConfig; +import org.hyperic.hq.common.LicenseManager; import org.hyperic.hq.common.shared.ProductProperties; import org.hyperic.hq.product.pluginxml.PluginData; import org.hyperic.sigar.OperatingSystem; @@ -826,7 +828,8 @@ } log.info("Loading plugin: " + name); try { - registerPluginJar(plugins[j].getAbsolutePath()); + if (registerPluginJar(plugins[j].getAbsolutePath()) == null) + continue; } catch (UnsupportedClassVersionError e) { log.info("Cannot load " + name + ": " + unsupportedClassVersionMessage(e.getMessage())); @@ -963,6 +966,24 @@ } } + // Check with LicenseManager + try { + Class c = Class.forName("com.hyperic.hq.license.LicenseManager"); + Method getInstance = c.getMethod("instance", null); + LicenseManager mgr = (LicenseManager) getInstance.invoke(null, + null); + if (!mgr.isPluginEnabled(pluginName)) { + if (DEBUG_LIFECYCLE) { + log.debug("Skipping " + pluginName + + " (in license.exclude)"); + } + return null; + } + + } catch (Exception e) { + // Don't validate against LicenseManager then + } + if (data.getName() == null) { data.setName(pluginName); } |