org.gudy.azureus2.pluginsimpl.local
Class PluginInterfaceImpl

java.lang.Object
  extended by org.gudy.azureus2.pluginsimpl.local.PluginInterfaceImpl
All Implemented Interfaces:
AzureusCoreComponent, PluginInterface

public final class PluginInterfaceImpl
extends java.lang.Object
implements PluginInterface, AzureusCoreComponent

Author:
Olivier

Nested Class Summary
protected  class PluginInterfaceImpl.propertyWrapper
           
 
Field Summary
protected  java.util.List children
           
protected  java.lang.ClassLoader class_loader
           
 
Constructor Summary
protected PluginInterfaceImpl(Plugin _plugin, PluginInitializer _initialiser, java.lang.Object _initialiser_key, java.lang.ClassLoader _class_loader, java.util.List<java.io.File> _verified_files, java.lang.String _key, java.util.Properties _props, java.lang.String _pluginDir, java.lang.String _plugin_id, java.lang.String _plugin_version)
           
 
Method Summary
 void addConfigSection(ConfigSection section)
          adds a ConfigSection to the config view.
 void addConfigUIParameters(Parameter[] parameters, java.lang.String displayName)
          adds a tab under the 'plugins' tab in the config view.
Use PluginInterface.getPluginConfigUIFactory() to get the PluginConfigUIFactory class, from which you can create different types of parameters.
 void addEventListener(PluginEventListener l)
           
 void addListener(PluginListener l)
           
protected  void closedownComplete()
           
protected  void closedownInitiated()
           
protected  void destroy()
           
protected  void fireInitComplete(PluginListener listener)
           
 void firePluginEvent(PluginEvent event)
          Fire a plugin-specific event.
protected  void firePluginEventSupport(PluginEvent event)
           
