diff --git a/java/org/servalproject/servaldna/ServalDCommand.java b/java/org/servalproject/servaldna/ServalDCommand.java index f037be8e..7e6990fd 100644 --- a/java/org/servalproject/servaldna/ServalDCommand.java +++ b/java/org/servalproject/servaldna/ServalDCommand.java @@ -170,6 +170,7 @@ public class ServalDCommand return result; } + @Deprecated public static class IdentityResult extends JniResult { public String did; public String name; @@ -212,6 +213,7 @@ public class ServalDCommand } } + @Deprecated public static IdentityResult keyringAdd() throws ServalDFailureException { IdentityResult result = new IdentityResult(); @@ -219,6 +221,7 @@ public class ServalDCommand return result; } + @Deprecated public static IdentityResult keyringSetDidName(SubscriberId sid, String did, String name) throws ServalDFailureException { IdentityResult result = new IdentityResult(); @@ -226,6 +229,7 @@ public class ServalDCommand return result; } + @Deprecated public static int keyringList(final AsyncResult results) throws ServalDFailureException { // FIXME, this is a little hacky as the number of tags is unknown so we don't have a fixed number of columns @@ -263,6 +267,7 @@ public class ServalDCommand }, "keyring", "list", "--full"); } + @Deprecated public static int keyringList(IJniResults results) throws ServalDFailureException{ return command(results, "keyring", "list"); } @@ -273,6 +278,7 @@ public class ServalDCommand return result; } + @Deprecated public static IdentityResult reverseLookup(final SubscriberId sid) throws ServalDFailureException { IdentityResult result = new IdentityResult(); command(result, "reverse", "lookup", sid.toHex()); @@ -306,6 +312,7 @@ public class ServalDCommand } } + @Deprecated public static int dnaLookup(AsyncResult results, String did, int timeout) throws ServalDFailureException { return dnaLookup(new JniResultList(results) { @Override @@ -315,9 +322,11 @@ public class ServalDCommand }, did, timeout); } + @Deprecated public static int dnaLookup(IJniResults results, String did, int timeout) throws ServalDFailureException { return command(results, "dna", "lookup", did, Integer.toString(timeout)); } + public static class ManifestResult extends JniResult{ public BundleId manifestId; public long version; @@ -583,6 +592,7 @@ public class ServalDCommand } // Note that the result values will only have a subscriber id + @Deprecated public static int idPeers(AsyncResult results) throws ServalDFailureException { return idPeers(new JniResultList(results) { @Override @@ -592,6 +602,7 @@ public class ServalDCommand }); } + @Deprecated public static int idPeers(IJniResults results) throws ServalDFailureException { return command(results, "id", "peers"); } diff --git a/java/org/servalproject/servaldna/ServerControl.java b/java/org/servalproject/servaldna/ServerControl.java index 57010dce..7e086cd1 100644 --- a/java/org/servalproject/servaldna/ServerControl.java +++ b/java/org/servalproject/servaldna/ServerControl.java @@ -85,27 +85,30 @@ public class ServerControl { start(); } - public boolean isRunning() throws ServalDFailureException { - ServalDCommand.Status s = ServalDCommand.serverStatus(); - - if (s.status.equals("running")) { - setStatus(s); - }else{ - clearStatus(); + public boolean isRunning() { + try { + ServalDCommand.Status s = ServalDCommand.serverStatus(); + if (s.status.equals("running")) { + setStatus(s); + return pid!=0; + } + } catch (ServalDFailureException e) { + // ignore } + clearStatus(); return pid!=0; } public MdpServiceLookup getMdpServiceLookup(ChannelSelector selector, AsyncResult results) throws ServalDInterfaceException, IOException { if (!isRunning()) throw new ServalDInterfaceException("server is not running"); - return new MdpServiceLookup(selector, this.loopbackMdpPort, results); + return new MdpServiceLookup(selector, getLoopbackMdpPort(), results); } public MdpDnaLookup getMdpDnaLookup(ChannelSelector selector, AsyncResult results) throws ServalDInterfaceException, IOException { if (!isRunning()) throw new ServalDInterfaceException("server is not running"); - return new MdpDnaLookup(selector, this.loopbackMdpPort, results); + return new MdpDnaLookup(selector, getLoopbackMdpPort(), results); } public ServalDClient getRestfulClient() throws ServalDInterfaceException {