public abstract class AbstractPlugin extends Object implements Serializable
Id of a plugin is name_version. See PluginManager.setPluginProps(String, AbstractPlugin, Properties) for more details.
If the id of one plugin equals to another's, considering they are the same.
Note: The subclass extends from this abstract class MUST has a static method named getInstance to obtain an instance
of this plugin. See Singleton Pattern for more implementation
details.
PluginManager,
PluginStatus,
PluginType,
Serialized Form| Constructor and Description |
|---|
AbstractPlugin() |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventListener(AbstractEventListener<?> eventListener)
Adds the specified event listener.
|
void |
addType(PluginType type)
Adds the specified type.
|
void |
changeStatus()
when the plugin change the status,it should note the pointcut lifecycle to know.
|
boolean |
equals(Object obj) |
String |
getAuthor()
Gets the author of this plugin.
|
String |
getDirName()
Gets the directory name of this plugin.
|
String |
getId()
Gets the id.
|
String |
getLang(Locale locale,
String key)
Gets language label with the specified locale and key.
|
String |
getName()
Gets the name of this plugin.
|
String |
getRendererId()
getRendererId.
|
JSONObject |
getSetting()
getSetting.
|
PluginStatus |
getStatus()
Gets the status of this plugin.
|
Set<PluginType> |
getTypes()
Gets the types of this plugin.
|
String |
getVersion()
Gets the version of this plugin.
|
int |
hashCode() |
void |
plug(Map<String,Object> dataModel)
Plugs with the specified data model.
|
void |
plug(Map<String,Object> dataModel,
RequestContext context)
Plugs with the specified data model and the args from request.
|
abstract void |
postPlug(Map<String,Object> dataModel,
RequestContext context)
postPlug after the dataModel of the simplest-view be generated.
|
abstract void |
prePlug(RequestContext context)
prePlug after the real method be invoked.
|
void |
readLangs()
Reads lang_xx.properties into field
langs. |
void |
setAuthor(String author)
Sets the author of this plugin with the specified author.
|
void |
setDir(String dirName)
Sets the directory name of this plugin with the specified directory.
|
void |
setId(String id)
Sets the id with the specified id.
|
void |
setName(String name)
Sets the name of this plugin with the specified name.
|
void |
setRendererId(String rendererId)
setRendererId.
|
void |
setSetting(JSONObject setting)
setSetting.
|
void |
setStatus(PluginStatus status)
Sets the status with the specified status.
|
void |
setVersion(String version)
Sets the version of this plugin with the specified version.
|
protected void |
start()
The lifecycle pointcut for the plugin to start(enable status).
|
protected void |
stop()
The lifecycle pointcut for the plugin to close(disable status).
|
JSONObject |
toJSONObject()
Converts this plugin to a json object (plugin description).
|
void |
unplug()
Unplugs.
|
public void addEventListener(AbstractEventListener<?> eventListener)
eventListener - the specified event listenerpublic void unplug()
public String getDirName()
public void setDir(String dirName)
dirName - the specified directory namepublic void readLangs()
langs.public String getLang(Locale locale, String key)
locale - the specified localekey - the specified keypublic abstract void prePlug(RequestContext context)
context - contextpublic abstract void postPlug(Map<String,Object> dataModel, RequestContext context)
dataModel - dataModelcontext - contextprotected void start()
protected void stop()
public void plug(Map<String,Object> dataModel)
dataModel - the specified data modelpublic void plug(Map<String,Object> dataModel, RequestContext context)
dataModel - dataModelcontext - contextpublic JSONObject toJSONObject() throws JSONException
{
"oId": "",
"name": "",
"version": "",
"author": "",
"status": "" // Enumeration name of PluginStatus
}
JSONException - if can not convertpublic String getId()
public void setId(String id)
id - the specified idpublic void setStatus(PluginStatus status)
status - the specified statuspublic PluginStatus getStatus()
public String getAuthor()
public void setAuthor(String author)
author - the specified authorpublic String getName()
public void setName(String name)
name - the specified namepublic String getVersion()
public void setVersion(String version)
version - the specified versionpublic JSONObject getSetting()
public void setSetting(JSONObject setting)
setting - the setting to setpublic Set<PluginType> getTypes()
public String getRendererId()
public void setRendererId(String rendererId)
rendererId - the rendererId to setpublic void addType(PluginType type)
type - the specified typepublic void changeStatus()
to enable :start() to disable :stop()
Copyright © 2009–2019 B3log. All rights reserved.