X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.db%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fdb%2FSCLScriptRunnerApplication.java;h=5e53808a2b30f039b49d19282c0ad0f1531b5dfa;hb=53062e8f34c2d2a910e4e81835c81ebafef1a374;hp=f26908955bc722547700cd111cfe8c648b9a309d;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLScriptRunnerApplication.java b/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLScriptRunnerApplication.java index f26908955..5e53808a2 100644 --- a/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLScriptRunnerApplication.java +++ b/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLScriptRunnerApplication.java @@ -1,72 +1,74 @@ -package org.simantics.scl.db; - -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.Simantics; -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, - }; - IArguments result = Arguments.parse(args, accepted); - return result; - } - - @Override - public void stop() { - } - -} +package org.simantics.scl.db; + +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.Simantics; +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() { + } + +}