add skeleton launcher project FELIX-1324


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@801990 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/common/runtime/.classpath b/sigil/common/runtime/.classpath
new file mode 100644
index 0000000..ef51f6b
--- /dev/null
+++ b/sigil/common/runtime/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java 1.6.0"/>
+	<classpathentry kind="con" path="org.apache.felix.sigil.classpathContainer"/>
+	<classpathentry kind="output" path="build/classes"/>
+</classpath>
diff --git a/sigil/common/runtime/.project b/sigil/common/runtime/.project
new file mode 100644
index 0000000..7ce9ec8
--- /dev/null
+++ b/sigil/common/runtime/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.apache.felix.sigil.common.runtime</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.apache.felix.sigil.eclipse.core.sigilBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.apache.felix.sigil.sigilnature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
diff --git a/sigil/common/runtime/sigil.properties b/sigil/common/runtime/sigil.properties
new file mode 100644
index 0000000..2488647
--- /dev/null
+++ b/sigil/common/runtime/sigil.properties
@@ -0,0 +1,15 @@
+
+# sigil project file, saved by plugin.
+
+-bundles: \
+	org.apache.felix.sigil.common.runtime, \
+
+-sourcedirs: \
+	src, \
+
+-imports: \
+	org.apache.commons.cli;version=1.2.0, \
+	org.osgi.framework, \
+	org.osgi.framework.launch;version=1.0.0, \
+
+# end
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java
new file mode 100644
index 0000000..c7ddab3
--- /dev/null
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java
@@ -0,0 +1,87 @@
+package org.apache.felix.sigil.common.runtime;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.ServiceLoader;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.Parser;
+import org.apache.commons.cli.PosixParser;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+public class Main
+{
+    private static final String COMMAND_LINE_SYNTAX = "java -jar org.apache.felix.sigil.common.runtime";
+    
+    private static Framework framework;
+    private static final Options options;
+    
+    static {
+        options = new Options();
+        options.addOption( "?", "help", false, "Print help for the Sigil launcher" );
+    }
+
+    public static void main( String[] args )
+    {
+        try {
+            Parser parser = new PosixParser();
+            CommandLine cl = parser.parse( options, args );
+            
+            if ( cl.hasOption( '?' ) ) {
+                printHelp();
+            }
+            else {
+                ServiceLoader<FrameworkFactory> loader = ServiceLoader.load( FrameworkFactory.class );
+                FrameworkFactory factory = loader.iterator().next();
+                
+                Map<String, String> config = buildConfig( cl );
+                
+                framework = factory.newFramework( config );
+                framework.init();
+                
+                launch( args );
+                
+                framework.waitForStop( 0 );
+            }
+        }
+        catch (NoSuchElementException e) {
+            System.err.println( "No " + FrameworkFactory.class.getName() + " found on classpath" );
+            System.exit( 1 );
+        }
+        catch ( BundleException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( InterruptedException e )
+        {
+            System.err.println( "Interrupted prior to framework stop" );
+        }
+        catch ( ParseException e )
+        {
+            printHelp();
+        }
+    }
+
+    private static Map<String, String> buildConfig( CommandLine cl )
+    {
+        HashMap<String, String> config = new HashMap<String, String>();
+        return config;
+    }
+
+    private static void launch( String[] args ) throws ParseException
+    {
+    }
+    
+    private static void printHelp()
+    {
+        HelpFormatter f = new HelpFormatter();
+        f.printHelp( COMMAND_LINE_SYNTAX, options );
+    }
+}