package kfs.springutils;

import java.io.IOException;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author pavedrim
 */
public class RunApp {

    public static void run(String profileName) {
        run(profileName, "pidfile", "appContext.xml");
    }
    
    public static void run(String profileName, String pidPropertyFilename, String contextFile) {
        if (pidPropertyFilename != null) {
            String pidf = System.getProperty(pidPropertyFilename);
            if ((pidf != null) && !pidf.isEmpty()) {
                ProcessBuilder pb = new ProcessBuilder("/bin/bash", "-c", "echo $PPID > " + pidf);
                try {
                    Process p = pb.start();
                } catch (IOException e) {
                }
            }
        }
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext();
        ctx.setConfigLocation(contextFile);
        ctx.getEnvironment().setActiveProfiles(profileName);
        ctx.refresh();
    }
}

@@ -177,16 +177,150 @@
 nApp %7B%0A%0A
+    public static String defaultContextFile = %22appContext.xml%22;%0A    public static String defaultPidFilePropertyName = %22pidfile%22;%0A    %0A
     publ
@@ -389,35 +389,54 @@
 me, 
-%22pidfile%22, %22app
+defaultPidFilePropertyName, default
 Context
-.xml%22
+File
 );%0A 

Use fafault values as a constats