/** * Hello world. * * @return the string */ @Access(AccessType.PUBLIC) public String helloWorld() { return ("Hello World"); }
/** * Hello world. * * @param message * the message * @return the string */ @Override public String helloWorld(@Name("message") final String message) { return "You said:" + message; }
/** * Do more, with an ignored return value..... * * @return the string */ @NoReply String doMore(); }
/** * Gets the my sub agent. * * @return the my sub agent */ @Namespace("sub") public MySubAgent getMySubAgent() { return new MySubAgent(); }
/** * Get the name of a parameter Reads the parameter annotation @Name. Returns * null if the annotation is not provided. * * @param param * the param * @return name */ static String getName(final AnnotatedParam param) { String name = null; final Name nameAnnotation = param.getAnnotation(Name.class); if (nameAnnotation != null) { name = nameAnnotation.value(); } return name; }
/** * Test if a parameter is required Reads the parameter annotation @Required. * Returns True if the annotation is not provided. * * @param param * the param * @return required */ @SuppressWarnings("deprecation") static boolean isRequired(final AnnotatedParam param) { boolean required = true; final com.almende.eve.protocol.jsonrpc.annotation.Required requiredAnnotation = param .getAnnotation(com.almende.eve.protocol.jsonrpc.annotation.Required.class); if (requiredAnnotation != null) { required = requiredAnnotation.value(); } if (param.getAnnotation(Optional.class) != null) { required = false; } return required; }
@Access(AccessType.PUBLIC) class MySubAgent { public String helloWorld() { return ("Hello World"); } }
/** * Hello world. * * @param message * the message * @return the string */ String helloWorld(@Name("message") String message);
/** * The Interface ExampleAgentInterface. */ @NoReply public interface ExampleAgentInterface { /** * Hello world. * * @param message * the message * @return the string */ String helloWorld(@Name("message") String message); /** * Do something. */ void doSomething(); /** * Do more, with an ignored return value..... * * @return the string */ @NoReply String doMore(); }
/** * Gets the config. * * @return the config */ @Access(AccessType.PUBLIC) @Override public AgentConfig getConfig() { return config; }
/** * Gets the person. * * @param test * the test * @return the person */ public List<MessageContainer> getMessage( @Name("message") final MessageContainer test) { return Arrays.asList(test); }
/** * Gets the id. * * @return the id */ @Access(AccessType.PUBLIC) @Override public String getId() { return agentId; }
/** * The Class CalcAgent. */ @Access(AccessType.PUBLIC) public class CalcAgent extends Agent { private static final String CALC_API_URL = "http://api.mathjs.org/v1/"; /** * Evaluate given expression For example expr="2.5 + 3 / sqrt(16)" will * return "3.25" * * @param expr * the expr * @return result * @throws IOException * Signals that an I/O exception has occurred. */ public String eval(@Name("expr") final String expr) throws IOException { final String url = CALC_API_URL + "?expr=" + URLEncoder.encode(expr, "UTF-8"); final HttpClient client = HttpClients.createDefault(); final HttpGet request = new HttpGet(url); final HttpResponse response = client.execute(request); return StringUtil.streamToString(response.getEntity().getContent()); } }
/** * Gets the state. * * @return the state */ @Access(AccessType.UNAVAILABLE) @JsonIgnore protected State getState() { return state; }
/** * Throw exception. * * @throws IllegalStateException * the illegal state exception */ @Access(AccessType.PUBLIC) public void throwException() throws IllegalStateException { throw new IllegalStateException("Hi there!"); } }
/** * Gets the type. * * @return the type */ @Access(AccessType.PUBLIC) @Override public String getType() { return this.getClass().getName(); }
/** * Connect all transports. * * @throws IOException * Signals that an I/O exception has occurred. */ @Access(AccessType.UNAVAILABLE) public void connect() throws IOException { transport.connect(); }
/** * Cancel. * * @param taskId * the task id */ @Access(AccessType.UNAVAILABLE) protected void cancel(final String taskId) { final Scheduler scheduler = this.scheduler; if (scheduler == null) return; scheduler.cancel(taskId); }
/** * Creates a proxy for given URL and interface, with this agent as sender. * * @param <T> * the generic type * @param url * the url * @param agentInterface * the agent interface * @return the t */ @Access(AccessType.UNAVAILABLE) protected final <T> T createAgentProxy(final URI url, final Class<T> agentInterface) { return AgentProxyFactory.genProxy(this, url, agentInterface); }
/** * Gets the urls. * * @return the urls */ @Access(AccessType.PUBLIC) @Override @JsonIgnore public List<URI> getUrls() { return transport.getAddresses(); }