-package org.simantics;\r
-\r
-import java.io.BufferedReader;\r
-import java.io.IOException;\r
-import java.io.InputStreamReader;\r
-\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.NullProgressMonitor;\r
-import org.eclipse.equinox.app.IApplication;\r
-import org.eclipse.equinox.app.IApplicationContext;\r
-import org.simantics.application.arguments.Arguments;\r
-import org.simantics.application.arguments.IArgumentFactory;\r
-import org.simantics.application.arguments.IArguments;\r
-import org.simantics.application.arguments.SimanticsArguments;\r
-import org.simantics.scl.compiler.commands.CommandSession;\r
-import org.simantics.scl.osgi.SCLOsgi;\r
-import org.simantics.scl.runtime.reporting.SCLReportingHandler;\r
-\r
-public class SCLScriptRunnerApplication implements IApplication {\r
-\r
- @Override\r
- public Object start(IApplicationContext context) throws Exception {\r
- try {\r
- String[] args = (String[])context.getArguments().get("application.args");\r
- IProgressMonitor progress = new NullProgressMonitor();\r
- Simantics.startUpHeadless(parseArguments(args), progress);\r
- runSCLFromStdin();\r
- Simantics.shutdown(progress);\r
- return IApplication.EXIT_OK;\r
- } catch(Throwable t) {\r
- t.printStackTrace();\r
- throw (Exception)t;\r
- } finally {\r
- System.exit(0);\r
- }\r
- }\r
- \r
- private void runSCLFromStdin() throws Exception {\r
- BufferedReader input = new BufferedReader(new InputStreamReader(System.in));\r
- CommandSession commandSession = new CommandSession(SCLOsgi.MODULE_REPOSITORY,\r
- SCLReportingHandler.DEFAULT_WITHOUT_ECHO);\r
- try {\r
- while(true) {\r
- String line = input.readLine();\r
- if(line == null)\r
- break;\r
- if(line.isEmpty())\r
- continue;\r
- commandSession.execute(line);\r
- }\r
- } catch(IOException e) {\r
- e.printStackTrace();\r
- } \r
- }\r
-\r
- private IArguments parseArguments(String[] args) {\r
- IArgumentFactory<?>[] accepted = {\r
- SimanticsArguments.RECOVERY_POLICY_FIX_ERRORS,\r
- SimanticsArguments.ONTOLOGY_RECOVERY_POLICY_REINSTALL,\r
- SimanticsArguments.SERVER,\r
- SimanticsArguments.LOCAL_SERVER_PORT,\r
- SimanticsArguments.DATABASE_ID,\r
- };\r
- IArguments result = Arguments.parse(args, accepted);\r
- return result;\r
- }\r
- \r
- @Override\r
- public void stop() {\r
- }\r
-\r
-}\r
+package org.simantics;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+import org.simantics.application.arguments.Arguments;
+import org.simantics.application.arguments.IArgumentFactory;
+import org.simantics.application.arguments.IArguments;
+import org.simantics.application.arguments.SimanticsArguments;
+import org.simantics.scl.compiler.commands.CommandSession;
+import org.simantics.scl.osgi.SCLOsgi;
+import org.simantics.scl.runtime.reporting.SCLReportingHandler;
+
+public class SCLScriptRunnerApplication implements IApplication {
+
+ @Override
+ public Object start(IApplicationContext context) throws Exception {
+ try {
+ String[] args = (String[])context.getArguments().get("application.args");
+ IProgressMonitor progress = new NullProgressMonitor();
+ Simantics.startUpHeadless(parseArguments(args), progress);
+ runSCLFromStdin();
+ Simantics.shutdown(progress);
+ return IApplication.EXIT_OK;
+ } catch(Throwable t) {
+ t.printStackTrace();
+ throw (Exception)t;
+ } finally {
+ System.exit(0);
+ }
+ }
+
+ private void runSCLFromStdin() throws Exception {
+ BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
+ CommandSession commandSession = new CommandSession(SCLOsgi.MODULE_REPOSITORY,
+ SCLReportingHandler.DEFAULT_WITHOUT_ECHO);
+ try {
+ while(true) {
+ String line = input.readLine();
+ if(line == null)
+ break;
+ if(line.isEmpty())
+ continue;
+ commandSession.execute(line);
+ }
+ } catch(IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private IArguments parseArguments(String[] args) {
+ IArgumentFactory<?>[] accepted = {
+ SimanticsArguments.RECOVERY_POLICY_FIX_ERRORS,
+ SimanticsArguments.ONTOLOGY_RECOVERY_POLICY_REINSTALL,
+ SimanticsArguments.SERVER,
+ SimanticsArguments.LOCAL_SERVER_PORT,
+ SimanticsArguments.DISABLE_INDEX,
+ SimanticsArguments.DATABASE_ID,
+ };
+ IArguments result = Arguments.parse(args, accepted);
+ return result;
+ }
+
+ @Override
+ public void stop() {
+ }
+
+}