org.java.plugin.extension
Class PluginsCollector

java.lang.Object
  extended by org.java.plugin.extension.PluginsCollector

public class PluginsCollector
extends java.lang.Object

This boroughs code from the JPF boot library with a few modifications.
Default implementation of plug-ins collector. Supported configuration parameters are:

Application.pluginRepositories
Comma separated list of local plug-in repositories, given folders will be scanned for plug-ins. Default value is ./plugins.
epos.pluginLocationDescriptors
Comma separated list of URLs for XML syntax files that describe available plug-in locations (see file syntax bellow). No default value provided.

Given repositories are scanned recursively collecting all folders that contain plugin.xml or plugin-fragment.xml and *.zip and *.jar files.

Plug-ins locations descriptor is a simple XML syntax file that stores locations of all available plug-in manifests and contexts (in terms of PluginManager.PluginLocation). Here is an example:

<plugins>
   <plugin
     manifest="http://localhost/myPlugins/plugin1/plugin.xml"
     context="http://localhost/myPlugins/plugin1/"/>
   <plugin
     manifest="http://localhost/myPlugins/plugin2/plugin.xml"
     context="http://localhost/myPlugins/plugin2/"/>
   <plugin
     manifest="http://www.plugins.com/repository/plugin1/plugin.xml"
     context="http://www.plugins.com/repository/plugin1/"/>
   <plugin
     manifest="http://www.plugins.com/repository/plugin1/plugin.xml"
     context="http://www.plugins.com/repository/plugin1/"/>
 </plugins>
Using such simple descriptor you may, for example, publish plug-ins on a site to make them available for clients without needing to download plug-ins manually.


Field Summary
protected  org.apache.commons.logging.Log log
           
protected static java.lang.String PARAM_PLUGINS_LOCATIONS_DESCRIPTORS
           
protected static java.lang.String PARAM_PLUGINS_REPOSITORIES
           
 
Constructor Summary
PluginsCollector(java.util.Properties configuration)
          Create and configure a new PluginsCollector.
 
Method Summary
 boolean addRepository(java.io.File location)
          Add a new location as plugin repository.
 PluginManager.PluginLocation[] collectPluginLocations()
          After configure(Properties) was called, this scans the found directories and locations and creates an array of PluginManager.PluginLocations.
protected  void configure(java.util.Properties config)
          Takes the configuration from the given properties and scans for plugins and description locations.
 java.util.List<java.net.URL> getDescriptors()
           
 java.util.List<java.net.URL> getJars()
           
 java.util.List<java.io.File> getRepositories()
           
protected static java.net.URL jarelement2jar(java.net.URL cUrl)
           
protected static java.lang.String jarelement2jarfile(java.net.URL cUrl)
           
protected  void processFile(java.io.File file, java.util.List<PluginManager.PluginLocation> result)
          Process a file as PluginManager.PluginLocation.
protected  void processFolder(java.io.File folder, java.util.List<PluginManager.PluginLocation> result)
          Process a folder while creating PluginManager.PluginLocations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_PLUGINS_REPOSITORIES

protected static final java.lang.String PARAM_PLUGINS_REPOSITORIES
See Also:
Constant Field Values

PARAM_PLUGINS_LOCATIONS_DESCRIPTORS

protected static final java.lang.String PARAM_PLUGINS_LOCATIONS_DESCRIPTORS
See Also:
Constant Field Values

log

protected org.apache.commons.logging.Log log
Constructor Detail

PluginsCollector

public PluginsCollector(java.util.Properties configuration)
Create and configure a new PluginsCollector.

Parameters:
configuration -
Method Detail

configure

protected void configure(java.util.Properties config)
Takes the configuration from the given properties and scans for plugins and description locations. This does not create PluginManager.PluginLocations but detects local directories and remote URLs.

Parameters:
config -
Throws:
java.lang.Exception

collectPluginLocations

public PluginManager.PluginLocation[] collectPluginLocations()
After configure(Properties) was called, this scans the found directories and locations and creates an array of PluginManager.PluginLocations.


processFolder

protected void processFolder(java.io.File folder,
                             java.util.List<PluginManager.PluginLocation> result)
Process a folder while creating PluginManager.PluginLocations. This creates a PluginManager.PluginLocation for the folder and recursively for each sub-folder.

Parameters:
folder - the folder
result - list of PluginManager.PluginLocation

processFile

protected void processFile(java.io.File file,
                           java.util.List<PluginManager.PluginLocation> result)
Process a file as PluginManager.PluginLocation. This creates a PluginManager.PluginLocation for the given file.

Parameters:
file -
result -

jarelement2jarfile

protected static java.lang.String jarelement2jarfile(java.net.URL cUrl)

jarelement2jar

protected static java.net.URL jarelement2jar(java.net.URL cUrl)

getRepositories

public java.util.List<java.io.File> getRepositories()
Returns:
repositories registered

getDescriptors

public java.util.List<java.net.URL> getDescriptors()
Returns:
descriptors registered

getJars

public java.util.List<java.net.URL> getJars()
Returns:
jars registered

addRepository

public boolean addRepository(java.io.File location)
Add a new location as plugin repository. This checks if the location already exists in this collector. If not, it is added. If you add repositories here, make sure to register them with your plugin manager.

Parameters:
location - the new location
Returns:
true if location was added


Copyright © 2010. All Rights Reserved.