Examples of IRed5Plugin


Examples of org.red5.server.api.plugin.IRed5Plugin

          //ensure plug-in class can be resolved
          ClassLoader classLoader = scope.getClassLoader();
          Class<?> clazz = Class.forName(desc.getPluginType(), true, classLoader);
          log.trace("Class: {}", clazz);
          //get the plug-in from the registry
          IRed5Plugin plugin = PluginRegistry.getPlugin(desc.getPluginName());
          log.debug("Got plugin from the registry: {}", plugin);
          //if the plugin class extends the red5 plug-in we will add the application to it
          if (plugin instanceof Red5Plugin) {
            //pass the app to the plugin so that it may be manipulated directly by the plug-in
            ((Red5Plugin) plugin).setApplication(this);
          }
          //when a plug-in method is specified do invokes
          if (desc.getMethod() != null) {
            Method method = plugin.getClass().getMethod(desc.getMethod(), (Class[]) null);
            //if a return type is not specified for the plug-in method just invoke it
            if (desc.getMethodReturnType() == null) {
              log.debug("Invoking plugin");
              method.invoke(plugin, (Object[]) null);
            } else {
View Full Code Here

Examples of org.red5.server.api.plugin.IRed5Plugin

      }
    });
   
    if (plugins != null) {

      IRed5Plugin red5Plugin = null;

      log.debug("{} plugins to launch", plugins.length);
      for (File plugin : plugins) {
          JarFile jar = null;
          Manifest manifest = null;
        try {
          jar = new JarFile(plugin, false);
          manifest = jar.getManifest();
        } catch (Exception e1) {
          log.warn("Error loading plugin manifest: {}", plugin);
        } finally {
          jar.close();
        }
        if (manifest == null) {
          continue;
        }       
          Attributes attributes = manifest.getMainAttributes();
          if (attributes == null) {
            continue;
          }
          String pluginMainClass = attributes.getValue("Red5-Plugin-Main-Class");
          if (pluginMainClass == null || pluginMainClass.length() <= 0) {
            continue;
          }
          // attempt to load the class; since it's in the plugins directory this should work
          ClassLoader loader = common.getClassLoader();
          Class<?> pluginClass;
          String pluginMainMethod = null;
          try {
            pluginClass = Class.forName(pluginMainClass, true, loader);
          } catch (ClassNotFoundException e) {
            continue;
          }
          try {
          //handle plug-ins without "main" methods
          pluginMainMethod = attributes.getValue("Red5-Plugin-Main-Method");
          if (pluginMainMethod == null || pluginMainMethod.length() <= 0) {
            //just get an instance of the class
            red5Plugin = (IRed5Plugin) pluginClass.newInstance();           
          } else {
            Method method = pluginClass.getMethod(pluginMainMethod, (Class<?>[]) null);
            Object o = method.invoke(null, (Object[]) null);
            if (o != null && o instanceof IRed5Plugin) {
              red5Plugin = (IRed5Plugin) o;
            }
          }
          //register and start
          if (red5Plugin != null) {
            //set top-level context
            red5Plugin.setApplicationContext(applicationContext);
            //set server reference
            red5Plugin.setServer(server);
            //register the plug-in to make it available for lookups
            PluginRegistry.register(red5Plugin);
            //start the plugin
            red5Plugin.doStart();
          }
          log.info("Loaded plugin: {}", pluginMainClass);
        } catch (Throwable t) {
          log.warn("Error loading plugin: {}; Method: {}", pluginMainClass, pluginMainMethod);
          log.error("", t);
View Full Code Here

Examples of org.red5.server.api.plugin.IRed5Plugin

    //get a write lock
    pluginWriteLock.lock();
    try {
      if (plugins.containsKey(pluginName)) {
        //get old plugin
        IRed5Plugin oldPlugin = plugins.get(pluginName);
        //if they are not the same shutdown the older one
        if (!plugin.equals(oldPlugin)) {     
          try {
            oldPlugin.doStop();
          } catch (Exception e) {
            log.warn("Exception caused when stopping old plugin", e);
          }
          //replace old one
          plugins.replace(pluginName, plugin);
View Full Code Here

Examples of org.red5.server.api.plugin.IRed5Plugin

   *
   * @param pluginName
   * @return requested plug-in matching the name given or null if not found
   */
  public static IRed5Plugin getPlugin(String pluginName) {
    IRed5Plugin plugin = null;
    pluginReadLock.lock();
    try {
      plugin = plugins.get(pluginName);
    } finally {
      pluginReadLock.unlock();
View Full Code Here

Examples of org.red5.server.api.plugin.IRed5Plugin

    log.info("Destroying and cleaning up {} plugins", plugins.size())
    //loop through the plugins and stop them
    pluginReadLock.lock();
    try {
      for (Entry<String, IRed5Plugin> pluginEntry : plugins.entrySet()) {
        IRed5Plugin plugin = pluginEntry.getValue();
        try {
          plugin.doStop();
        } catch (Exception ex) {
          if (plugin != null) {
            log.warn("Plugin stop failed for: {}", plugin.getName(), ex);
          } else {
            log.warn("Plugin stop failed", ex);
          }
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.