protected  void generateEvidence(IndentWriter writer)
           
 java.lang.String getApplicationName()
          Returns the name of the application that the user sees - if you need to display the name of the program, you should use this method.
 java.lang.String getAzureusName()
          Retrieve the name of the application.
 java.lang.String getAzureusVersion()
          Retrieve the Application's version as a string.
 ClientIDManager getClientIDManager()
           
 ConfigSection[] getConfigSections()
           
 ConnectionManager getConnectionManager()
          Get the connection manager.
 DistributedDatabase getDistributedDatabase()
          Get the distributed database
 DownloadManager getDownloadManager()
          Gives access to the download manager
 java.lang.Object getInitializerKey()
           
 IPCInterfaceImpl getIPC()
          get the inter-plugin-communcations interface for this plugin
 IPFilter getIPFilter()
          Gives access to the IP filter
 PluginInterface getLocalPluginInterface(java.lang.Class plugin_class, java.lang.String id)
          Returns an initialised plugin instance with its own scope (e.g.
 Logger getLogger()
          Gives access to the logger
 MainlineDHTManager getMainlineDHTManager()
          Returns the manager object for registering plugins that connect to the Mainline DHT.
 MessageManager getMessageManager()
          Get the peer messaging manager.
 java.lang.String getPerUserPluginDirectoryName()
          gives access to the per-user plugin directory.
 PlatformManager getPlatformManager()
          Gets the platform manager that gives access to native functionality
 Plugin getPlugin()
          Gives access to the plugin itself
 java.lang.ClassLoader getPluginClassLoader()
          gives access to the ClassLoader used to load the plugin
 PluginConfig getPluginconfig()
          gives access to the plugin config interface
 java.lang.String getPluginConfigKey()
           
 PluginConfigUIFactory getPluginConfigUIFactory()
          gives access to the plugin Config UI Factory
 java.lang.String getPluginDirectoryName()
          Gives access to the plugin installation path - note, if you want to use this path to store data files in, it would be better for you to use PluginConfig.getPluginUserFile(String) instead.
 java.lang.String getPluginID()
          Returns an identifier used to identify this particular plugin
 PluginManager getPluginManager()
          gives access to the plugin manager
 java.lang.String getPluginName()
          Returns the value of "plugin.name" if it exists in the properties file, otherwise the directory name is returned.
 java.util.Properties getPluginProperties()
          gives access to the plugin properties
 PluginState getPluginState()
          Returns an object that provides information the current state of the plugin, and provides various mechanisms to query and control plugins and their integration with Azureus at a low-level.
 java.lang.String getPluginVersion()
          Returns the version number of the plugin it if can be deduced from either the name of the jar file it is loaded from or the properties file.
 ShareManager getShareManager()
          Gives access to the sharing functionality
 ShortCuts getShortCuts()
          access to a set of convenience routines for doing things in a quicker, although less structured, fashion
 TorrentManager getTorrentManager()
          Gives access to the torrent manager
 Tracker getTracker()
          Gives access to the tracker functionality
 UIManager getUIManager()
          access to UI extension features
 UpdateManager getUpdateManager()
          access to the update manager used to update plugins.
 Utilities getUtilities()
          access to various utility functions
protected  void initialisationComplete()
           
 boolean isBuiltIn()
          Built-in plugins are those used internally by Azureus, for example the UPnP plugin
 boolean isDisabled()
          Returns true if the plugin has been marked as disabled, and prevented from initialising.
 boolean isInitialisationThread()
          Indicates whether or not the current thread is the one responsible for running plugin initialisation
 boolean isMandatory()
          Whether or not this is a mandatory plugin.
 boolean isOperational()
          Returns true if the plugin is running, returns false if the plugin isn't running for some reason.
 boolean isShared()
           
 boolean isUnloadable()
           
 void openTorrentFile(java.lang.String fileName)
          Deprecated.  
 void openTorrentURL(java.lang.String url)
          Deprecated.  
 void reload()
           
 void removeConfigSection(ConfigSection section)
           
 void removeEventListener(PluginEventListener l)
           
 void removeListener(PluginListener l)
           
 void setDisabled(boolean disabled)
          Sets whether the plugin can be loaded or not.
 void setPluginDirectoryName(java.lang.String name)
           
 void setPluginName(java.lang.String name)
           
 void setPluginVersion(java.lang.String version)
           
 void uninstall()
          Uninstall this plugin if it has been loaded from a plugin directory.
 void unload()
           
protected  void unloadSupport()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

class_loader

protected java.lang.ClassLoader class_loader

children

protected java.util.List children
Constructor Detail

PluginInterfaceImpl

protected PluginInterfaceImpl(Plugin _plugin,
                              PluginInitializer _initialiser,
                              java.lang.Object _initialiser_key,
                              java.lang.ClassLoader _class_loader,
                              java.util.List<java.io.File> _verified_files,
                              java.lang.String _key,
                              java.util.Properties _props,
                              java.lang.String _pluginDir,
                              java.lang.String _plugin_id,
                              java.lang.String _plugin_version)
                       throws PluginException
Throws:
PluginException
Method Detail

getPlugin

public Plugin getPlugin()
Description copied from interface: PluginInterface
Gives access to the plugin itself

Specified by:
getPlugin in interface PluginInterface
Returns:

isOperational

public boolean isOperational()
Description copied from interface: PluginInterface
Returns true if the plugin is running, returns false if the plugin isn't running for some reason.

Specified by:
isOperational in interface PluginInterface

getInitializerKey

public java.lang.Object getInitializerKey()

getPluginManager

public PluginManager getPluginManager()
Description copied from interface: PluginInterface
gives access to the plugin manager

Specified by:
getPluginManager in interface PluginInterface
Returns:

getApplicationName

public java.lang.String getApplicationName()
Description copied from interface: PluginInterface
Returns the name of the application that the user sees - if you need to display the name of the program, you should use this method.

Specified by:
getApplicationName in interface PluginInterface
Returns:
3.0.5.3

getAzureusName

public java.lang.String getAzureusName()
Description copied from interface: PluginInterface
Retrieve the name of the application.

Specified by:
getAzureusName in interface PluginInterface
Returns:
the Application's name

getAzureusVersion

public java.lang.String getAzureusVersion()
Description copied from interface: PluginInterface
Retrieve the Application's version as a string.

Specified by:
getAzureusVersion in interface PluginInterface
Returns:
Application's version. Typically in the following formats (regexp):
[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+
[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+_CVS
[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+_B[0-9]+

addConfigSection

public void addConfigSection(ConfigSection section)
Description copied from interface: PluginInterface
adds a ConfigSection to the config view.

In contrast to addConfigUIParameters, this gives you total control over a tab. Please be kind and use localizable text.

Specified by:
addConfigSection in interface PluginInterface
Parameters:
section - ConfigSection to be added to the Config view

removeConfigSection

public void removeConfigSection(ConfigSection section)
Specified by:
removeConfigSection in interface PluginInterface

getConfigSections

public ConfigSection[] getConfigSections()
Specified by:
getConfigSections in interface PluginInterface
Returns:
List of ConfigSections for this plugin

openTorrentFile

public void openTorrentFile(java.lang.String fileName)
Deprecated. 

Description copied from interface: PluginInterface
opens a torrent file given its name

Specified by:
openTorrentFile in interface PluginInterface
Parameters:
fileName - The Name of the file that azureus must open

openTorrentURL

public void openTorrentURL(java.lang.String url)
Deprecated. 

Description copied from interface: PluginInterface
opens a torrent file given the url it's at

Specified by:
openTorrentURL in interface PluginInterface
Parameters:
url - The String representation of the url pointing to a torrent file

setPluginName

public void setPluginName(java.lang.String name)

getPluginName

public java.lang.String getPluginName()
Description copied from interface: PluginInterface
Returns the value of "plugin.name" if it exists in the properties file, otherwise the directory name is returned.

Specified by:
getPluginName in interface PluginInterface

setPluginVersion

public void setPluginVersion(java.lang.String version)

getPluginVersion

public java.lang.String getPluginVersion()
Description copied from interface: PluginInterface
Returns the version number of the plugin it if can be deduced from either the name of the jar file it is loaded from or the properties file. null otherwise

Specified by:
getPluginVersion in interface PluginInterface
Returns:
Version number as a string, or null

getPluginID

public java.lang.String getPluginID()
Description copied from interface: PluginInterface
Returns an identifier used to identify this particular plugin

Specified by:
getPluginID in interface PluginInterface
Returns:

isMandatory

public boolean isMandatory()
Description copied from interface: PluginInterface
Whether or not this is a mandatory plugin. Mandatory plugins take priority over update checks, for example, over optional ones.

Specified by:
isMandatory in interface PluginInterface

isBuiltIn

public boolean isBuiltIn()
Description copied from interface: PluginInterface
Built-in plugins are those used internally by Azureus, for example the UPnP plugin

Specified by:
isBuiltIn in interface PluginInterface

getPluginProperties

public java.util.Properties getPluginProperties()
Description copied from interface: PluginInterface
gives access to the plugin properties

Specified by:
getPluginProperties in interface PluginInterface
Returns:
the properties from the file plugin.properties

getPluginDirectoryName

public java.lang.String getPluginDirectoryName()
Description copied from interface: PluginInterface
Gives access to the plugin installation path - note, if you want to use this path to store data files in, it would be better for you to use PluginConfig.getPluginUserFile(String) instead.

Specified by:
getPluginDirectoryName in interface PluginInterface
Returns:
the full path the plugin is installed in

getPerUserPluginDirectoryName

public java.lang.String getPerUserPluginDirectoryName()
Description copied from interface: PluginInterface
gives access to the per-user plugin directory. Useful for shared plugins that need to store per-user state. Will be same as getPluginDirectoryName for per-user installed plugins directory may not yet exist

Specified by:
getPerUserPluginDirectoryName in interface PluginInterface
Returns:

setPluginDirectoryName

public void setPluginDirectoryName(java.lang.String name)

addConfigUIParameters

public void addConfigUIParameters(Parameter[] parameters,
                                  java.lang.String displayName)
Description copied from interface: PluginInterface
adds a tab under the 'plugins' tab in the config view.
Use PluginInterface.getPluginConfigUIFactory() to get the PluginConfigUIFactory class, from which you can create different types of parameters.

Specified by:
addConfigUIParameters in interface PluginInterface
Parameters:
parameters - the Parameter(s) to be edited
displayName - the under which it should display.
Azureus will look-up for ConfigView.section.plugins.displayName; into the lang files in order to find the localized displayName. (see i18n)

getPluginconfig

public PluginConfig getPluginconfig()
Description copied from interface: PluginInterface
gives access to the plugin config interface

Specified by:
getPluginconfig in interface PluginInterface
Returns:
the PluginConfig object associated with this plugin

getPluginConfigUIFactory

public PluginConfigUIFactory getPluginConfigUIFactory()
Description copied from interface: PluginInterface
gives access to the plugin Config UI Factory

Specified by:
getPluginConfigUIFactory in interface PluginInterface
Returns:
the PluginConfigUIFactory associated with this plugin

getPluginConfigKey

public java.lang.String getPluginConfigKey()

getTracker

public Tracker getTracker()
Description copied from interface: PluginInterface
Gives access to the tracker functionality

Specified by:
getTracker in interface PluginInterface
Returns:
The tracker

getShareManager

public ShareManager getShareManager()
                             throws ShareException
Description copied from interface: PluginInterface
Gives access to the sharing functionality

Specified by:
getShareManager in interface PluginInterface
Returns:
Throws:
ShareException

getDownloadManager

public DownloadManager getDownloadManager()
Description copied from interface: PluginInterface
Gives access to the download manager

Specified by:
getDownloadManager in interface PluginInterface
Returns:
An object that allows management of downloads

getMainlineDHTManager

public MainlineDHTManager getMainlineDHTManager()
Description copied from interface: PluginInterface
Returns the manager object for registering plugins that connect to the Mainline DHT.

Specified by:
getMainlineDHTManager in interface PluginInterface

getTorrentManager

public TorrentManager getTorrentManager()
Description copied from interface: PluginInterface
Gives access to the torrent manager

Specified by:
getTorrentManager in interface PluginInterface
Returns:
An object to manage torrents

getLogger

public Logger getLogger()
Description copied from interface: PluginInterface
Gives access to the logger

Specified by:
getLogger in interface PluginInterface
Returns:
The logger

getIPFilter

public IPFilter getIPFilter()
Description copied from interface: PluginInterface
Gives access to the IP filter

Specified by:
getIPFilter in interface PluginInterface
Returns:
An object that allows access to IP Filtering

getUtilities

public Utilities getUtilities()
Description copied from interface: PluginInterface
access to various utility functions

Specified by:
getUtilities in interface PluginInterface
Returns:

getShortCuts

public ShortCuts getShortCuts()
Description copied from interface: PluginInterface
access to a set of convenience routines for doing things in a quicker, although less structured, fashion

Specified by:
getShortCuts in interface PluginInterface
Returns:

getUIManager

public UIManager getUIManager()
Description copied from interface: PluginInterface
access to UI extension features

Specified by:
getUIManager in interface PluginInterface
Returns:

getUpdateManager

public UpdateManager getUpdateManager()
Description copied from interface: PluginInterface
access to the update manager used to update plugins. required for non-Azureus SF hosted plugins (SF ones are managed automatically)

Specified by:
getUpdateManager in interface PluginInterface
Returns:

unloadSupport

protected void unloadSupport()

isUnloadable

public boolean isUnloadable()
Specified by:
isUnloadable in interface PluginInterface

reload

public void reload()
            throws PluginException
Specified by:
reload in interface PluginInterface
Throws:
PluginException

unload

public void unload()
            throws PluginException
Specified by:
unload in interface PluginInterface
Throws:
PluginException

uninstall

public void uninstall()
               throws PluginException
Description copied from interface: PluginInterface
Uninstall this plugin if it has been loaded from a plugin directory. Deletes the plugin directory

Specified by:
uninstall in interface PluginInterface
Throws:
PluginException

isInitialisationThread

public boolean isInitialisationThread()
Description copied from interface: PluginInterface
Indicates whether or not the current thread is the one responsible for running plugin initialisation

Specified by:
isInitialisationThread in interface PluginInterface
Returns:

getClientIDManager

public ClientIDManager getClientIDManager()
Specified by:
getClientIDManager in interface PluginInterface
Returns:

getConnectionManager

public ConnectionManager getConnectionManager()
Description copied from interface: PluginInterface
Get the connection manager.

Specified by:
getConnectionManager in interface PluginInterface
Returns:
manager

getMessageManager

public MessageManager getMessageManager()
Description copied from interface: PluginInterface
Get the peer messaging manager.

Specified by:
getMessageManager in interface PluginInterface
Returns:
manager

getDistributedDatabase

public DistributedDatabase getDistributedDatabase()
Description copied from interface: PluginInterface
Get the distributed database

Specified by:
getDistributedDatabase in interface PluginInterface
Returns:

getPlatformManager

public PlatformManager getPlatformManager()
Description copied from interface: PluginInterface
Gets the platform manager that gives access to native functionality

Specified by:
getPlatformManager in interface PluginInterface
Returns:

initialisationComplete

protected void initialisationComplete()

fireInitComplete

protected void fireInitComplete(PluginListener listener)

closedownInitiated

protected void closedownInitiated()

closedownComplete

protected void closedownComplete()

getPluginClassLoader

public java.lang.ClassLoader getPluginClassLoader()
Description copied from interface: PluginInterface
gives access to the ClassLoader used to load the plugin

Specified by:
getPluginClassLoader in interface PluginInterface
Returns:

getLocalPluginInterface

public PluginInterface getLocalPluginInterface(java.lang.Class plugin_class,
                                               java.lang.String id)
                                        throws PluginException
Description copied from interface: PluginInterface
Returns an initialised plugin instance with its own scope (e.g. for config params). Designed for loading secondary plugins directly from a primary one. Note - ensure that the bundled secondary plugins do *not* contain a plugin.properties as this will cause no end of problems.

Specified by:
getLocalPluginInterface in interface PluginInterface
Parameters:
plugin_class - must implement Plugin
id - the unique id of this plugin (used to scope config params etc)
Returns:
Throws:
PluginException

getIPC

public IPCInterfaceImpl getIPC()
Description copied from interface: PluginInterface
get the inter-plugin-communcations interface for this plugin

Specified by:
getIPC in interface PluginInterface
Returns:

isShared

public boolean isShared()
Specified by:
isShared in interface PluginInterface

destroy

protected void destroy()

addListener

public void addListener(PluginListener l)
Specified by:
addListener in interface PluginInterface

removeListener

public void removeListener(PluginListener l)
Specified by:
removeListener in interface PluginInterface

addEventListener

public void addEventListener(PluginEventListener l)
Specified by:
addEventListener in interface PluginInterface

removeEventListener

public void removeEventListener(PluginEventListener l)
Specified by:
removeEventListener in interface PluginInterface

firePluginEvent

public void firePluginEvent(PluginEvent event)
Description copied from interface: PluginInterface
Fire a plugin-specific event. See PluginEvent for details of type values to use

Specified by:
firePluginEvent in interface PluginInterface

firePluginEventSupport

protected void firePluginEventSupport(PluginEvent event)

generateEvidence

protected void generateEvidence(IndentWriter writer)

isDisabled

public boolean isDisabled()
Description copied from interface: PluginInterface
Returns true if the plugin has been marked as disabled, and prevented from initialising.

Specified by:
isDisabled in interface PluginInterface

setDisabled

public void setDisabled(boolean disabled)
Description copied from interface: PluginInterface
Sets whether the plugin can be loaded or not. If you are trying to affect if the plugin can be loaded at startup - use #setLoadedAtStartup(boolean) instead. This needs to be called prior to a plugin's initialisation to take effect.

Specified by:
setDisabled in interface PluginInterface

getPluginState

public PluginState getPluginState()
Description copied from interface: PluginInterface
Returns an object that provides information the current state of the plugin, and provides various mechanisms to query and control plugins and their integration with Azureus at a low-level.

Specified by:
getPluginState in interface PluginInterface