com.jalios.jcms.plugin
Class Plugin

java.lang.Object
  extended by com.jalios.jcms.plugin.Plugin

public class Plugin
extends Object

Main root class representing a Plugin.

Since:
jcms-5.7.0
Version:
$Revision: 30809 $
Author:
Jean-Philippe Encausse

Nested Class Summary
static class Plugin.LabelComparator
          Comparator class used to compare Plugins' labels
static class Plugin.PluginComparator
          Comparator class used to compare Plugins: Check dependencies of each other Check dependencies size Check plugin order Check plugin name
 
Field Summary
protected  String[] appserver
           
protected  String author
           
static String CHANGELOG
           
protected static Channel channel
           
protected  org.jdom.Document config
           
protected  org.jdom.Document configToSave
           
static String CONFIGURATION
           
static String DEFAULT_ICON
           
static String DEFAULT_PREVIEW
           
static String DEFAULT_PROPERTIES_EDITOR
           
protected  HashSet<Plugin> dependencies
           
protected  Map<String,String> descriptionMap
           
static String DOCUMENTATION
           
static String ICON
           
protected  boolean isDeployed
           
protected  boolean isInitialized
           
protected  boolean isLoaded
           
protected  boolean isRestart
           
protected  boolean isStopped
           
protected  boolean isWarned
           
protected  String jcms
           
static org.apache.log4j.Logger jcmsLogger
           
protected  boolean jsync
           
protected  Map<String,String> labelMap
           
protected  String license
           
static String LICENSE
           
protected  org.apache.log4j.Logger logger
           
protected  String name
           
protected  int order
           
protected  JProperties pluginProp
           
static String PREVIEW
           
static String PROPERTIES_EDITOR
           
static String REVISION
           
static String SIGNATURE
           
protected  String url
           
protected  String version
           
static String XML_COMPONENTS
           
static String XML_DEPENDENCIES
           
static String XML_DEPENDENCY
           
static String XML_HIBERNATE
           
static String XML_OPENAPI
           
static String XML_OPENAPI_RESOURCE
           
static String XML_PRIVATE
           
static String XML_PUBLIC
           
static String XML_TYPE
           
static String XML_TYPES
           
static String XML_WEBAPP
           
 
Constructor Summary
Plugin()
           
Plugin(String label)
          Create a Plugin from a given Camelized Label
 
Method Summary
protected  boolean checkAppServer()
          Check if the plugin work with the current application server
protected  boolean checkJCMSVersion()
          Check if the plugin work with the current JCMS version
 Set<SignatureDiffEntry> diff()
          Diff the base plugin signature and a live plugin signature.
protected  void fillElementPath(Collection<String> paths, List<org.jdom.Element> elmList, String prefix, String tagName, boolean deep, String matchAttribute, String matchValue)
           
protected  void fillJavaSet(org.jdom.Element itJava, Set<String> pathSet, boolean sources)
           
protected  void fillPluginComponentPath(Map<String,String> itemMap, String tagName, boolean sources)
           
 Set<Plugin> getAllDependenciesSet()
          Returns all plugins used by this plugin recursively.
 Set<String> getAllPathSet(boolean sources, boolean generated)
          Returns a Set of relative path to all Plugins files
 String[] getAppServer()
           
 String getAuthor()
           
 String getBuild(Locale userLocale)
           
 String getChangeLog()
           
 String getConfiguration()
           
 Set<Plugin> getDependenceSet()
           
 String getDescription(String lang)
           
protected  Map<String,String> getDescriptionMap()
           
 String getDocumentation()
           
 TreeMap<String,String> getEditableProperties()
          Return a TreeMap that contains all plugin properties having an I18N value.
 Set<String> getHibernateMappingsPath()
          Returns a Set of path to plugin's Hibernate mappings (hbm).
 String getIcon()
           
protected  Collection<String> getIncludeCollection(String tag)
          Return a Collection of JSP Relatives path to include for the given anchor.
 String getJarPath()
          Returns the relative path to the packaged plugin jar sources
 Set<String> getJarsPath()
          Returns a Set of path to plugin's jars.
 Set<String> getJavaPath(boolean sources)
          Returns a Set of path to plugin's java files.
 String getJCMSVersion()
           
 boolean getJSync()
           
 String getLabel(String lang)
           
