private void loadPluginJobTypes(final JobTypePluginSet plugins)
      throws JobTypeManagerException {
    final File jobPluginsDir = new File(this.jobTypePluginDir);

    if (!jobPluginsDir.exists()) {
      logger.error("Job type plugin dir " + this.jobTypePluginDir
          + " doesn't exist. Will not load any external plugins.");
      return;
    } else if (!jobPluginsDir.isDirectory()) {
      throw new JobTypeManagerException("Job type plugin dir "
          + this.jobTypePluginDir + " is not a directory!");
    } else if (!jobPluginsDir.canRead()) {
      throw new JobTypeManagerException("Job type plugin dir "
          + this.jobTypePluginDir + " is not readable!");
    }

    // Load the common properties used by all jobs that are run
    Props commonPluginJobProps = null;
    final File commonJobPropsFile = new File(jobPluginsDir, COMMONCONFFILE);
    if (commonJobPropsFile.exists()) {
      logger.info("Common plugin job props file " + commonJobPropsFile
          + " found. Attempt to load.");
      try {
        commonPluginJobProps = new Props(this.globalProperties, commonJobPropsFile);
      } catch (final IOException e) {
        throw new JobTypeManagerException(
            "Failed to load common plugin job properties" + e.getCause());
      }
    } else {
      logger.info("Common plugin job props file " + commonJobPropsFile
          + " not found. Using only globals props");
      commonPluginJobProps = new Props(this.globalProperties);
    }

    // Loads the common properties used by all plugins when loading
    Props commonPluginLoadProps = null;
    final File commonLoadPropsFile = new File(jobPluginsDir, COMMONSYSCONFFILE);
    if (commonLoadPropsFile.exists()) {
      logger.info("Common plugin load props file " + commonLoadPropsFile
          + " found. Attempt to load.");
      try {
        commonPluginLoadProps = new Props(null, commonLoadPropsFile);
      } catch (final IOException e) {
        throw new JobTypeManagerException(
            "Failed to load common plugin loader properties" + e.getCause());
      }
    } else {
      logger.info("Common plugin load props file " + commonLoadPropsFile
          + " not found. Using empty props.");
      commonPluginLoadProps = new Props();
    }

    plugins.setCommonPluginJobProps(commonPluginJobProps);
    plugins.setCommonPluginLoadProps(commonPluginLoadProps);

    // Loading job types
    for (final File dir : jobPluginsDir.listFiles()) {
      if (dir.isDirectory() && dir.canRead()) {
        try {
          loadJobTypes(dir, plugins);
        } catch (final Exception e) {
          logger.error(
              "Failed to load jobtype " + dir.getName() + e.getMessage(), e);
          throw new JobTypeManagerException(e);
        }
      }
    }
  }
private void loadPluginJobTypes ( final JobTypePluginSet plugins ) throws JobTypeManagerException { final File jobPluginsDir = new File ( this . jobTypePluginDir ) ; if ( ! jobPluginsDir . exists ( ) ) { logger . error ( "Job type plugin dir " + this . jobTypePluginDir + " doesn't exist. Will not load any external plugins." ) ; return ; } else if ( ! jobPluginsDir . isDirectory ( ) ) { throw new JobTypeManagerException ( "Job type plugin dir " + this . jobTypePluginDir + " is not a directory!" ) ; } else if ( ! jobPluginsDir . canRead ( ) ) { throw new JobTypeManagerException ( "Job type plugin dir " + this . jobTypePluginDir + " is not readable!" ) ; } Props commonPluginJobProps = null ; final File commonJobPropsFile = new File ( jobPluginsDir , COMMONCONFFILE ) ; if ( commonJobPropsFile . exists ( ) ) { logger . info ( "Common plugin job props file " + commonJobPropsFile + " found. Attempt to load." ) ; try { commonPluginJobProps = new Props ( this . globalProperties , commonJobPropsFile ) ; } catch ( final IOException e ) { throw new JobTypeManagerException ( "Failed to load common plugin job properties" + e . getCause ( ) ) ; } } else { logger . info ( "Common plugin job props file " + commonJobPropsFile + " not found. Using only globals props" ) ; commonPluginJobProps = new Props ( this . globalProperties ) ; } Props commonPluginLoadProps = null ; final File commonLoadPropsFile = new File ( jobPluginsDir , COMMONSYSCONFFILE ) ; if ( commonLoadPropsFile . exists ( ) ) { logger . info ( "Common plugin load props file " + commonLoadPropsFile + " found. Attempt to load." ) ; try { commonPluginLoadProps = new Props ( null , commonLoadPropsFile ) ; } catch ( final IOException e ) { throw new JobTypeManagerException ( "Failed to load common plugin loader properties" + e . getCause ( ) ) ; } } else { logger . info ( "Common plugin load props file " + commonLoadPropsFile + " not found. Using empty props." ) ; commonPluginLoadProps = new Props ( ) ; } plugins . setCommonPluginJobProps ( commonPluginJobProps ) ; plugins . setCommonPluginLoadProps ( commonPluginLoadProps ) ; for ( final File dir : jobPluginsDir . listFiles ( ) ) { if ( dir . isDirectory ( ) && dir . canRead ( ) ) { try { loadJobTypes ( dir , plugins ) ; } catch ( final Exception e ) { logger . error ( "Failed to load jobtype " + dir . getName ( ) + e . getMessage ( ) , e ) ; throw new JobTypeManagerException ( e ) ; } } } }
load Job Types from jobtype plugin dir