2.17.2: 2011-06-17

net.sf.basedb.core
Class PluginType

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<PluginTypeData>
      extended by net.sf.basedb.core.PluginType
All Implemented Interfaces:
AccessControlled, Identifiable, Nameable, Registered, Removable

public class PluginType
extends BasicItem<PluginTypeData>
implements Nameable, Removable, Registered

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2009-04-06 14:52:39 +0200 (Mon, 06 Apr 2009) $

Field Summary
static int MAX_INTERFACENAME_LENGTH
          The maximum length of the interface name 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 Item TYPE
          The type of item represented by this class.
 
Fields inherited from interface net.sf.basedb.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
 
Constructor Summary
PluginType(PluginTypeData data)
          Creates a plugin type item.
 
Method Summary
static PluginType getById(DbControl dc, int id)
          Get a PluginType object when you know the ID.
static PluginType getByInterfaceName(DbControl dc, String interfaceName)
          Get a PluginType object when you know the interface name it represents.
 String getDescription()
          Get the description for the item.
 Date getEntryDate()
          Get the date that the item was registered in the database.
 String getInterfaceName()
          Get the class name of the Java class that implements this plugin.
 String getJarPath()
          Get the path to the JAR file that contains the plugin class file.
 String getName()
          Get the name of the item.
static PluginType getNew(DbControl dc, String interfaceName, String jarPath)
          Create a new PluginType item.
 ItemQuery<PluginDefinition> getPlugins()
          Get a query that returns the plugin definitions which implements this type.
static ItemQuery<PluginType> getQuery()
          Get a query configured to retrieve plugin types.
 Item getType()
          Get the type of item represented by the object.
(package private)  void initPermissions(int granted, int denied)
          All users get READ access.
 boolean isRemoved()
          Check if the removed flag is set for this item.
 void loadInterfaceInformation(String jarPath, String interfaceName)
           
 void setDescription(String description)
          Set the description for the item.
private  void setInterfaceName(String interfaceName)
          The class name cannot be changed.
private  void setJarPath(String jarPath)
          The jar path cannot be changed.
 void setName(String name)
          Set the name of the item.
 void setRemoved(boolean removed)
          Set the removed flag for this item.
 
Methods inherited from class net.sf.basedb.core.BasicItem
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, 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
 

Field Detail

TYPE

public static final Item TYPE
The type of item represented by this class.

See Also:
Item.PLUGINTYPE, getType()

MAX_INTERFACENAME_LENGTH

public static final int MAX_INTERFACENAME_LENGTH
The maximum length of the interface name that can be stored in the database. Check the length against this value before calling the setInterfaceName(String) method to avoid exceptions.

See Also:
Constant Field Values

MAX_JARPATH_LENGTH

public static final int MAX_JARPATH_LENGTH
The maximum length of the jar path name that can be stored in the database.

See Also:
Constant Field Values
Constructor Detail

PluginType

PluginType(PluginTypeData data)
Creates a plugin type item.

Parameters:
data - the data
Method Detail

getNew

public static PluginType getNew(DbControl dc,
                                String interfaceName,
                                String jarPath)
                         throws BaseException
Create a new PluginType item.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
interfaceName - The name of an interface that a plugin must implement to be of this type
jarPath - Optional path to the jar file which contains the interface class, if missing the interface must be in the classpath
Returns:
The new PluginDefinition item
Throws:
BaseException - If there is an error

getById

public static PluginType getById(DbControl dc,
                                 int id)
                          throws ItemNotFoundException,
                                 PermissionDeniedException,
                                 BaseException
Get a PluginType object when you know the ID.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
id - The id of the item to load.
Returns:
The PluginType item
Throws:
ItemNotFoundException - If an item with the specified id is not found
PermissionDeniedException - If the logged in user doesn't have read permission to the item
BaseException - If there is another error

getByInterfaceName

public static PluginType getByInterfaceName(DbControl dc,
                                            String interfaceName)
                                     throws ItemNotFoundException,
                                            PermissionDeniedException,
                                            BaseException