protected  Map<String,String> getLabelMap()
           
 String getLicense()
           
 org.apache.log4j.Logger getLogger()
          Returns the logger of the current Plugin.
 String getName()
           
 Map<String,String> getOpenAPIResourcePath(boolean sources)
          Returns a Map from path of plugin's OpenAPI resources files to their uritemplate.
 int getOrder()
           
 String getPackageName()
           
 String getPackagePath()
           
 Set<File> getPackageSet()
          Returns a Set of File representing all package version for this plugin.
 Map<String,String> getPluginComponentPath(boolean sources)
          Returns a Map from path of plugin's components files to their nature ("storelistener", "dblistener", ...).
protected
<T extends PluginComponent>
List<T>
getPluginComponents(Class<T> clazz)
          Convenient method to retrieve a usage of elements from the plugin configuration and create PluginComponents from attribute class Skip unresolvable types with a warning.
 String getPreview()
           
 Set<String> getPrivatesPath()
          Returns a Set of path to plugin's private files.
 String getPropertiesEditor()
           
protected  String getPublicPath(String pluginRelativePath, String defaultPath)
           
 Set<String> getPublicsPath()
          Returns a Set of path to plugin's public files.
 Signature getSignature()
          Returns a Signature of plugin's files
 String getSignaturePath()
           
 String getStatus(String userLang)
           
 String getStatusIcons(String userLang)
           
 Set<String> getTemplatesPath()
          Returns a Set of path to plugin's type's templates.
 String getTextLicense()
           
 Set<String> getTypeDirectoriesPathSet()
          Returns a Set of new plugin's types directory path
 Map<String,Set<String>> getTypesPath(boolean sources, boolean generated)
          Returns a Map of Type Mame / Relative path to declared plugin's type files Type XML Type Template XML Declared custom java Files Declared JSP Declared Resources (preview, images, ...)
 List<TypeTemplateEntry> getTypeTemplateEntries()
          Returns templates for given types declared in plugin configuration.
 String getUrl()
           
 String getVersion()
           
 Set<String> getWebappsPath()
          Returns a Set of path to plugin's webapps files.
 Set<String> getWorkflowsPath()
          Returns a Set of path to plugin's workflow.
 void init()
          Called by PluginManager during initialization after all plugins dependencies initialized.
 void initDependencies(boolean checkStatus)
          Called by PluginManager during initialization after all plugins loads.
 boolean isDeployed()
           
 boolean isInitialized()
           
 boolean isLoaded()
           
 boolean isStopped()
           
 boolean isWarned()
           
 void load(org.jdom.Document config, boolean isDeployed)
          Called by PluginManager during initialization to setup main variable from config file.
protected  void loadLanguageProperties(LangProperties properties, List<String> langList)
          Load language properties into channel properties.
protected  void loadProperties(LangProperties properties)
          Load plugin properties into channel properties.
 boolean mustRestart()
           
 boolean performPackage(boolean sources)
          Performs a package of the plugin's files.
protected  void registerAlarmListener()
          Register AlarmListener into the Channel declared in plugin configuration.
protected  void registerAuthenticationHandler()
          Register Authentication handler into the Channel declared in plugin configuration.
protected  void registerChannelListener()
          Register ChannelListener into the Channel declared in plugin configuration.
protected  void registerCleanFilter()
          Register CleanFilter into the Channel declared in plugin configuration.
protected  void registerDataController()
          Register DataControllers into the Channel declared in plugin configuration.
protected  void registerDBListener()
          Register DBListener into the Channel declared in plugin configuration.
protected  void registerHibernateMapping()
          Register the Hibernate mapping files
protected  void registerOpenApiResources()
          Register RestResource into the Channel declared in plugin configuration.
protected  void registerPolicyFilter()
          Register PolicyFilter into the Channel declared in plugin configuration.
protected  void registerQueryFilter()
          Register QueryFilter into the Channel declared in plugin configuration.
protected  void registerStoreListener(boolean beforeStoreLoad)
          Register StoreListeners into the Channel declared in plugin configuration.
protected  void registerTemplates()
          Register templates for given types declared in plugin configuration.
 void resetConfigToSave()
          Clones XML document that represents plugin configuration.
 void saveConfig()
           
 void setInitialized(boolean initialized)
           
 void setRestart(boolean restart)
           
 void setStopped()
           
 void setup()
          Called by PluginManager during initialization after all plugins dependencies initialized.
 void setWarned(boolean warn)
           
 boolean sign(boolean force)
          Create a Signature of plugin's files and store it in plugin private directory.
 String toString()
           
 void updateAppServer(String[] field)
           
 void updateAuthor(String field)
           
 void updateDescription(Map<String,String> descriptionMap)
           
 void updateInitialized(boolean field)
           
 void updateJarSet(Set<String> jarSet)
           
 void updateJCMSVersion(String field)
           
 void updateJSync(boolean field)
           
 void updateLabel(Map<String,String> labelMap)
           
 void updateLicense(String field)
           
 void updateOrder(int field)
           
 void updatePrivateSet(Set<String> privateSet)
           
 void updatePublicSet(Set<String> publicSet)
           
 void updateTypeMap(Map<String,Set<String>> map)
           
 void updateUrl(String field)
           
 void updateVersion(String field)
           
 void updateWebappSet(Set<String> webappSet)
           
 void updateWorkflowSet(Set<String> workflowSet)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

jcmsLogger

public static org.apache.log4j.Logger jcmsLogger

channel

protected static Channel channel

REVISION

public static final String REVISION
See Also:
Constant Field Values

SIGNATURE

public static final String SIGNATURE
See Also:
Constant Field Values

CHANGELOG

public static final String CHANGELOG
See Also:
Constant Field Values

DOCUMENTATION

public static final String DOCUMENTATION
See Also:
Constant Field Values

LICENSE

public static final String LICENSE
See Also:
Constant Field Values

PREVIEW

public static final String PREVIEW
See Also:
Constant Field Values

ICON

public static final String ICON
See Also:
Constant Field Values

CONFIGURATION

public static final String CONFIGURATION
See Also:
Constant Field Values

PROPERTIES_EDITOR

public static final String PROPERTIES_EDITOR
See Also:
Constant Field Values

DEFAULT_PROPERTIES_EDITOR

public static final String DEFAULT_PROPERTIES_EDITOR
See Also:
Constant Field Values

DEFAULT_PREVIEW

public static final String DEFAULT_PREVIEW
See Also:
Constant Field Values

DEFAULT_ICON

public static final String DEFAULT_ICON
See Also:
Constant Field Values

XML_PRIVATE

public static final String XML_PRIVATE
See Also:
Constant Field Values

XML_PUBLIC

public static final String XML_PUBLIC
See Also:
Constant Field Values

XML_WEBAPP

public static final String XML_WEBAPP
See Also:
Constant Field Values

XML_TYPES

public static final String XML_TYPES
See Also:
Constant Field Values

XML_TYPE

public static final String XML_TYPE
See Also:
Constant Field Values

XML_DEPENDENCIES

public static final String XML_DEPENDENCIES
See Also:
Constant Field Values

XML_DEPENDENCY

public static final String XML_DEPENDENCY
See Also:
Constant Field Values

XML_COMPONENTS

public static final String XML_COMPONENTS
See Also:
Constant Field Values

XML_HIBERNATE

public static final String XML_HIBERNATE
See Also:
Constant Field Values

XML_OPENAPI

public static final String XML_OPENAPI
See Also:
Constant Field Values

XML_OPENAPI_RESOURCE

public static final String XML_OPENAPI_RESOURCE
See Also:
Constant Field Values

config

protected org.jdom.Document config

configToSave

protected org.jdom.Document configToSave

logger

protected org.apache.log4j.Logger logger

isDeployed

protected boolean isDeployed

isLoaded

protected boolean isLoaded

isInitialized

protected boolean isInitialized

isStopped

protected boolean isStopped

isWarned

protected boolean isWarned

isRestart

protected boolean isRestart

name

protected String name

version

protected String version

jcms

protected String jcms

order

protected int order

dependencies

protected HashSet<Plugin> dependencies

jsync

protected boolean jsync

appserver

protected String[] appserver

url

protected String url

author

protected String author

license

protected String license

labelMap

protected Map<String,String> labelMap

descriptionMap

protected Map<String,String> descriptionMap

pluginProp

protected JProperties pluginProp
Constructor Detail

Plugin

public Plugin()

Plugin

public Plugin(String label)
Create a Plugin from a given Camelized Label

Parameters:
label - the plugin label
Method Detail

load

public void load(org.jdom.Document config,
                 boolean isDeployed)
Called by PluginManager during initialization to setup main variable from config file. Do not access other plugins because they might not been already loadded wait init() method

Parameters:
config - JDOM Document of config plugin file
isDeployed - true if the plugin has been deployed

getJarPath

public String getJarPath()
Returns the relative path to the packaged plugin jar sources

Returns:
String path to plugin jar

performPackage

public boolean performPackage(boolean sources)
Performs a package of the plugin's files. Java files and classes will be bundled in a jar file.

Parameters:
sources - boolean true to include java source files in the package
Returns:
boolean true if perform has been done

getPackageSet

public Set<File> getPackageSet()
Returns a Set of File representing all package version for this plugin.

Returns:
Set of File

initDependencies

public void initDependencies(boolean checkStatus)
Called by PluginManager during initialization after all plugins loads.

Parameters:
checkStatus - true to check if depending plugin are available

getAllDependenciesSet

public Set<Plugin> getAllDependenciesSet()
Returns all plugins used by this plugin recursively. TODO: Cache the Set

Returns:
Set of Plugin used by this plugin

init

public void init()
Called by PluginManager during initialization after all plugins dependencies initialized. Called juste after PluginManager Initialisation:


setup

public void setup()
Called by PluginManager during initialization after all plugins dependencies initialized.


checkAppServer

protected boolean checkAppServer()
Check if the plugin work with the current application server

Returns:
boolean true if it work with current application server

checkJCMSVersion

protected boolean checkJCMSVersion()
Check if the plugin work with the current JCMS version

Returns:
boolean true if it work with current JCMS version

sign

public boolean sign(boolean force)
Create a Signature of plugin's files and store it in plugin private directory.

Parameters:
force - generate signature even if file exists
Returns:
boolean false if the signature has not been created

diff

public Set<SignatureDiffEntry> diff()
Diff the base plugin signature and a live plugin signature.

Returns:
a Set of SignatureDiffEntry

getSignature

public Signature getSignature()
Returns a Signature of plugin's files

Returns:
Signature of plugin's files

getTypeTemplateEntries

public List<TypeTemplateEntry> getTypeTemplateEntries()
Returns templates for given types declared in plugin configuration. Skip unresolvable types with a warning. Registration process will not be broken because Plugins may target types not available.

Returns:
List of TypeTemplateEntry
Since:
jcms-6.0.0

registerTemplates

protected void registerTemplates()
Register templates for given types declared in plugin configuration. Skip unresolvable types with a warning. Registration process will not be broken because Plugins may target types not available.

Since:
jcms-6.0.0

getIncludeCollection

protected Collection<String> getIncludeCollection(String tag)
Return a Collection of JSP Relatives path to include for the given anchor.

Parameters:
tag - the anchor to use

registerStoreListener

protected void registerStoreListener(boolean beforeStoreLoad)
Register StoreListeners into the Channel declared in plugin configuration. Skip unresolvable types with a warning. Registration process will not be broken because Plugins may target types not available.

Parameters:
beforeStoreLoad - boolean true before loading store

registerDBListener

protected void registerDBListener()
Register DBListener into the Channel declared in plugin configuration. Skip unresolvable types with a warning. Registration process will not be broken because Plugins may target types not available.


registerDataController

protected void registerDataController()
Register DataControllers into the Channel declared in plugin configuration. Skip unresolvable types with a warning. Registration process will not be broken because Plugins may target types not available.


registerAlarmListener

protected void registerAlarmListener()
Register AlarmListener into the Channel declared in plugin configuration. Skip unresolvable types with a warning. Registration process will not be broken because Plugins may target types not available.


registerChannelListener

protected void registerChannelListener()
Register ChannelListener into the Channel declared in plugin configuration. Skip unresolvable types with a warning. Registration process will not be broken because Plugins may target types not available.

See Also:
getPluginComponents(Class)

registerQueryFilter

protected void registerQueryFilter()
Register QueryFilter into the Channel declared in plugin configuration. Skip unresolvable types with a warning. Registration process will not be broken because Plugins may target types not available.

