Package org.rzo.yajsw.wrapper

Source Code of org.rzo.yajsw.wrapper.WrappedProcessFactory

package org.rzo.yajsw.wrapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.MapConfiguration;
import org.rzo.yajsw.config.YajswConfiguration;
import org.rzo.yajsw.config.YajswConfigurationImpl;

public class WrappedProcessFactory
{
  public static WrappedProcess createProcess(YajswConfiguration config)
  {
    if (config.getString("wrapper.image") != null)
      return new WrappedRuntimeProcess();
    else if (config.getString("wrapper.groovy") != null)
      return new WrappedGroovyProcess();
    return new WrappedJavaProcess();
  }

  public static WrappedProcess createProcess(Map map, boolean useSystemProperties)
  {
    Configuration localConf = new MapConfiguration(map);
    YajswConfiguration conf = new YajswConfigurationImpl(localConf, true);
    WrappedProcess process = createProcess(conf);
    process.setLocalConfiguration(localConf);
    process.setUseSystemProperties(useSystemProperties);
    process.init();
    return process;
  }

  public static WrappedProcessList createProcessList(Map map, List<String> confFiles, boolean useSystemProperties)
  {
    WrappedProcessList list = new WrappedProcessList();
    for (String conf : confFiles)
    {
      Map sConf = new HashMap(map);
      sConf.put("wrapper.config", conf);
      list.add(createProcess(sConf, useSystemProperties));
    }
    return list;
  }

}
TOP

Related Classes of org.rzo.yajsw.wrapper.WrappedProcessFactory

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.