コード例 #1
0
 public void removeEventListener(final PluginEventListener l) {
   initialiser.runPEVTask(
       new AERunnable() {
         public void runSupport() {
           event_listeners.remove(l);
         }
       });
 }
コード例 #2
0
 public void firePluginEvent(final PluginEvent event) {
   initialiser.runPEVTask(
       new AERunnable() {
         public void runSupport() {
           firePluginEventSupport(event);
         }
       });
 }
コード例 #3
0
  public void addListener(PluginListener l) {
    listeners.add(l);

    if (initialiser.isInitialisationComplete()) {

      fireInitComplete(l);
    }
  }
コード例 #4
0
  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));
    }
  }
コード例 #5
0
  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);
          }
        });
  }
コード例 #6
0
 public DistributedDatabase getDistributedDatabase() {
   return (DDBaseImpl.getSingleton(initialiser.getAzureusCore()));
 }
コード例 #7
0
 public ConnectionManager getConnectionManager() {
   return ConnectionManagerImpl.getSingleton(initialiser.getAzureusCore());
 }
コード例 #8
0
 public MessageManager getMessageManager() {
   return MessageManagerImpl.getSingleton(initialiser.getAzureusCore());
 }
コード例 #9
0
 public UpdateManager getUpdateManager() {
   return (UpdateManagerImpl.getSingleton(initialiser.getAzureusCore()));
 }
コード例 #10
0
 public boolean isInitialisationThread() {
   return (initialiser.isInitialisationThread());
 }
コード例 #11
0
 public Utilities getUtilities() {
   return (new UtilitiesImpl(initialiser.getAzureusCore(), this));
 }
コード例 #12
0
 public MainlineDHTManager getMainlineDHTManager() {
   return new MainlineDHTManagerImpl(initialiser.getAzureusCore());
 }
コード例 #13
0
 public DownloadManager getDownloadManager() {
   return (DownloadManagerImpl.getSingleton(initialiser.getAzureusCore()));
 }
コード例 #14
0
 public PluginManager getPluginManager() {
   return (initialiser.getPluginManager());
 }
コード例 #15
0
  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);
  }