1 package org.simantics;
\r
3 import java.io.BufferedReader;
\r
4 import java.io.IOException;
\r
5 import java.io.InputStreamReader;
\r
7 import org.eclipse.core.runtime.IProgressMonitor;
\r
8 import org.eclipse.core.runtime.NullProgressMonitor;
\r
9 import org.eclipse.equinox.app.IApplication;
\r
10 import org.eclipse.equinox.app.IApplicationContext;
\r
11 import org.simantics.application.arguments.Arguments;
\r
12 import org.simantics.application.arguments.IArgumentFactory;
\r
13 import org.simantics.application.arguments.IArguments;
\r
14 import org.simantics.application.arguments.SimanticsArguments;
\r
15 import org.simantics.scl.compiler.commands.CommandSession;
\r
16 import org.simantics.scl.osgi.SCLOsgi;
\r
17 import org.simantics.scl.runtime.reporting.SCLReportingHandler;
\r
19 public class SCLScriptRunnerApplication implements IApplication {
\r
22 public Object start(IApplicationContext context) throws Exception {
\r
24 String[] args = (String[])context.getArguments().get("application.args");
\r
25 IProgressMonitor progress = new NullProgressMonitor();
\r
26 Simantics.startUpHeadless(parseArguments(args), progress);
\r
28 Simantics.shutdown(progress);
\r
29 return IApplication.EXIT_OK;
\r
30 } catch(Throwable t) {
\r
31 t.printStackTrace();
\r
38 private void runSCLFromStdin() throws Exception {
\r
39 BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
\r
40 CommandSession commandSession = new CommandSession(SCLOsgi.MODULE_REPOSITORY,
\r
41 SCLReportingHandler.DEFAULT_WITHOUT_ECHO);
\r
44 String line = input.readLine();
\r
49 commandSession.execute(line);
\r
51 } catch(IOException e) {
\r
52 e.printStackTrace();
\r
56 private IArguments parseArguments(String[] args) {
\r
57 IArgumentFactory<?>[] accepted = {
\r
58 SimanticsArguments.RECOVERY_POLICY_FIX_ERRORS,
\r
59 SimanticsArguments.ONTOLOGY_RECOVERY_POLICY_REINSTALL,
\r
60 SimanticsArguments.SERVER,
\r
61 SimanticsArguments.LOCAL_SERVER_PORT,
\r
62 SimanticsArguments.DATABASE_ID,
\r
64 IArguments result = Arguments.parse(args, accepted);
\r
69 public void stop() {
\r