Commit 0b3f777a authored by Matt Tucker's avatar Matt Tucker Committed by matt

Added license type to plugins.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4091 b35dd754-fafc-0310-a699-88a17e54d16e
parent a9337bdf
......@@ -129,7 +129,7 @@ file might look like the following:
one of the other categories. The license agreement should be details in the
plugin's Readme.</li>
</ul>
If the license type is not set, it is assumed to be internal.</li>
If the license type is not set, it is assumed to be other.</li>
</ul></p>
Several additional files can be present in the plugin to provide additional information to
......
......@@ -19,7 +19,7 @@ import java.io.File;
* <li>Act as {@link org.xmpp.component.Component Components} to implement
* additional features in the XMPP protocol.
* <li>Dynamically modify the admin console.
* <li>Use the Wildfire API to add new functionality to server.
* <li>Use the Wildfire API to add new functionality to the server.
* </ul>
*
* Plugins live in the <tt>plugins</tt> directory of <tt>home</tt>. Plugins
......@@ -45,10 +45,15 @@ import java.io.File;
* &lt;description&gt;This is an example plugin.&lt;/description&gt;
* &lt;author&gt;Foo Inc.&lt;/author&gt;
* &lt;version&gt;1.0&lt;/version&gt;
* &lt;minServerVersion&gt;2.1.2&lt;/minServerVersion&gt;
* &lt;minServerVersion&gt;3.0.0&lt;/minServerVersion&gt;
* &lt;licenseType&gt;gpl&lt;/licenseType&gt;
* &lt;/plugin&gt;</pre>
* <p/>
* Each plugin will be loaded in its own class loader, unless the plugin is configured
* with a parent plugin.<p/>
*
* Each plugin will be loaded in its own class loader.
* Please see the Plugin Developer Guide (available with the
* Wildfire documentation) for additional details about plugin development.
*
* @author Matt Tucker
*/
......
......@@ -592,6 +592,31 @@ public class PluginManager {
return -1;
}
/**
* Returns the license agreement type that the plugin is governed by. The value
* is retrieved from the plugin.xml file of the plugin. If the value could not be
* found, {@link License#other} is returned.
*
* @param plugin the plugin.
* @return the plugin's license agreement.
*/
public License getLicense(Plugin plugin) {
String licenseString = getElementValue(plugin, "/plugin/licenseType");
if (licenseString != null) {
try {
// Attempt to load the get the license type. We lower-case and
// trim the license type to give plugin author's a break. If the
// license type is not recognized, we'll log the error and default
// to "other".
return License.valueOf(licenseString.toLowerCase().trim());
}
catch (IllegalArgumentException iae) {
Log.error(iae);
}
}
return License.other;
}
/**
* Returns the classloader of a plugin.
*
......@@ -632,6 +657,39 @@ public class PluginManager {
return null;
}
/**
* An enumberation for plugin license agreement types.
*/
public enum License {
/**
* The plugin is distributed using a commercial license.
*/
commercial,
/**
* The plugin is distributed using the GNU Public License (GPL).
*/
gpl,
/**
* The plugin is distributed using the Apache license.
*/
apache,
/**
* The plugin is for internal use at an organization only and is not re-distributed.
*/
internal,
/**
* The plugin is distributed under another license agreement not covered by
* one of the other choices. The license agreement should be detailed in the
* plugin Readme.
*/
other
}
/**
* A service that monitors the plugin directory for plugins. It periodically
* checks for new plugin JAR files and extracts them if they haven't already
......@@ -822,4 +880,4 @@ public class PluginManager {
return dir.delete();
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment