Package com.jalios.jcms.plugin
Class Plugin
java.lang.Object
com.jalios.jcms.plugin.Plugin
- All Implemented Interfaces:
Comparable<Plugin>
Main root class representing a Plugin.
- Since:
- jcms-5.7.0
- Author:
- Jean-Philippe Encausse
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classComparator class used to compare Plugins' labelsstatic classDeprecated.this comparator does not properly sort complex plugins dependencies. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Dateprotected String[]protected Stringprotected JPropertiesprotected Stringstatic final Stringprotected static Channelprotected org.jdom.Documentprotected org.jdom.Documentstatic final Stringprotected Datestatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanstatic final Stringprotected Stringstatic org.apache.log4j.Loggerprotected booleanprotected Stringstatic final Stringprotected org.apache.log4j.Loggerprotected Stringprotected intprotected JPropertiesstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Stringprotected Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanCheck if the plugin work with the current application serverprotected booleanCheck if the plugin work with the current JCMS versionintbooleanDisable this plugin.booleanEnable this plugin.protected voidfillElementPath(Collection<String> paths, List<org.jdom.Element> elmList, String prefix, String tagName, boolean deep, String matchAttribute, String matchValue) protected voidfillJavaSet(org.jdom.Element itJava, Set<String> pathSet, boolean sources) protected voidfillPluginComponentPath(Map<String, String> itemMap, String tagName, boolean sources) Returns all plugins used by this plugin recursively.getAllPathSet(boolean sources, boolean generated) Returns a Set of relative path to all Plugins filesString[]Retrieve the Instant this plugin was built.getBuildTime(Locale userLocale) Returns the set of plugins that are dependent of this plugin.getDescription(String lang) getDisplayedStatus(String userLang) get localized status with some UI containerReturn a TreeMap that contains all plugin properties having an I18N value.Returns a Set of path to plugin's Hibernate mappings (hbm).getIcon()protected Collection<String> Returns a Collection of JSP Relatives path to include for the given anchor.Returns the relative path to the packaged plugin jar sourcesReturns a Set of path to plugin's jars.getJavaPath(boolean sources) Returns a Set of path to plugin's java files.Returns a Set of path to plugin's java files by only checking declared packages in plugin.xmlbooleangetJSync()org.apache.log4j.LoggerDeprecated.since 10.0.8 / JCMS-10220.getName()getOpenAPIResourcePath(boolean sources) Returns a Map from path of plugin's OpenAPI resources files to their uritemplate.intgetOrder()Returns a Set of File representing all package version for this plugin.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.protected <T extends PluginComponent>
List<T> getPluginComponents(Class<T> clazz, String tagName) Convenient method to retrieve a usage of elements from the plugin configuration and create PluginComponents from attribute class Skip unresolvable types with a warning.Returns a Set of path to plugin's private files.Retrieve all properties declared by this pluginprotected StringgetPublicPath(String pluginRelativePath, String defaultPath) Returns a Set of path to plugin's public files.Retrieve the path of the plugin signature.get the status (in english) with any UI artefacts (for REST export for example).Deprecated.getDisplayedStatus(String)method should be used insteadgetStatusIcons(String userLang) Returns a Set of path to plugin's type's templates.Returns a Set of new plugin's types directory pathgetTypesPath(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, ...)Returns templates for given types declared in plugin configuration.getUrl()Returns a Set of path to plugin's webapps files.Returns a Set of path to plugin's workflow.voidinit(boolean isEnabled) Called by PluginManager during initialization after all plugins dependencies initialized.protected voidvoidinitDependencies(boolean checkStatus) Called by PluginManager during initialization after all plugins loads.booleanisActive()booleanbooleanbooleanbooleanbooleanisLoaded()booleanReturns true if this plugin is the main plugin.booleanisProvidingType(String className) Returns true if the give className is a type provided by this plugin.booleanisProvidingWorkflow(String wfId) Returns true if the given Workflow is provided by this plugin.booleanbooleanisWarned()voidload(org.jdom.Document config, boolean isDeployed) Called by PluginManager during initialization to setup main variable from config file.protected voidloadLanguageProperties(LangProperties properties, List<String> langList) Load language properties into channel properties.protected voidloadProperties(LangProperties properties) Load plugin properties into channel properties.booleanbooleanperformPackage(boolean sources) Performs a package of the plugin's files.protected voidRegister AlarmListener into the Channel declared in plugin configuration.protected voidRegister AlertChannel declared in plugin configuration.voidRegister all components of this plugin.protected voidRegister Authentication handler into the Channel declared in plugin configuration.protected voidRegister ChannelListener into the Channel declared in plugin configuration.protected voidRegister CleanFilter into the Channel declared in plugin configuration.protected voidRegister DataControllers into the Channel declared in plugin configuration.protected voidRegister DBListener into the Channel declared in plugin configuration.protected voidRegister the Hibernate mapping filesprotected voidRegister JSyncListeners into the Channel declared in plugin configuration.protected voidRegister RestResource into the Channel declared in plugin configuration.protected voidRegister PolicyFilter into the Channel declared in plugin configuration.protected voidRegister QueryFilter into the Channel declared in plugin configuration.protected voidregisterStoreListener(boolean beforeStoreLoad) Register StoreListeners into the Channel declared in plugin configuration.protected voidRegister templates for given types declared in plugin configuration.voidClones XML document that represents plugin configuration.voidvoidvoidvoidsetEnabled(boolean isEnabled) voidsetInitialized(boolean initialized) voidsetRestart(boolean restart) voidvoidsetup()Called by PluginManager during initialization after all plugins dependencies initialized.voidsetWarned(boolean warn) toString()voidUnregister all components of this plugin.voidupdateAppServer(String[] v) voidvoidvoidupdateInitialized(boolean v) voidupdateJarSet(Set<String> jarSet) voidvoidupdateJSync(boolean v) voidupdateLabel(Map<String, String> v) voidvoidupdateOrder(int v) voidupdatePrivateSet(Set<String> privateSet) voidupdatePublicSet(Set<String> publicSet) voidupdateTypeMap(Map<String, Set<String>> map) voidvoidvoidupdateWebappSet(Set<String> webappSet) voidupdateWorkflowSet(Set<String> workflowSet)
-
Field Details
-
jcmsLogger
public static org.apache.log4j.Logger jcmsLogger -
channel
-
SIGNATURE
- See Also:
-
CHANGELOG
- See Also:
-
DOCUMENTATION
- See Also:
-
JAVADOC
- See Also:
-
LICENSE
- See Also:
-
PREVIEW
- See Also:
-
PREVIEW_PNG
- See Also:
-
ICON_GIF
- See Also:
-
ICON_PNG
- See Also:
-
ICON_SVG
- See Also:
-
CONFIGURATION
- See Also:
-
PROPERTIES_EDITOR
- See Also:
-
DEFAULT_PROPERTIES_EDITOR
- See Also:
-
DEFAULT_PREVIEW
- See Also:
-
DEFAULT_ICON
- See Also:
-
XML_PRIVATE
- See Also:
-
XML_PUBLIC
- See Also:
-
XML_WEBAPP
- See Also:
-
XML_TYPES
- See Also:
-
XML_TYPE
- See Also:
-
XML_DEPENDENCIES
- See Also:
-
XML_DEPENDENCY
- See Also:
-
XML_COMPONENTS
- See Also:
-
XML_HIBERNATE
- See Also:
-
XML_OPENAPI
- See Also:
-
XML_OPENAPI_RESOURCE
- See Also:
-
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 -
isEnabled
protected boolean isEnabled -
isStopped
protected boolean isStopped -
isWarned
protected boolean isWarned -
isRestart
protected boolean isRestart -
activationRequestDate
-
deactivationRequestDate
-
name
-
version
-
jcms
-
order
protected int order -
dependenceSet
-
activeDependenceSet
-
allDependenceSet
-
jsync
protected boolean jsync -
appserver
-
url
-
author
-
license
-
labelMap
-
descriptionMap
-
typeNameSet
-
workflowIdSet
-
pluginProp
-
unregisterMap
-
build
-
buildTime
-
-
Constructor Details
-
Plugin
public Plugin() -
Plugin
Create a Plugin from a given Camelized Label- Parameters:
label- the plugin label
-
-
Method Details
-
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 fileisDeployed- true if the plugin has been deployed
-
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
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
-
getAllDependenceSet
Returns all plugins used by this plugin recursively. TODO: Cache the Set- Returns:
- Set of Plugin used by this plugin
-
getDependentPluginSet
Returns the set of plugins that are dependent of this plugin. If isActive true returns only plugins that are dependent is active state.- Returns:
- the set of plugins that are dependent of this plugin.
- Since:
- jcms-10.0.0
-
init
public void init(boolean isEnabled) Called by PluginManager during initialization after all plugins dependencies initialized. Called juste after PluginManager Initialisation:- Plugin order declaration is respected.
- Channel not completly initialised
- Properties not loaded.
- Parameters:
isEnabled- indicates if the plugin is enabled or not.
-
setup
public void setup()Called by PluginManager during initialization after all plugins dependencies initialized.- Plugin order declaration is respected.
- Properties loaded.
-
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
-
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
Returns a Collection of JSP Relatives path to include for the given anchor.- Parameters:
tag- the anchor to use- Returns:
- a Collection of JSP Relatives path to include for the given anchor.
-
registerAllComponents
public void registerAllComponents()Register all components of this plugin.- Since:
- jcms-10.0.0
-
unregisterAllComponents
public void unregisterAllComponents()Unregister all components of this plugin.- Since:
- jcms-10.0.0
-
enablePlugin
public boolean enablePlugin()Enable this plugin.- Returns:
- true if this plugin has been successfully enabled.
- Since:
- jcms-10.0.0
-
disablePlugin
public boolean disablePlugin()Disable this plugin.- Returns:
- true if this plugin has been successfully disabled.
- Since:
- jcms-10.0.0
-
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. -
registerJSyncListener
protected void registerJSyncListener()Register JSyncListeners 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. -
registerAlertChannel
protected void registerAlertChannel()Register AlertChannel 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:
-
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:
-
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:
-
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:
-
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
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.- Type Parameters:
T- A PluginComponent type- Parameters:
clazz- the PluginComponent class- Returns:
- List a list of PluginItem (should never be null)
-
getPluginComponents
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.- Type Parameters:
T- A PluginComponent type- Parameters:
clazz- the PluginComponent classtagName- the name of the tag used in plugin.xml- 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
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
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 propertieslangList- the lang list of JCMS
-
getProperties
Retrieve all properties declared by this plugin- Returns:
- a JProperties instance
- Since:
- 10.0.8 / JCMS-10969
-
getEditableProperties
Return a TreeMap that contains all plugin properties having an I18N value. Skip properties starting with "extra."- Returns:
- TreeMap
-
getAllPathSet
Returns a Set of relative path to all Plugins files- Parameters:
sources- include java sources in the pathgenerated- include generated files- Returns:
- Set a set of relatives path
-
getTypeDirectoriesPathSet
Returns a Set of new plugin's types directory path- Returns:
- Set of String representing types's directories
-
getTypesPath
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, ...)
- Parameters:
sources- include java sources in the pathgenerated- include generated content- Returns:
- Set a set of relatives path
-
getWorkflowsPath
Returns a Set of path to plugin's workflow.- Returns:
- Set of path
-
getJarsPath
Returns a Set of path to plugin's jars.- Returns:
- Set of path
-
getJavaPath
Returns a Set of path to plugin's java files.- Parameters:
sources- boolean true to include java files- Returns:
- Set of path
-
getJavaPathWithoutCheckingFolder
Returns a Set of path to plugin's java files by only checking declared packages in plugin.xml- Returns:
- Set of path
-
getHibernateMappingsPath
Returns a Set of path to plugin's Hibernate mappings (hbm).- Returns:
- Set of path
- Since:
- jcms-6.0.0
-
getTemplatesPath
Returns a Set of path to plugin's type's templates.- Returns:
- Set of path
-
getPublicsPath
Returns a Set of path to plugin's public files.- Returns:
- Set of path
-
getPrivatesPath
Returns a Set of path to plugin's private files.- Returns:
- Set of path
-
getWebappsPath
Returns a Set of path to plugin's webapps files.- Returns:
- Set of path
-
getPluginComponentPath
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
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
-
fillJavaSet
-
fillPluginComponentPath
-
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
-
updateDescription
-
updateInitialized
public void updateInitialized(boolean v) -
updateVersion
-
updateJCMSVersion
-
updateOrder
public void updateOrder(int v) -
updateUrl
-
updateAuthor
-
updateLicense
-
updateJSync
public void updateJSync(boolean v) -
updateAppServer
-
updateWorkflowSet
-
updateJarSet
-
updatePrivateSet
-
updatePublicSet
-
updateWebappSet
-
updateTypeMap
-
getLogger
Deprecated.since 10.0.8 / JCMS-10220. You should use a logger specific to your package/class, not this generic one. The visilibty of this method will be changed in a further version (JCMS-10221)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
-
isDeployed
public boolean isDeployed() -
isStopped
public boolean isStopped() -
isLoaded
public boolean isLoaded() -
isInitialized
public boolean isInitialized() -
setInitialized
public void setInitialized(boolean initialized) -
isEnabled
public boolean isEnabled() -
setEnabled
public void setEnabled(boolean isEnabled) -
getActivationRequestDate
-
getDeactivationRequestDate
-
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
-
getVersion
-
isActive
public boolean isActive() -
initBuild
protected void initBuild() -
getBuild
-
getSvnRevision
-
getJenkinsTag
-
getBuildTime
-
getBuildTime
-
getBuildInstant
Retrieve the Instant this plugin was built.Implementation details : this method parses the value of the
{PluginName}.timestampproperty in thebuild.propof the plugin, if any.- Returns:
- an Instant or null if could not be retrieved
- Since:
- JCMS-11605
-
getJCMSVersion
-
getOrder
public int getOrder() -
getJSync
public boolean getJSync() -
getAppServer
-
getUrl
-
getAuthor
-
getLicense
-
getLabel
-
getDescription
-
getDependenceSet
-
getActiveDependenceSet
-
getLabelMap
-
getDescriptionMap
-
getPackageName
-
getPackagePath
-
getStatus
get the status (in english) with any UI artefacts (for REST export for example).- Returns:
- the status o the plugin
-
getStatus
Deprecated.getDisplayedStatus(String)method should be used insteadget localized status with some UI container- Parameters:
userLang- the user language to display status- Returns:
- the displayed status of the plugin
-
getDisplayedStatus
get localized status with some UI container- Parameters:
userLang- the user language to display status- Returns:
- the displayed status of the plugin
-
getStatusIcons
-
getPropertiesEditor
-
getPreview
- Returns:
- PNG version "docs/images/preview.png" (
PREVIEW_PNG) if exists, else, JPG version "docs/images/preview.jpg" (PREVIEW) if exists, else, default preview "images/jalios/logos/puzzle.jpg" (DEFAULT_PREVIEW)
-
isBitmapIcon
public boolean isBitmapIcon() -
getIcon
- Returns:
- SVG version "docs/images/icon.svg" (
ICON_SVG) if exists, else PNG version "docs/images/icon.png" (ICON_PNG) if exists, else GIF version "docs/images/icon.gif" (ICON_GIF) if exists, else, default icon "frontend/icons/files/Generic/Plugin.svg" (DEFAULT_ICON)
-
getChangeLog
-
getTextLicense
-
getDocumentation
-
getJavadocHtmlLink
-
getConfiguration
-
getSignaturePath
Retrieve the path of the plugin signature.Plugin signature is no longer generated since JPlatform 11 (JCMS-11520).
This method is still available for internal uses to ignore/delete old signature file.- Returns:
- a relative path, such as
WEB-INF/plugins/MyPlugin/signature.xml
-
getPublicPath
-
isMainPlugin
public boolean isMainPlugin()Returns true if this plugin is the main plugin.- Returns:
- true if this plugin is the main plugin.
- Since:
- jcms-8.0.1
-
compareTo
- Specified by:
compareToin interfaceComparable<Plugin>
-
isProvidingType
Returns true if the give className is a type provided by this plugin.- Parameters:
className- the class name of type.- Returns:
- true if the give className is a type provided by this plugin.
- Since:
- jcms-10.0.0
-
isProvidingWorkflow
Returns true if the given Workflow is provided by this plugin.- Parameters:
wfId- the workflow ID.- Returns:
- true if the given Workflow is provided by this plugin.
- Since:
- jcms-10.0.0
-
sendRequestForActivation
public void sendRequestForActivation() -
sendRequestForDeactivation
public void sendRequestForDeactivation()
-