Deprecate java command line api to keyring commands

This commit is contained in:
Jeremy Lakeman 2015-09-28 12:03:27 +09:30
parent 75df3bd4ec
commit 41d416977f
2 changed files with 23 additions and 9 deletions

View File

@ -170,6 +170,7 @@ public class ServalDCommand
return result; return result;
} }
@Deprecated
public static class IdentityResult extends JniResult { public static class IdentityResult extends JniResult {
public String did; public String did;
public String name; public String name;
@ -212,6 +213,7 @@ public class ServalDCommand
} }
} }
@Deprecated
public static IdentityResult keyringAdd() public static IdentityResult keyringAdd()
throws ServalDFailureException { throws ServalDFailureException {
IdentityResult result = new IdentityResult(); IdentityResult result = new IdentityResult();
@ -219,6 +221,7 @@ public class ServalDCommand
return result; return result;
} }
@Deprecated
public static IdentityResult keyringSetDidName(SubscriberId sid, String did, String name) throws ServalDFailureException public static IdentityResult keyringSetDidName(SubscriberId sid, String did, String name) throws ServalDFailureException
{ {
IdentityResult result = new IdentityResult(); IdentityResult result = new IdentityResult();
@ -226,6 +229,7 @@ public class ServalDCommand
return result; return result;
} }
@Deprecated
public static int keyringList(final AsyncResult<IdentityResult> results) throws ServalDFailureException public static int keyringList(final AsyncResult<IdentityResult> 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 // 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"); }, "keyring", "list", "--full");
} }
@Deprecated
public static int keyringList(IJniResults results) throws ServalDFailureException{ public static int keyringList(IJniResults results) throws ServalDFailureException{
return command(results, "keyring", "list"); return command(results, "keyring", "list");
} }
@ -273,6 +278,7 @@ public class ServalDCommand
return result; return result;
} }
@Deprecated
public static IdentityResult reverseLookup(final SubscriberId sid) throws ServalDFailureException { public static IdentityResult reverseLookup(final SubscriberId sid) throws ServalDFailureException {
IdentityResult result = new IdentityResult(); IdentityResult result = new IdentityResult();
command(result, "reverse", "lookup", sid.toHex()); command(result, "reverse", "lookup", sid.toHex());
@ -306,6 +312,7 @@ public class ServalDCommand
} }
} }
@Deprecated
public static int dnaLookup(AsyncResult<LookupResult> results, String did, int timeout) throws ServalDFailureException { public static int dnaLookup(AsyncResult<LookupResult> results, String did, int timeout) throws ServalDFailureException {
return dnaLookup(new JniResultList<LookupResult>(results) { return dnaLookup(new JniResultList<LookupResult>(results) {
@Override @Override
@ -315,9 +322,11 @@ public class ServalDCommand
}, did, timeout); }, did, timeout);
} }
@Deprecated
public static int dnaLookup(IJniResults results, String did, int timeout) throws ServalDFailureException { public static int dnaLookup(IJniResults results, String did, int timeout) throws ServalDFailureException {
return command(results, "dna", "lookup", did, Integer.toString(timeout)); return command(results, "dna", "lookup", did, Integer.toString(timeout));
} }
public static class ManifestResult extends JniResult{ public static class ManifestResult extends JniResult{
public BundleId manifestId; public BundleId manifestId;
public long version; public long version;
@ -583,6 +592,7 @@ public class ServalDCommand
} }
// Note that the result values will only have a subscriber id // Note that the result values will only have a subscriber id
@Deprecated
public static int idPeers(AsyncResult<IdentityResult> results) throws ServalDFailureException { public static int idPeers(AsyncResult<IdentityResult> results) throws ServalDFailureException {
return idPeers(new JniResultList<IdentityResult>(results) { return idPeers(new JniResultList<IdentityResult>(results) {
@Override @Override
@ -592,6 +602,7 @@ public class ServalDCommand
}); });
} }
@Deprecated
public static int idPeers(IJniResults results) throws ServalDFailureException { public static int idPeers(IJniResults results) throws ServalDFailureException {
return command(results, "id", "peers"); return command(results, "id", "peers");
} }

View File

@ -85,27 +85,30 @@ public class ServerControl {
start(); start();
} }
public boolean isRunning() throws ServalDFailureException { public boolean isRunning() {
ServalDCommand.Status s = ServalDCommand.serverStatus(); try {
ServalDCommand.Status s = ServalDCommand.serverStatus();
if (s.status.equals("running")) { if (s.status.equals("running")) {
setStatus(s); setStatus(s);
}else{ return pid!=0;
clearStatus(); }
} catch (ServalDFailureException e) {
// ignore
} }
clearStatus();
return pid!=0; return pid!=0;
} }
public MdpServiceLookup getMdpServiceLookup(ChannelSelector selector, AsyncResult<MdpServiceLookup.ServiceResult> results) throws ServalDInterfaceException, IOException { public MdpServiceLookup getMdpServiceLookup(ChannelSelector selector, AsyncResult<MdpServiceLookup.ServiceResult> results) throws ServalDInterfaceException, IOException {
if (!isRunning()) if (!isRunning())
throw new ServalDInterfaceException("server is not running"); 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<ServalDCommand.LookupResult> results) throws ServalDInterfaceException, IOException { public MdpDnaLookup getMdpDnaLookup(ChannelSelector selector, AsyncResult<ServalDCommand.LookupResult> results) throws ServalDInterfaceException, IOException {
if (!isRunning()) if (!isRunning())
throw new ServalDInterfaceException("server is not running"); 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 { public ServalDClient getRestfulClient() throws ServalDInterfaceException {