See Also:
getPluginComponents(Class)

registerCleanFilter

protected void registerCleanFilter()
Register CleanFilter into the Channel declared in plugin configuration. Skip unresolvable types with a warning. Registration process will not be broken because Plugins may target types not available.

See Also:
getPluginComponents(Class)

registerPolicyFilter

protected void registerPolicyFilter()
Register PolicyFilter into the Channel declared in plugin configuration. Skip unresolvable types with a warning. Registration process will not be broken because Plugins may target types not available.

See Also:
getPluginComponents(Class)

registerAuthenticationHandler

protected void registerAuthenticationHandler()
Register Authentication handler into the Channel declared in plugin configuration. Skip unresolvable types with a warning. Registration process will not be broken because Plugins may target types not available.

See Also:
getPluginComponents(Class)

getPluginComponents

protected <T extends PluginComponent> List<T> getPluginComponents(Class<T> clazz)
Convenient method to retrieve a usage of elements from the plugin configuration and create PluginComponents from attribute class Skip unresolvable types with a warning. Registration process will not be broken because Plugins types not available.

Parameters:
clazz - the PluginComponent class
Returns:
List a list of PluginItem (should never be null)

registerHibernateMapping

protected void registerHibernateMapping()
Register the Hibernate mapping files


registerOpenApiResources

protected void registerOpenApiResources()
Register RestResource into the Channel declared in plugin configuration. Skip unresolvable types with a warning. Registration process will not be broken because Plugins may target types not available.


loadProperties

protected void loadProperties(LangProperties properties)
Load plugin properties into channel properties. Properties must be stored in "WEB-INF/plugins/Plugin/properties/" and ends with ".prop".

Parameters:
properties - the channel properties

loadLanguageProperties

protected void loadLanguageProperties(LangProperties properties,
                                      List<String> langList)
Load language properties into channel properties. Properties must be stored in "WEB-INF/plugins/Plugin/properties/languages" and ends with ".prop".

Parameters:
properties - the channel properties
langList - the lang list of JCMS

getEditableProperties

public TreeMap<String,String> getEditableProperties()
Return a TreeMap that contains all plugin properties having an I18N value. Skip properties starting with "extra."

Returns:
TreeMap

getAllPathSet

public Set<String> getAllPathSet(boolean sources,
                                 boolean generated)
Returns a Set of relative path to all Plugins files

Parameters:
sources - include java sources in the path
generated - include generated files
Returns:
Set a set of relatives path

getTypeDirectoriesPathSet

public Set<String> getTypeDirectoriesPathSet()
Returns a Set of new plugin's types directory path

Returns:
Set of String representing types's directories

getTypesPath

public Map<String,Set<String>> getTypesPath(boolean sources,
                                            boolean generated)
Returns a Map of Type Mame / Relative path to declared plugin's type files

Parameters:
sources - include java sources in the path
generated - include generated content
Returns:
Set a set of relatives path

getWorkflowsPath

public Set<String> getWorkflowsPath()
Returns a Set of path to plugin's workflow.

Returns:
Set of path

getJarsPath

public Set<String> getJarsPath()
Returns a Set of path to plugin's jars.

Returns:
Set of path

getJavaPath

public Set<String> getJavaPath(boolean sources)
Returns a Set of path to plugin's java files.

Parameters:
sources - boolean true to include java files
Returns:
Set of path

getHibernateMappingsPath

public Set<String> getHibernateMappingsPath()
Returns a Set of path to plugin's Hibernate mappings (hbm).

Returns:
Set of path
Since:
jcms-6.0.0

getTemplatesPath

public Set<String> getTemplatesPath()
Returns a Set of path to plugin's type's templates.

Returns:
Set of path

getPublicsPath

public Set<String> getPublicsPath()
Returns a Set of path to plugin's public files.

Returns:
Set of path

getPrivatesPath

public Set<String> getPrivatesPath()
Returns a Set of path to plugin's private files.

Returns:
Set of path

getWebappsPath

public Set<String> getWebappsPath()
Returns a Set of path to plugin's webapps files.

Returns:
Set of path

getPluginComponentPath

