org.rhq.core.domain.plugin
Class Plugin

java.lang.Object
  extended by org.rhq.core.domain.plugin.Plugin
All Implemented Interfaces:
Serializable

public class Plugin
extends Object
implements Serializable

An agent plugin. This object contains information about the plugin jar itself (e.g. its name and MD5). It may also contain the jar contents (getContent()).

See Also:
Serialized Form

Field Summary
static String QUERY_FIND_ALL
           
static String QUERY_FIND_BY_NAME
           
static String QUERY_FIND_BY_RESOURCE_TYPE_AND_CATEGORY
           
static String TABLE_NAME
           
static String UPDATE_ALL_BUT_CONTENT
           
 
Constructor Summary
protected Plugin()
           
  Plugin(int id, String name, String path, String displayName, boolean enabled, String description, String help, String md5, String version, long ctime, long mtime)
          Constructor that can build the full object except for the content byte array.
  Plugin(String name, String path)
          Constructor for Plugin.
  Plugin(String name, String path, byte[] content)
          Constructor for Plugin.
  Plugin(String name, String path, String md5)
          Constructor for Plugin.
 
Method Summary
 boolean equals(Object obj)
           
 byte[] getContent()
          Returns the actual content of the plugin file.
 long getCtime()
          See the javadoc of getMtime() for information about this field and its relationship with "mtime".
 String getDescription()
           
 String getDisplayName()
           
 String getHelp()
           
 int getId()
           
 String getMd5()
           
 String getMD5()
           
 long getMtime()
          The "mtime" of the plugin has slightly different semantics than other "mtime" values found elsewhere.
 String getName()
           
 String getPath()
          Returns the actual name of the plugin jar.
 String getVersion()
           
 int hashCode()
           
 boolean isEnabled()
           
 void setContent(byte[] content)
           
 void setCtime(long ctime)
           
 void setDescription(String description)
           
 void setDisplayName(String displayName)
           
 void setEnabled(boolean enabled)
           
 void setHelp(String help)
           
 void setId(int id)
           
 void setMd5(String md5)
           
 void setMD5(String md5)
           
 void setMtime(long mtime)
          This entity does not automatically update the "mtime" when it is updated via a PreUpdate annotation, therefore, the owner of this entity needs to explicitly call this setter in order to set the "mtime".
 void setName(String name)
           
 void setPath(String path)
          Ensure that the path being set does not include any directory names.
 void setVersion(String version)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TABLE_NAME

public static final String TABLE_NAME
See Also:
Constant Field Values

QUERY_FIND_BY_RESOURCE_TYPE_AND_CATEGORY

public static final String QUERY_FIND_BY_RESOURCE_TYPE_AND_CATEGORY
See Also:
Constant Field Values

QUERY_FIND_ALL

public static final String QUERY_FIND_ALL
See Also:
Constant Field Values

QUERY_FIND_BY_NAME

public static final String QUERY_FIND_BY_NAME
See Also:
Constant Field Values

UPDATE_ALL_BUT_CONTENT

public static final String UPDATE_ALL_BUT_CONTENT
See Also:
Constant Field Values
Constructor Detail

Plugin

protected Plugin()

Plugin

public Plugin(@NotNull
              String name,
              String path)
Constructor for Plugin.

Parameters:
name - the logical name of the plugin
path - the actual filename of the plugin jar (see getPath())

Plugin

public Plugin(String name,
              String path,
              String md5)
Constructor for Plugin. Note that this allows you to provide an MD5 without providing the plugin's actual content. If you wish to persist this entity in the database, you should either provide the content or update the entity later by streaming the file content to the content column.

Parameters:
name - the logical name of the plugin
path - the actual filename of the plugin jar (see getPath())
md5 - the MD5 hash string of the plugin jar contents

Plugin

public Plugin(String name,
              String path,
              byte[] content)
Constructor for Plugin.

Parameters:
name - the logical name of the plugin
path - the actual filename of the plugin jar (see getPath())
content - the actual jar file contents (the MD5 hash string will be generated from this)

Plugin

public Plugin(int id,
              String name,
              String path,
              String displayName,
              boolean enabled,
              String description,
              String help,
              String md5,
              String version,
              long ctime,
              long mtime)
Constructor that can build the full object except for the content byte array. This is used mainly for the named queries that want to return a Plugin object but does not eagerly load in the content array.

Parameters:
id -
name -
path -
displayName -
enabled -
description -
help -
md5 -
version -
ctime -
mtime -
Method Detail

getId

public int getId()

setId

public void setId(int id)

getName

public String getName()

setName

public void setName(String name)

getCtime

public long getCtime()
See the javadoc of getMtime() for information about this field and its relationship with "mtime".

Returns:
the time when this entity was persisted

setCtime

public void setCtime(long ctime)

getMtime

public long getMtime()
The "mtime" of the plugin has slightly different semantics than other "mtime" values found elsewhere. The "mtime" will typically be the time that the content field was modified, not necessarily the time when any field was modified. In other words, look at "mtime" if you want to know when the actual plugin content was last updated. Note that this "mtime" may in fact be the last modified time of the plugin file from which the content came from - this means mtime may actually be earlier in time than "ctime" (in the case when the plugin jar file was last touched prior to this entity being created). Note that the "ctime" field semantics remains the same as always, it is the time when this entity was originally created.

Returns:
mtime of the content

setMtime

public void setMtime(long mtime)
This entity does not automatically update the "mtime" when it is updated via a PreUpdate annotation, therefore, the owner of this entity needs to explicitly call this setter in order to set the "mtime". You normally set this value to the last modified time of the plugin jar that provided this plugin entity's content.

Parameters:
mtime -

getDisplayName

public String getDisplayName()

setDisplayName

public void setDisplayName(String displayName)

getDescription

public String getDescription()

setDescription

public void setDescription(String description)

isEnabled

public boolean isEnabled()

setEnabled

public void setEnabled(boolean enabled)

getHelp

public String getHelp()

setHelp

public void setHelp(String help)

getVersion

public String getVersion()

setVersion

public void setVersion(String version)

getMd5

public String getMd5()

setMd5

public void setMd5(String md5)

getMD5

public String getMD5()

setMD5

public void setMD5(String md5)

getPath

public String getPath()
Returns the actual name of the plugin jar. This is not the absolute path, in fact, it does not include any directory paths. It is strictly the name of the plugin jar as found on the file system (aka the filename).

Returns:
plugin filename

setPath

public void setPath(String path)
Ensure that the path being set does not include any directory names. The plugin path is the filename. See getPath().

Parameters:
path - the filename of the plugin, not including directory names

getContent

public byte[] getContent()
Returns the actual content of the plugin file. Be careful calling this in an entity context - the entire plugin file content will be loaded in memory (which may trigger an OutOfMemoryError if the file is very large).

Returns:
the content of the plugin file

setContent

public void setContent(byte[] content)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008-2009 RHQ Project Advisory Board (Red Hat, Inc.). All Rights Reserved.