public void removeEventListener(final PluginEventListener l) {
   initialiser.runPEVTask(
       new AERunnable() {
         public void runSupport() {
           event_listeners.remove(l);
         }
       });
 }
 public void firePluginEvent(final PluginEvent event) {
   initialiser.runPEVTask(
       new AERunnable() {
         public void runSupport() {
           firePluginEventSupport(event);
         }
       });
 }
  public void addListener(PluginListener l) {
    listeners.add(l);

    if (initialiser.isInitialisationComplete()) {

      fireInitComplete(l);
    }
  }
  public PluginInterface getLocalPluginInterface(Class plugin_class, String id)
      throws PluginException {
    try {
      Plugin p = (Plugin) plugin_class.newInstance();

      // Discard plugin.id from the properties, we want the
      // plugin ID we create to take priority - not a value
      // from the original plugin ID properties file.
      Properties local_props = new Properties(props);
      local_props.remove("plugin.id");

      if (id.endsWith("_v")) {

        throw (new Exception("Verified plugins must be loaded from a jar"));
      }

      PluginInterfaceImpl pi =
          new PluginInterfaceImpl(
              p,
              initialiser,
              initialiser_key,
              class_loader,
              null,
              key + "." + id,
              local_props,
              pluginDir,
              getPluginID() + "." + id,
              plugin_version);

      initialiser.fireCreated(pi);

      p.initialize(pi);

      children.add(pi);

      return (pi);

    } catch (Throwable e) {

      if (e instanceof PluginException) {

        throw ((PluginException) e);
      }

      throw (new PluginException("Local initialisation fails", e));
    }
  }
  public void addEventListener(final PluginEventListener l) {
    initialiser.runPEVTask(
        new AERunnable() {
          public void runSupport() {
            List<PluginEvent> events = initialiser.getPEVHistory();

            for (PluginEvent event : events) {

              try {
                l.handleEvent(event);

              } catch (Throwable e) {

                Debug.out(e);
              }
            }
            event_listeners.add(l);
          }
        });
  }
 public DistributedDatabase getDistributedDatabase() {
   return (DDBaseImpl.getSingleton(initialiser.getAzureusCore()));
 }
 public ConnectionManager getConnectionManager() {
   return ConnectionManagerImpl.getSingleton(initialiser.getAzureusCore());
 }
 public MessageManager getMessageManager() {
   return MessageManagerImpl.getSingleton(initialiser.getAzureusCore());
 }
 public UpdateManager getUpdateManager() {
   return (UpdateManagerImpl.getSingleton(initialiser.getAzureusCore()));
 }
 public boolean isInitialisationThread() {
   return (initialiser.isInitialisationThread());
 }
 public Utilities getUtilities() {
   return (new UtilitiesImpl(initialiser.getAzureusCore(), this));
 }
 public MainlineDHTManager getMainlineDHTManager() {
   return new MainlineDHTManagerImpl(initialiser.getAzureusCore());
 }
 public DownloadManager getDownloadManager() {
   return (DownloadManagerImpl.getSingleton(initialiser.getAzureusCore()));
 }
 public PluginManager getPluginManager() {
   return (initialiser.getPluginManager());
 }
  protected PluginInterfaceImpl(
      Plugin _plugin,
      PluginInitializer _initialiser,
      Object _initialiser_key,
      ClassLoader _class_loader,
      List<File> _verified_files,
      String _key,
      Properties _props,
      String _pluginDir,
      String _plugin_id,
      String _plugin_version)
      throws PluginException {
    // check we're being created by the core

    StackTraceElement[] stack = Thread.currentThread().getStackTrace();

    int pos = 0;

    while (!stack[pos].getClassName().equals(PluginInterfaceImpl.class.getName())) {

      pos++;
    }

    String caller_class = stack[pos + 1].getClassName();

    if (!(caller_class.equals("org.gudy.azureus2.pluginsimpl.local.PluginInitializer")
        || caller_class.equals("org.gudy.azureus2.pluginsimpl.local.PluginInterfaceImpl"))) {

      throw (new PluginException("Invalid caller"));
    }

    // check we haven't been subclassed

    String class_name = getClass().getCanonicalName();

    if (class_name == null
        || !class_name.equals("org.gudy.azureus2.pluginsimpl.local.PluginInterfaceImpl")) {

      throw (new PluginException("Subclassing not permitted"));
    }

    plugin = _plugin;
    initialiser = _initialiser;
    initialiser_key = _initialiser_key;
    class_loader = _class_loader;
    key = _key;
    pluginConfigKey = "Plugin." + _key;
    props = new propertyWrapper(_props);
    pluginDir = _pluginDir;
    config = new PluginConfigImpl(this, pluginConfigKey);
    given_plugin_id = _plugin_id;
    plugin_version = _plugin_version;
    ipc_interface = new IPCInterfaceImpl(initialiser, plugin);
    state = new PluginStateImpl(this, initialiser);

    boolean verified = false;
    boolean bad = false;

    if (_plugin_id.endsWith("_v")) {

      if (plugin.getClass() == FailedPlugin.class) {

        verified = true;

      } else {
        if (_verified_files != null) {

          File jar = FileUtil.getJarFileFromClass(plugin.getClass());

          if (jar != null) {

            for (File file : _verified_files) {

              if (file.equals(jar)) {

                verified = true;
              }
            }
          }
        }
      }

      if (!verified) {

        bad = true;
      }
    }

    PluginInitializer.setVerified(this, plugin, verified, bad);
  }