public Map<String,String> getPluginComponentPath(boolean sources)
Returns a Map from path of plugin's components files to their nature ("storelistener", "dblistener", ...).

Parameters:
sources - boolean true to include java files
Returns:
Map of path ==> nature of plugin component

getOpenAPIResourcePath

public Map<String,String> getOpenAPIResourcePath(boolean sources)
Returns a Map from path of plugin's OpenAPI resources files to their uritemplate.

Parameters:
sources - boolean true to include java files
Returns:
Map of path of resource class ==> uri template

fillElementPath

protected void fillElementPath(Collection<String> paths,
                               List<org.jdom.Element> elmList,
                               String prefix,
                               String tagName,
                               boolean deep,
                               String matchAttribute,
                               String matchValue)

fillJavaSet

protected void fillJavaSet(org.jdom.Element itJava,
                           Set<String> pathSet,
                           boolean sources)

fillPluginComponentPath

protected void fillPluginComponentPath(Map<String,String> itemMap,
                                       String tagName,
                                       boolean sources)

resetConfigToSave

public void resetConfigToSave()
Clones XML document that represents plugin configuration. This method should be called before calling updateXXX() methods.


saveConfig

public void saveConfig()

updateLabel

public void updateLabel(Map<String,String> labelMap)

updateDescription

public void updateDescription(Map<String,String> descriptionMap)

updateInitialized

public void updateInitialized(boolean field)

updateVersion

public void updateVersion(String field)

updateJCMSVersion

public void updateJCMSVersion(String field)

updateOrder

public void updateOrder(int field)

updateUrl

public void updateUrl(String field)

updateAuthor

public void updateAuthor(String field)

updateLicense

public void updateLicense(String field)

updateJSync

public void updateJSync(boolean field)

updateAppServer

public void updateAppServer(String[] field)

updateWorkflowSet

public void updateWorkflowSet(Set<String> workflowSet)

updateJarSet

public void updateJarSet(Set<String> jarSet)

updatePrivateSet

public void updatePrivateSet(Set<String> privateSet)

updatePublicSet

public void updatePublicSet(Set<String> publicSet)

updateWebappSet

public void updateWebappSet(Set<String> webappSet)

updateTypeMap

public void updateTypeMap(Map<String,Set<String>> map)

getLogger

public org.apache.log4j.Logger getLogger()
Returns the logger of the current Plugin. In current implemenation, returned logger is used by JCMS GUI to display Plugin's logs.

Returns:
Logger the logger

toString

public String toString()
Overrides:
toString in class Object

isDeployed

public boolean isDeployed()

isStopped

public boolean isStopped()

isLoaded

public boolean isLoaded()

isInitialized

public boolean isInitialized()

setInitialized

public void setInitialized(boolean initialized)

setStopped

public void setStopped()

setRestart

public void setRestart(boolean restart)

mustRestart

public boolean mustRestart()

isWarned

public boolean isWarned()

setWarned

public void setWarned(boolean warn)

getName

public String getName()

getVersion

public String getVersion()

getBuild

public String getBuild(Locale userLocale)

getJCMSVersion

public String getJCMSVersion()

getOrder

public int getOrder()

getJSync

public boolean getJSync()

getAppServer

public String[] getAppServer()

getUrl

public String getUrl()

getAuthor

public String getAuthor()

getLicense

public String getLicense()

getLabel

public String getLabel(String lang)

getDescription

public String getDescription(String lang)

getDependenceSet

public Set<Plugin> getDependenceSet()

getLabelMap

protected Map<String,String> getLabelMap()

getDescriptionMap

protected Map<String,String> getDescriptionMap()

getPackageName

public String getPackageName()

getPackagePath

public String getPackagePath()

getStatus

public String getStatus(String userLang)

getStatusIcons

public String getStatusIcons(String userLang)

getPropertiesEditor

public String getPropertiesEditor()

getPreview

public String getPreview()

getIcon

public String getIcon()

getChangeLog

public String getChangeLog()

getTextLicense

public String getTextLicense()

getDocumentation

public String getDocumentation()

getConfiguration

public String getConfiguration()

getSignaturePath

public String getSignaturePath()

getPublicPath

protected String getPublicPath(String pluginRelativePath,
                               String defaultPath)


Copyright © 2001-2010 Jalios SA. All Rights Reserved.