Get a PluginType object when you know the interface name it represents.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
interfaceName - The interface name of the plugin type
Returns:
The PluginType item
Throws:
ItemNotFoundException - If an item with the specified interface name is not found
PermissionDeniedException - If the logged in user doesn't have read permission to the item
BaseException - If there is another error

getQuery

public static ItemQuery<PluginType> getQuery()
Get a query configured to retrieve plugin types.

Returns:
An ItemQuery object

getType

public Item getType()
Description copied from interface: Identifiable
Get the type of item represented by the object. The returned value is one of the values defined in the Item enumeration.

Specified by:
getType in interface Identifiable
Returns:
A value indicating the type of item

getName

public String getName()
Description copied from interface: Nameable
Get the name of the item.

Specified by:
getName in interface Nameable
Returns:
A String with the name of the item

setName

public void setName(String name)
             throws PermissionDeniedException,
                    InvalidDataException
Description copied from interface: Nameable
Set the name of the item. The name cannot be null and mustn't be longer than the value specified by the Nameable.MAX_NAME_LENGTH constant.

Specified by:
setName in interface Nameable
Parameters:
name - The new name for the item
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the name is null or longer than specified by the Nameable.MAX_NAME_LENGTH constant

getDescription

public String getDescription()
Description copied from interface: Nameable
Get the description for the item.

Specified by:
getDescription in interface Nameable
Returns:
A String with a description of the item

setDescription

public void setDescription(String description)
                    throws PermissionDeniedException,
                           InvalidDataException
Description copied from interface: Nameable
Set the description for the item. The description can be null but mustn't be longer than the value specified by the Nameable.MAX_DESCRIPTION_LENGTH constant.

Specified by:
setDescription in interface Nameable
Parameters:
description - The new description for the item
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the description longer than specified by the Nameable.MAX_DESCRIPTION_LENGTH constant

initPermissions

void initPermissions(int granted,
                     int denied)
               throws BaseException
All users get READ access.

Overrides:
initPermissions in class BasicItem<PluginTypeData>
Parameters:
granted - Permissions that have been granted by the subclass
denied - Permissions that have been denied by the subclass
Throws:
BaseException - If the permissions couldn't be initialised

isRemoved

public boolean isRemoved()
Description copied from interface: Removable
Check if the removed flag is set for this item.

Specified by:
isRemoved in interface Removable
Returns:
TRUE if the item is flagged as removed, FALSE otherwise

setRemoved

public void setRemoved(boolean removed)
                throws PermissionDeniedException
Description copied from interface: Removable
Set the removed flag for this item.

Specified by:
setRemoved in interface Removable
Parameters:
removed - TRUE if the item should be flagged as removed, FALSE otherwise
Throws:
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 FALSE

getEntryDate

public Date getEntryDate()
Description copied from interface: Registered
Get the date that the item was registered in the database.

Specified by:
getEntryDate in interface Registered
Returns:
A date or null if this is not known

getInterfaceName

public String getInterfaceName()
Get the class name of the Java class that implements this plugin. The specified class must implement the Plugin interface.

Returns:
The class name for this plugin

setInterfaceName

private void setInterfaceName(String interfaceName)
                       throws InvalidDataException
The class name cannot be changed. Used internally only.

Throws:
InvalidDataException

getJarPath

public String getJarPath()
Get the path to the JAR file that contains the plugin class file. If this value is null, the plugin must be on the classpath.


setJarPath

private void setJarPath(String jarPath)
                 throws InvalidDataException
The jar path cannot be changed. Used internally only.

Throws:
InvalidDataException

loadInterfaceInformation

public void loadInterfaceInformation(String jarPath,
                                     String interfaceName)
                              throws InvalidDataException,
                                     BaseException
Parameters:
jarPath - Path to the jar file where the interface is located. Null can be used only if the interface is located in the server's classpath.
interfaceName - The name of an interface that a plugin must implement to be of this type.
Throws:
InvalidDataException - If the found class not really is an interface, or if the found interface doesn't extend from Plugin
BaseException - If there is some other error.

getPlugins

public ItemQuery<PluginDefinition> getPlugins()
Get a query that returns the plugin definitions which implements this type.

See Also:
PluginDefinition.getQuery()

2.17.2: 2011-06-17