2.17.2: 2011-06-17

net.sf.basedb.util
Class PluginInfo

java.lang.Object
  extended by net.sf.basedb.util.PluginInfo

public class PluginInfo
extends Object

A PluginInfo object is used to keep information about external plugin located in a jar file.

Version:
2.5
Author:
Martin
Last modified
$Date$

Field Summary
private  About about
          The about information from the plugin
private  String className
          The classname of the plugin
private  List<PluginConfigInfo> configs
          The list with belonging configurations
private static String configurationImportFile
          The path in a jar-file to the file that holds configurations to import
private  boolean denied
           
private  boolean inSameJarFile
           
private  boolean isInstalled
           
private  String jarInDatabase
           
private  String jarPath
          The path to the jarfile the plugin is located in.
private  String minBaseVersion
          The BASE version that the plugin at least requires
private  String pluginVersion
          The version of this plug-in
private  String versionInDatabase
           
private static String xmlFile
          The name of a XML-file that holds information about each plugin class in the jar file.
 
Constructor Summary
PluginInfo(String jarPath, String className, String minBaseVersion, About about, List<PluginConfigInfo> configs)
          Creates a new PluginInfo object.
 
Method Summary
 void checkInstallation(DbControl dc)
          Checks the database if this plug-in is installed or not.
 About getAbout()
          Gets the about information that is set for this plugin
 String getClassName()
          Gets the class name for the plugin
 List<PluginConfigInfo> getConfigurations()
          Gets information about the configurations that come together with the plugin in the jar.
 String getConfigurationsPath()
          The path inside a jar to the xml-file that holds the pluginconfigurations that can be imported.
 String getJarPath()
          Gets the name of the jar file holding this plugin
 String getJarPathInDatabase()
          Gets the jar path of the already installed plugin.
 String getMinBaseVersion()
          Gets the lowest version of BASE that the plugin is compatible with
 String getVersionInDatabase()
          Get which version of this plugin that is installed in BASE.
 boolean hasConfigurations()
           
 boolean hasDifferentVersion()
          Has the plug-in a version number that differ from what is stored in the database.
 boolean inSameJarFile()
          If the plug-in is already installed in the same or a different JAR file.
 boolean isDenied()
          If the currently logged in user has write permission to the (installed) plug-in or not.
 boolean isInstalled()
          If the plug-in is already installed in BASE.
static List<PluginInfo> loadFromJar(File jarFile)
          Gets a list with PluginInfo objects, one for every plugin listed in the base-plugins.xml file, which is located in the jar-file's META-INF directory.
private static boolean versionCompatible(String version)
          Gets if a version is compatible with current major.minor-version of BASE
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jarPath

private String jarPath
The path to the jarfile the plugin is located in.


className

private String className
The classname of the plugin


minBaseVersion

private String minBaseVersion
The BASE version that the plugin at least requires


about

private About about
The about information from the plugin


pluginVersion

private String pluginVersion
The version of this plug-in


configs

private List<PluginConfigInfo> configs
The list with belonging configurations


xmlFile

private static final String xmlFile
The name of a XML-file that holds information about each plugin class in the jar file.

See Also:
Constant Field Values

configurationImportFile

private static final String configurationImportFile
The path in a jar-file to the file that holds configurations to import

See Also:
Constant Field Values

denied

private boolean denied

isInstalled

private boolean isInstalled

inSameJarFile

private boolean inSameJarFile

versionInDatabase

private String versionInDatabase

jarInDatabase

private String jarInDatabase
Constructor Detail

PluginInfo

public PluginInfo(String jarPath,
                  String className,
                  String minBaseVersion,
                  About about,
                  List<PluginConfigInfo> configs)
Creates a new PluginInfo object.

Parameters:
jarPath - The path to the jar file in which the class is located.
className - The plugin's class name
minBaseVersion - BASE version that the plugin at least requires
about - Information about the plugin.
configs - A list with configurations for this plugin.
Method Detail

loadFromJar

public static List<PluginInfo> loadFromJar(File jarFile)
                                    throws JDOMException
Gets a list with PluginInfo objects, one for every plugin listed in the base-plugins.xml file, which is located in the jar-file's META-INF directory. Plugins which class file couldn't be found or the class doesn't implement Plugin will not be included in the list but already installed plugins will.

Parameters:
jarFile - The jar file to load the plugin info from.
Returns:
List with PluginInfo about the plugins that were found in jar file.
Throws:
JDOMException - If any error loading the XML-document

getClassName

public String getClassName()
Gets the class name for the plugin

Returns:
String A class name like 'net.sf.basedb.classname'

getJarPath

public String getJarPath()
Gets the name of the jar file holding this plugin

Returns:
String Name of the jar file

getMinBaseVersion

public String getMinBaseVersion()
Gets the lowest version of BASE that the plugin is compatible with

Returns:
String Base version

getAbout

public About getAbout()
Gets the about information that is set for this plugin

Returns:
About The about information that is in the plugin's about object.

getConfigurations

public List<PluginConfigInfo> getConfigurations()
Gets information about the configurations that come together with the plugin in the jar.

Returns:
A list with information about each plugin configuration.

hasConfigurations

public boolean hasConfigurations()

getConfigurationsPath

public String getConfigurationsPath()
The path inside a jar to the xml-file that holds the pluginconfigurations that can be imported.

Returns:
String format path.

checkInstallation

public void checkInstallation(DbControl dc)
Checks the database if this plug-in is installed or not. This method should be called before isDenied(), isInstalled() or inSameJarFile() is called.

Parameters:
dc - An open DbControl
Since:
2.9

isDenied

public boolean isDenied()
If the currently logged in user has write permission to the (installed) plug-in or not. Before calling this method, checkInstallation(DbControl) must be called.

Returns:
TRUE if the user has write permission, FALSE otherwise
Since:
2.9

isInstalled

public boolean isInstalled()
If the plug-in is already installed in BASE. Before calling this method, checkInstallation(DbControl) must be called.

Returns:
TRUE if the plug-in is installed
Since:
2.9

inSameJarFile

public boolean inSameJarFile()
If the plug-in is already installed in the same or a different JAR file. Before calling this method, checkInstallation(DbControl) must be called.

Returns:
TRUE if the plug-in is installed in the same JAR file
Since:
2.9

hasDifferentVersion

public boolean hasDifferentVersion()
Has the plug-in a version number that differ from what is stored in the database.

Returns:
TRUE if version number match value in database, FALSE if not.
Since:
2.12

getVersionInDatabase

public String getVersionInDatabase()
Get which version of this plugin that is installed in BASE.

Returns:
A string object containing the installed version, or NULL if this plugin hasn't been installed before.
Since:
2.12

getJarPathInDatabase

public String getJarPathInDatabase()
Gets the jar path of the already installed plugin.

Returns:
the jar path as a String object, or NULL if this plugin hasn't been installed before.
Since:
2.12

versionCompatible

private static boolean versionCompatible(String version)
Gets if a version is compatible with current major.minor-version of BASE

Parameters:
version - The version to test
Returns:
True if the version is compatible with current BASE version, FALSE otherwise.

2.17.2: 2011-06-17