|
3.0.4: 2012-03-05 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.basedb.core.BasicItem<D>
net.sf.basedb.core.OwnedItem<D>
net.sf.basedb.core.SharedItem<D>
net.sf.basedb.core.CommonItem<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 | |
---|---|
private PluginInfo |
info
|
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_JARFILE_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 void |
checkInstallation(DbControl dc,
Collection<PluginInfo> plugins)
Check the installation status of the given list of plug-ins. |
|
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 |
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 |
getJarFile()
Get the name of the JAR file that contains this plug-in. |
|
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. |
|
static PluginDefinition |
getNew(DbControl dc,
String className,
String jarFile,
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. |
|
static PluginDefinition |
installOrUpdate(DbControl dc,
PluginInfo info,
String jarFile,
ItemKey shareToEveryone)
Install or update the plug-in definition with information from the info object. |
|
boolean |
isAnnotated()
Check if this item has an annotation set. |
|
boolean |
isDisabled()
Checks if this plugin is disabled or not. |
|
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 jarFile,
String className,
boolean useRequstedPermissions)
Load a plugin and copy information to the internal data structure. |
|
Plugin |
newInstance()
Get an unitialized instance of the plugin. |
|
|
newInstance(Class<P> clazz)
Get an unitialized instance of the plugin implementation. |
|
|
newInstance(Class<P> clazz,
SessionControl sc,
PluginConfiguration configuration,
Job job)
Get an initialized instance of the plugin implementation. |
|
private Plugin |
newInstance(String jarPath,
String className,
ClassLoader alternateClassLoader,
boolean unloadBefore)
Create a new object instance of the given class. |
|
PluginConfiguration |
newPluginConfiguration()
Create a new PluginConfiguration for this plugin. |
|
(package private) void |
onAfterInsert()
This method is called on all items directly after Hibernate has inserted it into the database. |
|
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 |
setAbout(About about,
boolean force)
Update the plug-in information with the information in the about object. |
|
void |
setAllowImmediateExecution(boolean allow)
|
|
private void |
setClassName(String className)
The class name cannot be changed. |
|
private void |
setContact(String contact)
Set contact information for this plug-in. |
|
private void |
setCopyright(String copyright)
Update copyright information about this plug-in. |
|
void |
setDisabled(boolean disabled)
Disabled or enable this plugin. |
|
private void |
setEmail(String email)
Set the email address that can be used to contact the developer of the plug-in. |
|
private void |
setGuiContexts(Set<GuiContext> pluginContexts)
Set the contexts where this plugin can be used. |
|
private void |
setInteractive(boolean interactive)
|
|
private void |
setJarFile(String jarFile)
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 |
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. |
|
void |
setUrl(String url)
Set the URL to a web page with more information about the plug-in. |
|
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)
Update version information for this plug-in. |
|
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.CommonItem |
---|
getDescription, getName, setDescription, setName, toTransferable |
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, 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_JARFILE_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
private PluginInfo info
Constructor Detail |
---|
PluginDefinition(PluginDefinitionData pd)
Method Detail |
---|
public static PluginDefinition getNew(DbControl dc, String className, String jarFile, 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
interfacejarFile
- Optional file name of the JAR file which contains the
plugin class. The JAR file must be located in the plugins.dir
directory. If not specified 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 static void checkInstallation(DbControl dc, Collection<PluginInfo> plugins)
dc
- An optional DbControl (if null a new internal connection will be used)plugins
- An array with plug-in information objectspublic static PluginDefinition installOrUpdate(DbControl dc, PluginInfo info, String jarFile, ItemKey shareToEveryone)
public Item getType()
Identifiable
Item
enumeration.
getType
in interface Identifiable
public boolean isRemoved()
Removable
isRemoved
in interface Removable
isRemoved
in class CommonItem<PluginDefinitionData>
public void setRemoved(boolean removed) throws PermissionDeniedException
Removable
setRemoved
in interface Removable
setRemoved
in class CommonItem<PluginDefinitionData>
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()
void onAfterInsert() throws BaseException
BasicItem
BasicItem.onBeforeCommit(Transactional.Action)
in case the id is needed. The id
has not been generated when the onBeforeCommit
is called.
onAfterInsert
in class BasicItem<PluginDefinitionData>
BaseException
- If there is an errorTransactional
,
Developer documentation: Transactions,
Developer documentation: Coding rules and guidelines for item classespublic 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 setJarFile(String jarFile) throws InvalidDataException
InvalidDataException
public String getJarFile()
public String getVersionString()
private void setVersionString(String version) throws InvalidDataException
InvalidDataException
- If the version is too longpublic String getCopyright()
private void setCopyright(String copyright) throws InvalidDataException
InvalidDataException
- If the copyright is too longpublic String getContact()
private void setContact(String contact) throws InvalidDataException
InvalidDataException
- If the contact is too longpublic String getEmail()
private void setEmail(String email) throws InvalidDataException
InvalidDataException
- If the email is too longpublic String getUrl()
public void setUrl(String url) throws InvalidDataException
InvalidDataException
- If the url is too longpublic void setAbout(About about, boolean force)
about
- An About objectforce
- If TRUE all values are updated, if FALSE only non-null
valuespublic boolean isDisabled()
public void setDisabled(boolean disabled)
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.public <P extends Plugin> P newInstance(Class<P> clazz) 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
PermissionDeniedException
BaseException
public <P extends Plugin> P newInstance(Class<P> clazz, 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
sc
- 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, ClassLoader alternateClassLoader, boolean unloadBefore) throws BaseException
jarPath
- The full 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 jarFile, String className, boolean useRequstedPermissions) throws PermissionDeniedException, InvalidDataException, BaseException
jarFile
- File name of the jar file containing the plug-in. The
JAR file must be located in the directory spercified by 'plugins.dir' setting
in base.config. Null is allowed if plugin is located in the classpath (eg. WEB-INF/lib).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.
|
3.0.4: 2012-03-05 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |