|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.BasicItem<D> net.sf.basedb.core.OwnedItem<D> net.sf.basedb.core.SharedItem<PluginDefinitionData> net.sf.basedb.core.PluginDefinition
public class PluginDefinition
A plugin definition represents the executable plugin. Ie.
the class name of a class implementing the Plugin
interface.
Field Summary | |
---|---|
static int |
MAX_CLASSNAME_LENGTH
The maximum length of the class name that can be stored in the database. |
static int |
MAX_CONTACT_LENGTH
The maximum length of the contact information that can be stored in the database. |
static int |
MAX_COPYRIGHT_LENGTH
The maximum length of the copyright notice that can be stored in the database. |
static int |
MAX_EMAIL_LENGTH
The maximum length of the email address that can be stored in the database. |
static int |
MAX_JARPATH_LENGTH
The maximum length of the jar path name that can be stored in the database. |
static int |
MAX_NAME_LENGTH
The maximum length of the name that can be stored in the database. |
static int |
MAX_URL_LENGTH
The maximum length of the url that can be stored in the database. |
static int |
MAX_VERSION_LENGTH
The maximum length of the version that can be stored in the database. |
static Item |
TYPE
The type of item represented by this class. |
Fields inherited from interface net.sf.basedb.core.Nameable |
---|
MAX_DESCRIPTION_LENGTH |
Constructor Summary | |
---|---|
PluginDefinition(PluginDefinitionData pd)
|
Method Summary | ||
---|---|---|
static String |
convertToAbsolute(String path)
Convert a relative plug-in path to an absolute path. |
|
static String |
convertToRelative(String path)
Convert a plug-in path to a path relative to the plugins.dir
setting in base.config . |
|
static Map<Plugin.MainType,Integer> |
countPlugins(DbControl dc,
GuiContext gc)
Count the number of plugins that can be used in a given context. |
|
boolean |
getAllowImmediateExecution()
If immediate execution of jobs are allowed or if they always must go through the job queue. |
|
Set<Annotatable> |
getAnnotatableParents()
Get all parents objects which are annotatable and the logged in user has read permission to. |
|
String |
getAnnotationMessage()
Get a message explaining what the proxy does with the annotations. |
|
AnnotationSet |
getAnnotationSet()
Get the annotation set containing the annotations for this item. |
|
ItemQuery<AnnotationType> |
getAnnotationTypes()
Get the annotation types that can be used by this configuration. |
|
static PluginDefinition |
getByClassName(DbControl dc,
String className)
Get a PluginDefinition item when you know the class name. |
|
static PluginDefinition |
getById(DbControl dc,
int id)
Get a PluginDefinition item when you know the ID. |
|
String |
getClassName()
Get the class name of the Java class that implements this plugin. |
|
String |
getContact()
Get contact information for the plugin. |
|
String |
getCopyright()
Get a copyright notice for the plugin. |
|
Set<Permission> |
getDenied(RoleKey roleKey)
Get the permissions that have been denied to this plugin. |
|
String |
getDescription()
Get a description of the plugin. |
|
String |
getEmail()
Get an email address that can be used to get more information about the plugin. |
|
Date |
getEntryDate()
Get the date that the item was registered in the database. |
|
Set<Permission> |
getGranted(RoleKey roleKey)
Get the permissions that have been granted to this plugin. |
|
Set<GuiContext> |
getGuiContexts()
Get the Item types where it makes sense to use this plugin
for a client application. |
|
String |
getJarPath()
Get the path to the JAR file that contains the plugin class file. |
|
Plugin.MainType |
getMainType()
Get the type of plugin. |
|
Long |
getMaxMemory()
Get the maximum amount of memory the plugins is allowed to use. |
|
String |
getName()
Get the name of the plugin. |
|
static PluginDefinition |
getNew(DbControl dc,
String className,
String jarPath,
boolean useRequestedPermissions)
Create a new PluginDefinition item. |
|
ItemQuery<PluginConfiguration> |
getPluginConfigurations()
Get a query that returns the configurations for this plugin definition. |
|
ItemQuery<PluginType> |
getPluginTypes()
Get a query that returns the plugin types for this plugin definition. |
|
Protocol |
getProtocol()
A protcol used in the creation of an item that is used to attach annotations for the protocol parameters. |
|
static ItemQuery<PluginDefinition> |
getQuery()
Get a query that returns plugin definitions. |
|
static ItemQuery<PluginDefinition> |
getQuery(GuiContext gc,
String interfaceName)
Get a query that returns all plugins related to a specified GUI context and implementing a certain interface. |
|
Item |
getType()
Get the type of item represented by the object. |
|
String |
getUrl()
Get a URL with more information about the plugin. |
|
boolean |
getUseInternalJobQueue()
If this plug-in can be executed by the internal job queue or not. |
|
boolean |
getUsePermissions()
Check if this plugin should execute with or without permissions. |
|
Set<ItemProxy> |
getUsingItems()
Get all: PluginConfiguration :s created from this plugin
Job :s using this plugin
|
|
String |
getVersionString()
Get the version of the plugin. |
|
boolean |
isAnnotated()
Check if this item has an annotation set. |
|
boolean |
isInContext(GuiContext context)
Check if it makes sense to use this plugin in the context of the specified item. |
|
boolean |
isInteractive()
Check if the plugin is interactive or not. |
|
boolean |
isRemoved()
Check if the removed flag is set for this item. |
|
boolean |
isTrusted()
If this plugin is trusted or not. |
|
boolean |
isUsed()
Check if a PluginConfiguration is using this definition. |
|
void |
loadPluginInformation(String jarPath,
String className,
boolean useRequstedPermissions)
Load a plugin and copy all information, ie. plugin.about(), to the internal data structure. |
|
Plugin |
newInstance()
Get an unitialized instance of the plugin. |
|
|
newInstance(Class<P> clazz,
String jarPath)
Get an unitialized instance of the plugin implementation. |
|
|
newInstance(Class<P> clazz,
String jarPath,
SessionControl sc,
PluginConfiguration configuration,
Job job)
Get an initialized instance of the plugin implementation. |
|
(package private) Plugin |
newInstance(String jarPath)
|
|
private Plugin |
newInstance(String jarPath,
String className,
boolean unloadBefore)
Create a new object instance of the given class. |
|
PluginConfiguration |
newPluginConfiguration()
Create a new PluginConfiguration for this plugin. |
|
void |
removeAnnotations()
Remove all annotations from this item, by deleting the annotation set. |
|
boolean |
requiresConfiguration()
Check if the plugin requires a configuration to execute a job. |
|
void |
setAllowImmediateExecution(boolean allow)
|
|
private void |
setClassName(String className)
The class name cannot be changed. |
|
private void |
setContact(String contact)
The contact information cannot be changed. |
|
private void |
setCopyright(String copyright)
The copyright notice cannot be changed. |
|
void |
setDescription(String description)
The description cannot be changed. |
|
protected void |
setDescriptionInternal(String description)
The description cannot be changed. |
|
private void |
setEmail(String email)
The email address cannot be changed. |
|
private void |
setGuiContexts(Set<GuiContext> pluginContexts)
Set the contexts where this plugin can be used. |
|
private void |
setInteractive(boolean interactive)
|
|
private void |
setJarPath(String jarPath)
The jar path cannot be changed. |
|
private void |
setMainType(Plugin.MainType type)
The type cannot be changed. |
|
void |
setMaxMemory(Long maxMemory)
Set the maximum amount of memory the plugin is allowed to use. |
|
void |
setName(String name)
The name cannot be changed. |
|
private void |
setNameInternal(String name)
The name cannot be changed. |
|
void |
setPermissions(RoleKey roleKey,
Set<Permission> granted,
Set<Permission> denied)
Sets the permissions for this plugin. |
|
void |
setRemoved(boolean removed)
Set the removed flag for this item. |
|
private void |
setRequiresConfiguration(boolean requiresConfiguration)
|
|
private void |
setSupportsConfigurations(boolean supportsConfigurations)
|
|
void |
setTrusted(boolean trusted)
Set if this plugin should be trusted or not. |
|
private void |
setUrl(String url)
The URL cannot be changed. |
|
void |
setUseInternalJobQueue(boolean use)
Set if the plug-in can use the internal job queue or not. |
|
void |
setUsePermissions(boolean usePermissions)
|
|
private void |
setVersionString(String version)
The version cannot be changed. |
|
boolean |
supports(PluginType pluginType)
Check if a plugin implements the interface specified by the plugin type. |
|
boolean |
supports(String interfaceName)
Check if a plugin implements the interface specified by the plugin type. |
|
boolean |
supportsConfigurations()
Check if the plugin supports configurations or not when executing a job. |
Methods inherited from class net.sf.basedb.core.SharedItem |
---|
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey, toTransferable |
Methods inherited from class net.sf.basedb.core.OwnedItem |
---|
getOwner, isOwner, setOwner, takeOwnership, toTransferable |
Methods inherited from class net.sf.basedb.core.BasicItem |
---|
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.basedb.core.Identifiable |
---|
getId, getVersion |
Methods inherited from interface net.sf.basedb.core.AccessControlled |
---|
checkPermission, getPermissions, hasPermission |
Methods inherited from interface net.sf.basedb.core.Ownable |
---|
getOwner, isOwner, setOwner, takeOwnership |
Field Detail |
---|
public static final Item TYPE
Item.PLUGINDEFINITION
,
getType()
public static final int MAX_CLASSNAME_LENGTH
setClassName
method to avoid exceptions.
public static final int MAX_JARPATH_LENGTH
public static final int MAX_NAME_LENGTH
public static final int MAX_VERSION_LENGTH
public static final int MAX_COPYRIGHT_LENGTH
public static final int MAX_CONTACT_LENGTH
public static final int MAX_EMAIL_LENGTH
public static final int MAX_URL_LENGTH
Constructor Detail |
---|
PluginDefinition(PluginDefinitionData pd)
Method Detail |
---|
public static String convertToRelative(String path)
plugins.dir
setting in base.config
. If no plug-in directory has been
specified or if the path is null nothing is done. If the given path is
a subpath to the plugins.dir
path the common path is replaced
with %plugins.dir%
and all path separator characters are
converted to '/'. For example:
path
- The absolute path
convertToAbsolute(String)
public static String convertToAbsolute(String path)
convertToRelative(String)
method.
path
- The relative path
public static PluginDefinition getNew(DbControl dc, String className, String jarPath, boolean useRequestedPermissions) throws BaseException
PluginDefinition
item.
dc
- The DbControl
which will be used for
permission checking and database access.className
- The name of the class that implements the plugin
interfacejarPath
- Optional path to the jar file which contains the
plugin class, if missing the plugin must be in the classpathuseRequestedPermissions
- If the permissions that are returned
by the Plugin.getPermissions()
method should be used or not.
If not used the plugin uses the permissions from the logged in user
PluginDefinition
item
BaseException
- If there is an errorpublic static PluginDefinition getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
PluginDefinition
item when you know the ID.
dc
- The DbControl
which will be used for
permission checking and database access.id
- The ID of the item to load.
PluginDefinition
item.
ItemNotFoundException
- If an item with the specified ID is not found.
PermissionDeniedException
- If the logged in user doesn't have
READ
permission for the item.
BaseException
- If there is another error.public static PluginDefinition getByClassName(DbControl dc, String className) throws ItemNotFoundException, PermissionDeniedException, BaseException
PluginDefinition
item when you know the class name.
dc
- The DbControl
which will be used for
permission checking and database access.className
- The class name of the item to load.
PluginDefinition
item.
ItemNotFoundException
- If an item with the specified class name is not found.
PermissionDeniedException
- If the logged in user doesn't have
READ
permission for the item.
BaseException
- If there is another error.public static ItemQuery<PluginDefinition> getQuery()
ItemQuery
objectpublic static ItemQuery<PluginDefinition> getQuery(GuiContext gc, String interfaceName)
isInContext(GuiContext)
returns true for the
specified item, and supports(PluginType)
returns
true for the specified interface.
gc
- The context the plugin should be related to, or null
if this parameter is irrelevantinterfaceName
- The complete name of the interface that the plugin
must implement, or null if this parameter is irrelevantpublic static Map<Plugin.MainType,Integer> countPlugins(DbControl dc, GuiContext gc) throws BaseException
dc
- An open DbControl objectgc
- The context to count plugins for
BaseException
- If the plugins could not be counted.public Item getType()
Identifiable
Item
enumeration.
getType
in interface Identifiable
public boolean isRemoved()
Removable
isRemoved
in interface Removable
public void setRemoved(boolean removed) throws PermissionDeniedException
Removable
setRemoved
in interface Removable
removed
- TRUE if the item should be flagged as removed,
FALSE otherwise
PermissionDeniedException
- If the logged in user doesn't
have Permission.DELETE
permission for setting the flag
to TRUE or Permission.WRITE
permission for setting the
flag to FALSEpublic Date getEntryDate()
Registered
getEntryDate
in interface Registered
public boolean isUsed() throws BaseException
PluginConfiguration
is using this definition.
isUsed
in class BasicItem<PluginDefinitionData>
BaseException
- If not able to tell if item is used or not.BasicItem.getUsingItems()
public Set<ItemProxy> getUsingItems()
PluginConfiguration
:s created from this plugin
Job
:s using this plugin
getUsingItems
in class BasicItem<PluginDefinitionData>
BasicItem.addUsingItems(Set, Item, org.hibernate.Query)
public AnnotationSet getAnnotationSet() throws PermissionDeniedException, BaseException
Annotatable
DbControl.commit()
is
called. To check if an item has annotations without creating a new
annotation set use the Annotatable.isAnnotated()
method.
getAnnotationSet
in interface Annotatable
AnnotationSet
PermissionDeniedException
- If the logged in user doesn't have
enough permissions
BaseException
- If there is another errorpublic boolean isAnnotated()
Annotatable
isAnnotated
in interface Annotatable
public void removeAnnotations() throws PermissionDeniedException, BaseException
Annotatable
removeAnnotations
in interface Annotatable
PermissionDeniedException
- If the logged in user doesn't have
write permission
BaseException
- If there is another errorpublic Protocol getProtocol()
Annotatable
getProtocol
in interface Annotatable
public Set<Annotatable> getAnnotatableParents()
Annotatable
getAnnotatableParents
in interface Annotatable
public ItemQuery<AnnotationType> getAnnotationTypes()
AnnotationSetterPlugin
interface.
getAnnotationTypes
in interface AnnotatableProxy
public String getAnnotationMessage()
getAnnotationMessage
in interface AnnotatableProxy
public String getClassName()
Plugin
interface.
private void setClassName(String className) throws InvalidDataException
InvalidDataException
public String getJarPath()
private void setJarPath(String jarPath) throws InvalidDataException
InvalidDataException
public String getName()
getName
in interface Nameable
public void setName(String name) throws PermissionDeniedException
setName
in interface Nameable
name
- The new name for the item
PermissionDeniedException
- Alwaysprivate void setNameInternal(String name) throws InvalidDataException
InvalidDataException
- If the name is null or too longloadPluginInformation(String, String, boolean)
public String getDescription()
getDescription
in interface Nameable
public void setDescription(String description) throws PermissionDeniedException
setDescription
in interface Nameable
description
- The new description for the item
PermissionDeniedException
- Alwaysprotected void setDescriptionInternal(String description) throws InvalidDataException
InvalidDataException
- If the description is too longloadPluginInformation(String, String, boolean)
public String getVersionString()
private void setVersionString(String version) throws InvalidDataException
InvalidDataException
- If the version is too longloadPluginInformation(String, String, boolean)
public String getCopyright()
private void setCopyright(String copyright) throws InvalidDataException
InvalidDataException
- If the copyright is too longloadPluginInformation(String, String, boolean)
public String getContact()
private void setContact(String contact) throws InvalidDataException
InvalidDataException
- If the contact is too longloadPluginInformation(String, String, boolean)
public String getEmail()
private void setEmail(String email) throws InvalidDataException
InvalidDataException
- If the email is too longloadPluginInformation(String, String, boolean)
public String getUrl()
private void setUrl(String url) throws InvalidDataException
InvalidDataException
- If the url is too longloadPluginInformation(String, String, boolean)
public boolean isTrusted()
public void setTrusted(boolean trusted)
PermissionDeniedException
- If the logged in user doesn't have write
permissionisTrusted()
public Long getMaxMemory()
agent.maxMemory
setting in it's configuration file.
public void setMaxMemory(Long maxMemory)
maxMemory
- The maximum amount, or null if the job agent should decide
PermissionDeniedException
- If the logged in user doesn't have write
permissiongetMaxMemory()
public Plugin.MainType getMainType()
Plugin.MainType
.private void setMainType(Plugin.MainType type) throws InvalidDataException
InvalidDataException
- If the type is nullloadPluginInformation(String, String, boolean)
public boolean isInteractive()
InteractivePlugin
interface
and can be dynamically configured by telling the client
application what configuration parameters it needs.
private void setInteractive(boolean interactive)
public boolean supportsConfigurations()
PluginConfiguration
for this plugin. The return value
should be used by client applications for better GUI.
private void setSupportsConfigurations(boolean supportsConfigurations)
public boolean requiresConfiguration()
InvalidDataException
if
a configuration is required but isn't supplied.
private void setRequiresConfiguration(boolean requiresConfiguration)
public boolean getUsePermissions()
setPermissions(RoleKey, Set, Set)
public void setUsePermissions(boolean usePermissions)
public boolean getAllowImmediateExecution()
ImmediateDownloadExporter
public void setAllowImmediateExecution(boolean allow)
public boolean getUseInternalJobQueue()
public void setUseInternalJobQueue(boolean use)
use
- TRUE to use the internal job queue, FALSE to only use
job agentspublic boolean isInContext(GuiContext context)
Item.REPORTER
.
context
- The GuiContext
type
public Set<GuiContext> getGuiContexts()
Item
types where it makes sense to use this plugin
for a client application. For example, a plugin that imports
reporters would return a set containing Item.REPORTER
.
Set
of Item
:s or an empty set
if the plugin is not concerned about itemsprivate void setGuiContexts(Set<GuiContext> pluginContexts)
public PluginConfiguration newPluginConfiguration() throws PermissionDeniedException, BaseException
PluginConfiguration
for this plugin.
PluginConfiguration
item
PermissionDeniedException
- If
the logged in user doesn't have use
permission for this plugin definition
BaseException
- If there is another
errorpublic ItemQuery<PluginConfiguration> getPluginConfigurations()
ItemQuery
objectpublic ItemQuery<PluginType> getPluginTypes()
ItemQuery
objectpublic boolean supports(PluginType pluginType)
pluginType
- The pluginType to check
public boolean supports(String interfaceName)
interfaceName
- The pluginType to check
public Plugin newInstance() throws PermissionDeniedException, BaseException
PermissionDeniedException
- If the logged in user doesn't have
Permission.USE
permission to the items.
BaseException
- If there is a problem creating an instance.Plugin newInstance(String jarPath) throws PermissionDeniedException, BaseException
PermissionDeniedException
BaseException
public <P extends Plugin> P newInstance(Class<P> clazz, String jarPath) throws PermissionDeniedException, BaseException
P
- The kind of returned object that extends Plugin.clazz
- The class of the plugin which must be a subclass of Plugin
jarPath
- Overrides the default JAR path for a plugin, null to use the default
JAR path
PermissionDeniedException
BaseException
public <P extends Plugin> P newInstance(Class<P> clazz, String jarPath, SessionControl sc, PluginConfiguration configuration, Job job) throws PermissionDeniedException, BaseException
P
- The kind of returned object that extends Plugin.clazz
- The class of the plugin which must be a subclass of Plugin
jarPath
- Overrides the default JAR path for a plugin, null to use the default
JAR pathsc
- The session control to initialise the plugin withconfiguration
- The configuration parameters to initialise the plugin with,
or null if no configuration existsjob
- The job parameters to intialise the plugin with, or null if no
job exists
PermissionDeniedException
BaseException
private Plugin newInstance(String jarPath, String className, boolean unloadBefore) throws BaseException
jarPath
- The path to the JAR fileclassName
- The class to createunloadBefore
- If the class definition should be unloaded before the new
instance is created, unloading may not work if a client
program holds a reference to an instance of the class
BaseException
public void setPermissions(RoleKey roleKey, Set<Permission> granted, Set<Permission> denied) throws PermissionDeniedException, InvalidUseOfNullException
NOTE! The granted permissions are always granted, regardless of the logged in user's permissions. The denied permissions are always denied regardless of the logged in user's permissions. This applies even to the root user account.
If the granted permissions is null or empty and the denied permissions is null or contains the same set of permissions as defined by the item type the permissions are removed from the database, which means that only those permissions which differs from the defaults are stored in the database.
roleKey
- The rolekey for this plugingranted
- The permission to grant to the plugindenied
- The permissions to deny the plugin
PermissionDeniedException
- If the logged in user doesn't have Permission.SET_PERMISSION
for this PluginDefinition
or trying to grant the plugin more permission then the logged in user
InvalidUseOfNullException
- If the rolekey is nullpublic Set<Permission> getGranted(RoleKey roleKey) throws InvalidUseOfNullException
roleKey
- The role key to get the permission for
InvalidUseOfNullException
- If the role key is nullpublic Set<Permission> getDenied(RoleKey roleKey) throws InvalidUseOfNullException
roleKey
- The role key to get the permission for
InvalidUseOfNullException
- If the role key is nullpublic void loadPluginInformation(String jarPath, String className, boolean useRequstedPermissions) throws PermissionDeniedException, InvalidDataException, BaseException
jarPath
- Path to the jar-file in which the plugin is located.
Null is allowed if plugin is located in the web server's classpath.className
- Full class name of the plugin's main class.useRequstedPermissions
- TRUE if plugin should use the permissions it requests.
PermissionDeniedException
- If logged in user doesn't have write permission to this item.
InvalidDataException
- If any of the arguments is malformed or
if setting the plugin's properties fails.
BaseException
- If something else fails.
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |