Package com.biglybt.pifimpl.local
Class PluginInterfaceImpl
- java.lang.Object
-
- com.biglybt.pifimpl.local.PluginInterfaceImpl
-
- All Implemented Interfaces:
CoreComponent
,PluginInterface
public final class PluginInterfaceImpl extends java.lang.Object implements PluginInterface, CoreComponent
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
PluginInterfaceImpl.propertyWrapper
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List
children
protected java.lang.ClassLoader
class_loader
private PluginConfigImpl
config
private CopyOnWriteList<PluginEventListener>
event_listeners
private java.lang.String
given_plugin_id
This is the plugin ID value we were given when we were created.private java.util.Set<PluginListener>
init_complete_fired_set
private PluginInitializer
initialiser
private java.lang.Object
initialiser_key
private IPCInterfaceImpl
ipc_interface
private java.lang.String
key
private CopyOnWriteList<PluginListener>
listeners
private Logger
logger
private static LogIDs
LOGID
private Plugin
plugin
private java.lang.String
plugin_id_to_use
We store this value as soon as someone calls getPluginID(), meaning we will return a consistent value for the plugin's lifetime.private java.lang.String
plugin_version
private java.lang.String
pluginConfigKey
private java.lang.String
pluginDir
private java.util.Properties
props
private PluginStateImpl
state
-
Constructor Summary
Constructors Modifier Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
getApplicationVersion()
Retrieve the Application's version as a string.java.lang.String
getAzureusName()
Retrieve the name of the application.ClientIDManager
getClientIDManager()
ConnectionManager
getConnectionManager()
Get the connection manager.DistributedDatabase
getDistributedDatabase()
Get the distributed databaseDownloadManager
getDownloadManager()
Gives access to the download managerjava.lang.Object
getInitializerKey()
IPCInterfaceImpl
getIPC()
Get the inter-plugin-communications interface for this pluginIPFilter
getIPFilter()
Gives access to the IP filterPluginInterface
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 loggerMainlineDHTManager
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 functionalityPlugin
getPlugin()
Gives access to the plugin itselfjava.lang.ClassLoader
getPluginClassLoader()
gives access to the ClassLoader used to load the pluginPluginConfig
getPluginconfig()
Gives access to the plugin config interfacejava.lang.String
getPluginConfigKey()
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 usePluginConfig.getPluginUserFile(String)
instead.java.lang.String
getPluginID()
Returns an identifier used to identify this particular pluginPluginManager
getPluginManager()
gives access to the plugin managerjava.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 propertiesPluginState
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 the client at a low-level.(package private) PluginStateImpl
getPluginStateImpl()
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 functionalityShortCuts
getShortCuts()
access to a set of convenience routines for doing things in a quicker, although less structured, fashionTorrentManager
getTorrentManager()
Gives access to the torrent managerTracker
getTracker()
Gives access to the tracker functionalityUIManager
getUIManager()
access to UI extension featuresUpdateManager
getUpdateManager()
access to the update manager used to update plugins.Utilities
getUtilities()
access to various utility functionsprotected void
initialisationComplete()
boolean
isInitialisationThread()
Indicates whether or not the current thread is the one responsible for running plugin initialisationvoid
removeEventListener(PluginEventListener l)
void
removeListener(PluginListener l)
(package private) void
setAsFailed()
void
setPluginDirectoryName(java.lang.String name)
void
setPluginName(java.lang.String name)
void
setPluginVersion(java.lang.String version)
protected void
unloadSupport()
-
-
-
Field Detail
-
LOGID
private static final LogIDs LOGID
-
plugin
private Plugin plugin
-
initialiser
private PluginInitializer initialiser
-
initialiser_key
private java.lang.Object initialiser_key
-
class_loader
protected java.lang.ClassLoader class_loader
-
listeners
private CopyOnWriteList<PluginListener> listeners
-
init_complete_fired_set
private java.util.Set<PluginListener> init_complete_fired_set
-
event_listeners
private CopyOnWriteList<PluginEventListener> event_listeners
-
key
private java.lang.String key
-
pluginConfigKey
private java.lang.String pluginConfigKey
-
props
private java.util.Properties props
-
pluginDir
private java.lang.String pluginDir
-
config
private PluginConfigImpl config
-
plugin_version
private java.lang.String plugin_version
-
logger
private Logger logger
-
ipc_interface
private IPCInterfaceImpl ipc_interface
-
children
protected java.util.List children
-
state
private final PluginStateImpl state
-
given_plugin_id
private java.lang.String given_plugin_id
This is the plugin ID value we were given when we were created. We might use it, but it depends what value is the plugins properties (which will override this value).
-
plugin_id_to_use
private java.lang.String plugin_id_to_use
We store this value as soon as someone calls getPluginID(), meaning we will return a consistent value for the plugin's lifetime.
-
-
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 interfacePluginInterface
-
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 interfacePluginInterface
-
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 interfacePluginInterface
-
getAzureusName
public java.lang.String getAzureusName()
Description copied from interface:PluginInterface
Retrieve the name of the application.- Specified by:
getAzureusName
in interfacePluginInterface
- Returns:
- the Application's name
-
getApplicationVersion
public java.lang.String getApplicationVersion()
Description copied from interface:PluginInterface
Retrieve the Application's version as a string.- Specified by:
getApplicationVersion
in interfacePluginInterface
- 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]+
-
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 interfacePluginInterface
-
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 interfacePluginInterface
- 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 interfacePluginInterface
-
getPluginProperties
public java.util.Properties getPluginProperties()
Description copied from interface:PluginInterface
gives access to the plugin properties- Specified by:
getPluginProperties
in interfacePluginInterface
- 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 usePluginConfig.getPluginUserFile(String)
instead.- Specified by:
getPluginDirectoryName
in interfacePluginInterface
- 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 interfacePluginInterface
-
setPluginDirectoryName
public void setPluginDirectoryName(java.lang.String name)
-
getPluginconfig
public PluginConfig getPluginconfig()
Description copied from interface:PluginInterface
Gives access to the plugin config interface- Specified by:
getPluginconfig
in interfacePluginInterface
- Returns:
- the PluginConfig object 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 interfacePluginInterface
- Returns:
- The tracker
-
getShareManager
public ShareManager getShareManager() throws ShareException
Description copied from interface:PluginInterface
Gives access to the sharing functionality- Specified by:
getShareManager
in interfacePluginInterface
- Throws:
ShareException
-
getDownloadManager
public DownloadManager getDownloadManager()
Description copied from interface:PluginInterface
Gives access to the download manager- Specified by:
getDownloadManager
in interfacePluginInterface
- 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 interfacePluginInterface
-
getTorrentManager
public TorrentManager getTorrentManager()
Description copied from interface:PluginInterface
Gives access to the torrent manager- Specified by:
getTorrentManager
in interfacePluginInterface
- Returns:
- An object to manage torrents
-
getLogger
public Logger getLogger()
Description copied from interface:PluginInterface
Gives access to the logger- Specified by:
getLogger
in interfacePluginInterface
- Returns:
- The logger
-
getIPFilter
public IPFilter getIPFilter()
Description copied from interface:PluginInterface
Gives access to the IP filter- Specified by:
getIPFilter
in interfacePluginInterface
- 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 interfacePluginInterface
-
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 interfacePluginInterface
-
getUIManager
public UIManager getUIManager()
Description copied from interface:PluginInterface
access to UI extension features- Specified by:
getUIManager
in interfacePluginInterface
-
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 interfacePluginInterface
-
unloadSupport
protected void unloadSupport()
-
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 interfacePluginInterface
-
getClientIDManager
public ClientIDManager getClientIDManager()
- Specified by:
getClientIDManager
in interfacePluginInterface
-
getConnectionManager
public ConnectionManager getConnectionManager()
Description copied from interface:PluginInterface
Get the connection manager.- Specified by:
getConnectionManager
in interfacePluginInterface
- Returns:
- manager
-
getMessageManager
public MessageManager getMessageManager()
Description copied from interface:PluginInterface
Get the peer messaging manager.- Specified by:
getMessageManager
in interfacePluginInterface
- Returns:
- manager
-
getDistributedDatabase
public DistributedDatabase getDistributedDatabase()
Description copied from interface:PluginInterface
Get the distributed database- Specified by:
getDistributedDatabase
in interfacePluginInterface
-
getPlatformManager
public PlatformManager getPlatformManager()
Description copied from interface:PluginInterface
Gets the platform manager that gives access to native functionality- Specified by:
getPlatformManager
in interfacePluginInterface
-
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 interfacePluginInterface
-
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 interfacePluginInterface
- Parameters:
plugin_class
- must implement Pluginid
- the unique id of this plugin (used to scope config params etc)- Throws:
PluginException
-
getIPC
public IPCInterfaceImpl getIPC()
Description copied from interface:PluginInterface
Get the inter-plugin-communications interface for this plugin- Specified by:
getIPC
in interfacePluginInterface
-
setAsFailed
void setAsFailed()
-
destroy
protected void destroy()
-
addListener
public void addListener(PluginListener l)
- Specified by:
addListener
in interfacePluginInterface
-
removeListener
public void removeListener(PluginListener l)
- Specified by:
removeListener
in interfacePluginInterface
-
addEventListener
public void addEventListener(PluginEventListener l)
- Specified by:
addEventListener
in interfacePluginInterface
-
removeEventListener
public void removeEventListener(PluginEventListener l)
- Specified by:
removeEventListener
in interfacePluginInterface
-
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 interfacePluginInterface
- Parameters:
event
- plugin event
-
firePluginEventSupport
protected void firePluginEventSupport(PluginEvent event)
-
generateEvidence
protected void generateEvidence(IndentWriter writer)
-
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 the client at a low-level.- Specified by:
getPluginState
in interfacePluginInterface
-
getPluginStateImpl
PluginStateImpl getPluginStateImpl()
-
-