Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.gjt.sp.jedit
Class PluginJAR  view PluginJAR download PluginJAR.java

java.lang.Object
  extended byorg.gjt.sp.jedit.PluginJAR
Direct Known Subclasses:
EditPlugin.JAR

public class PluginJAR
extends java.lang.Object

Loads and unloads plugins.

JAR file contents

When loading a plugin, jEdit looks for the following resources: For a plugin to actually do something once it is resident in memory, it must contain a class whose name ends with Plugin. This class, known as the plugin core class must extend EditPlugin and define a few required properties, otherwise it is ignored.

Dynamic and deferred loading

Unlike in prior jEdit versions, jEdit 4.2 and later allow plugins to be added and removed to the resident set at any time using the jEdit.addPluginJAR(String) 55 and jEdit.removePluginJAR(PluginJAR,boolean) 55 methods. Furthermore, the plugin core class might not be loaded until the plugin is first used. See EditPlugin.start() 55 for a full description.

Since:
jEdit 4.2pre1
Version:
$Id: PluginJAR.java,v 1.40 2003/11/16 00:04:08 spestov Exp $

Nested Class Summary
static class PluginJAR.PluginCacheEntry
          Used by the DockableWindowManager and ServiceManager to handle caching.
 
Field Summary
private  ActionSet actions
           
private  boolean activated
           
private  ActionSet browserActions
           
private  java.lang.String cachePath
           
private  java.lang.String[] classes
           
private  JARClassLoader classLoader
           
private  java.net.URL dockablesURI
           
private  java.io.File file
           
private  java.lang.String path
           
private  EditPlugin plugin
           
private  java.net.URL servicesURI
           
private  java.util.List theseRequireMe
           
private  java.util.List weRequireThese
           
private  java.util.zip.ZipFile zipFile
           
 
Constructor Summary
(package private) PluginJAR(java.io.File file)
           
 
Method Summary
 void activatePlugin()
          Loads the plugin core class.
 void activatePluginIfNecessary()
          Should be called after a new plugin is installed.
private  void breakPlugin()
           
 boolean checkDependencies()
          Returns true if all dependencies are satisified, false otherwise.
 void deactivatePlugin(boolean exit)
          Unloads the plugin core class.
private  PluginJAR.PluginCacheEntry generateCache()
           
 ActionSet getActions()
          Deprecated. Call getActionSet() instead
 ActionSet getActionSet()
          Returns the plugin's action set for the jEdit action context jEdit.getActionContext() 55 .
 ActionSet getBrowserActionSet()
          Returns the plugin's action set for the file system browser action context VFSBrowser.getActionContext()>VFSBrowser.getActionContext() 55 .
 java.lang.String getCachePath()
          Returns the full path name of this plugin's summary file.
(package private)  java.lang.String[] getClasses()
           
 JARClassLoader getClassLoader()
          Returns the plugin's class loader.
 java.lang.String[] getDependentPlugins()
          Returns an array of all plugins that depend on this one.
 java.net.URL getDockablesURI()
          Returns the location of the plugin's dockables.xml file.
 java.io.File getFile()
          Returns a file pointing to the plugin JAR.
 java.lang.String getPath()
          Returns the full path name of this plugin's JAR file.
 EditPlugin getPlugin()
          Returns the plugin core class for this JAR file.
(package private) static PluginJAR.PluginCacheEntry getPluginCache(PluginJAR plugin)
           
 java.net.URL getServicesURI()
          Returns the location of the plugin's services.xml file.
 java.util.zip.ZipFile getZipFile()
          Returns the plugin's JAR file, opening it if necessary.
(package private)  void init()
           
private  void loadCache(PluginJAR.PluginCacheEntry cache)
           
(package private) static void setPluginCache(PluginJAR plugin, PluginJAR.PluginCacheEntry cache)
           
private  void startPlugin()
           
private  void startPluginLater()
           
 java.lang.String toString()
          Convert this Object to a human-readable String.
(package private)  void uninit(boolean exit)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

path

private java.lang.String path

cachePath

private java.lang.String cachePath

file

private java.io.File file

classLoader

private JARClassLoader classLoader

zipFile

private java.util.zip.ZipFile zipFile

classes

private java.lang.String[] classes

actions

private ActionSet actions

browserActions

private ActionSet browserActions

plugin

private EditPlugin plugin

dockablesURI

private java.net.URL dockablesURI

servicesURI

private java.net.URL servicesURI

activated

private boolean activated

theseRequireMe

private java.util.List theseRequireMe

weRequireThese

private java.util.List weRequireThese
Constructor Detail

PluginJAR

PluginJAR(java.io.File file)
Method Detail

getPath

public java.lang.String getPath()
Returns the full path name of this plugin's JAR file.


getCachePath

public java.lang.String getCachePath()
Returns the full path name of this plugin's summary file. The summary file is used to store certain information which allows loading of the plugin's resources and core class to be deferred until the plugin is first used. As long as a plugin is using the jEdit 4.2 plugin API, no extra effort is required to take advantage of the summary cache.


getFile

public java.io.File getFile()
Returns a file pointing to the plugin JAR.


getClassLoader

public JARClassLoader getClassLoader()
Returns the plugin's class loader.


getZipFile

public java.util.zip.ZipFile getZipFile()
                                 throws java.io.IOException
Returns the plugin's JAR file, opening it if necessary.

Since:
jEdit 4.2pre1

getActions

public ActionSet getActions()
Deprecated. Call getActionSet() instead


getActionSet

public ActionSet getActionSet()
Returns the plugin's action set for the jEdit action context jEdit.getActionContext() 55 . These actions are loaded from the actions.xml file; see ActionSet. .

Since:
jEdit 4.2pre1

getBrowserActionSet

public ActionSet getBrowserActionSet()
Returns the plugin's action set for the file system browser action context VFSBrowser.getActionContext()>VFSBrowser.getActionContext() 55 . These actions are loaded from the browser.actions.xml file; see ActionSet. .

Since:
jEdit 4.2pre1

checkDependencies

public boolean checkDependencies()
Returns true if all dependencies are satisified, false otherwise. Also if dependencies are not satisfied, the plugin is marked as "broken".


getDependentPlugins

public java.lang.String[] getDependentPlugins()
Returns an array of all plugins that depend on this one.

Since:
jEdit 4.2pre2

getPlugin

public EditPlugin getPlugin()
Returns the plugin core class for this JAR file. Note that if the plugin has not been activated, this will return an instance of EditPlugin.Deferred. If you need the actual plugin core class instance, call activatePlugin() 55 first.

Since:
jEdit 4.2pre1

activatePlugin

public void activatePlugin()
Loads the plugin core class. Does nothing if the plugin core class has already been loaded. This method might be called on startup, depending on what properties are set. See EditPlugin.start() 55 . This method is thread-safe.

Since:
jEdit 4.2pre1

activatePluginIfNecessary

public void activatePluginIfNecessary()
Should be called after a new plugin is installed.

Since:
jEdit 4.2pre2

deactivatePlugin

public void deactivatePlugin(boolean exit)
Unloads the plugin core class. Does nothing if the plugin core class has not been loaded. This method can only be called from the AWT event dispatch thread!

Since:
jEdit 4.2pre3

getDockablesURI

public java.net.URL getDockablesURI()
Returns the location of the plugin's dockables.xml file.

Since:
jEdit 4.2pre1

getServicesURI

public java.net.URL getServicesURI()
Returns the location of the plugin's services.xml file.

Since:
jEdit 4.2pre1

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


getPluginCache

static PluginJAR.PluginCacheEntry getPluginCache(PluginJAR plugin)

setPluginCache

static void setPluginCache(PluginJAR plugin,
                           PluginJAR.PluginCacheEntry cache)

init

void init()

uninit

void uninit(boolean exit)

getClasses

java.lang.String[] getClasses()

loadCache

private void loadCache(PluginJAR.PluginCacheEntry cache)

generateCache

private PluginJAR.PluginCacheEntry generateCache()
                                          throws java.io.IOException

startPlugin

private void startPlugin()

startPluginLater

private void startPluginLater()

breakPlugin

private void breakPlugin()