Package com.dotmarketing.plugin.model

Examples of com.dotmarketing.plugin.model.Plugin


   
    for (File f : pluginJars) {
      String id = f.getName();
      try{
        id = PluginUtil.getPluginNameFromJar(f.getName())
        Plugin plugin = null;
       
        if (plugins != null) {
          for (Plugin tempPlugin: plugins) {
            if (tempPlugin.getId().equals(id)) {
              plugin = tempPlugin;
              break;
            }
          }
        }
       
        boolean newPlugin = false;
        JarFile jar;
        Manifest mf;
        try {
          jar = new JarFile(f.getPath());
          mf=jar.getManifest();
        } catch (IOException e1) {
          Logger.fatal(this, "Method loadPlugins : Error deploying plugin id:" + id, e1);
          continue;
        }
        Attributes attrs=mf.getMainAttributes();
        if(plugin == null || !UtilMethods.isSet(plugin.getId())){
          plugin = new Plugin();
          newPlugin = true;
          plugin.setFirstDeployedDate(Calendar.getInstance().getTime());
          plugin.setId(id);
        }
        String version = attrs.getValue("Plugin-Version");
        if(!UtilMethods.isSet(version)){
          Logger.fatal(this, "Method loadPlugins : Error deploying plugin id:" + id);
          continue;
        }
        if(!newPlugin){
          if(plugin.getPluginVersion().equalsIgnoreCase(version)){
            setUpHooks(id);
            loadPluginProperties(jar, plugin.getId());
            pluginIds.add(id);
            pluginAPI.setDeployedPluginOrder(pluginIds);
            continue;
          }
        }
       
        plugin.setPluginVersion(version);
        String oldVersion = plugin.getPluginVersion();
        plugin.setLastDeployedDate(Calendar.getInstance().getTime());
        String pluginName = attrs.getValue("Plugin-Name") ==  null ? "":attrs.getValue("Plugin-Name");
        String author = attrs.getValue("Author") ==  null ? "":attrs.getValue("Author");
        plugin.setAuthor(author);
        plugin.setPluginName(pluginName);
        try{
          pluginAPI.save(plugin);
        } catch (DotDataException e2) {
          Logger.fatal(this, "Method loadPlugins : Error deploying plugin id:" + id, e2);
          continue;
        }
        loadPluginProperties(jar, plugin.getId());
        String deployClass = attrs.getValue("Deploy-Class");
        PluginDeployer deployer=null;
        if (deployClass!=null && deployClass.length()>0) {
          try {
            Object o=Class.forName(deployClass).newInstance();
            if (o instanceof PluginDeployer) {
              deployer=(PluginDeployer)o;
              if(newPlugin)
                deployer.deploy();
              else
                deployer.redeploy(oldVersion);
            }
          } catch (InstantiationException e) {
            Logger.debug(PluginLoader.class,"InstantiationException: " + id + " " + e.getMessage(),e);
            continue;
          } catch (IllegalAccessException e) {
            Logger.debug(PluginLoader.class,"IllegalAccessException: " + id + " " + e.getMessage(),e);
            continue;
          } catch (ClassNotFoundException e) {
            Logger.debug(PluginLoader.class,"ClassNotFoundException: " + id + " " + e.getMessage(),e);
            continue;
          }
        }
        setUpHooks(id);
        pluginIds.add(id);
        pluginAPI.setDeployedPluginOrder(pluginIds);
        pluginAPI.loadBackEndFiles(plugin.getId());
       
      }catch (Exception e) {
        Logger.fatal(this, "ERROR DEPLOYING A PLUGIN : " + id, e);
      }
    }
View Full Code Here


  }
 
  @Override
  protected com.dotmarketing.plugin.model.Plugin get(String pluginId) {
    String key = pluginGroup + pluginId;
      Plugin plugin = null;
      try{
        plugin = (Plugin)cache.get(key,pluginGroup);
      }catch (DotCacheException e) {
      Logger.debug(this, "Cache Entry not found", e);
    }
View Full Code Here

  /* (non-Javadoc)
   * @see com.dotmarketing.plugin.business.PluginFactory#loadPlugin(java.lang.String)
   */
  @Override
  protected Plugin loadPlugin(String id) throws DotDataException{
    Plugin plugin = cache.get(id);
    if(plugin != null){
      return plugin;
    }
    HibernateUtil hu = new HibernateUtil(Plugin.class);
    try {
      plugin = (Plugin)hu.load(id);
      if(plugin != null && UtilMethods.isSet(plugin.getId())){
        cache.removePlugin(plugin.getId());
        cache.add(plugin);
      }
      return plugin;
    } catch (DotHibernateException e) {
      Logger.error(this, e.getMessage(), e);
View Full Code Here

TOP

Related Classes of com.dotmarketing.plugin.model.Plugin

Copyright © 2018 www.massapicom. 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.