serval-dna/java/org/servalproject/servald/ServalD.java
Andrew Bettison 7e7ab30808 Refactor JNI command-line interface
Does not depend on ServalDResult class - appends output fields to a supplied
list instead, and returns the integer status

Does not depend on ServalDReentranceError class - uses
java.lang.IllegalStateException instead
2012-04-30 17:45:24 +09:30

34 lines
600 B
Java

package org.servalproject.servald;
import java.util.List;
import java.util.LinkedList;
class ServalD
{
int status;
List<String> outv;
public ServalD()
{
System.loadLibrary("servald");
}
public native int rawCommand(List<String> outv, String... args);
public void command(String... args)
{
this.outv = new LinkedList<String>();
this.status = this.rawCommand(this.outv, args);
}
public static void main(String[] args)
{
ServalD servald = new ServalD();
servald.command(args);
for (String s: servald.outv) {
System.out.println(s);
}
System.exit(servald.status);
}
}