/** * Creates the service method description for the multiplication service * method. * * @return multiplication service method description */ public static ServiceMethodDescription multiplyMethod() { return new ServiceMethodDescription("multiply", "Multiplies two numbers.") { @Override public ServiceMethod createServiceMethod(ServiceDescription serviceDescription) { return new MultiplyServiceMethod(this, serviceDescription); } }.addArgument("arg1", "First argument", VNumber.class) .addArgument("arg2", "Second argument", VNumber.class) .addResult("result", "The product of arg1 and arg2", VNumber.class); }
/** * Adds a result for the pvAccess RPC Service. * * @param name the result name * @param description the result description * @return this */ public RPCServiceMethodDescription addRPCResult(String name, String fieldName, String description, Class<?> type) { if (resultAdded) { throw new IllegalArgumentException("The pvAccess RPC rpcservice can only have one result"); } if (fieldName != null) { this.fieldNames.put(name, fieldName); } else { this.fieldNames.put(name, FIELD_NAME_EQUALS_NAME); } super.addResult(name, description, type); this.resultAdded = true; return this; }
/** * Adds an argument for pvAccess RPC rpcservice. * * @param name argument name * @param description argument description * @param type the expected type of the argument * @return this */ public RPCServiceMethodDescription addArgument(String name, String fieldName, String description, Class<?> type) { super.addArgument(name, description, relaxArgumentType(type)); strictArguments.put(name, type); orderedParameterNames.put(name, fieldName != null ? fieldName : FIELD_NAME_EQUALS_NAME); return this; }
/** * Creates description for the "run" service method; which simply runs the * command on the shell and returns the output. * * @return service method description for exec */ public static ServiceMethodDescription runMethod() { return new ServiceMethodDescription("run", "Executes a command.") { @Override public ServiceMethod createServiceMethod(ServiceDescription serviceDescription) { return new GenericExecServiceMethod(this, serviceDescription); } }.addArgument("command", "The command", VString.class) .addResult("output", "The output of the command", VType.class); }
/** * Creates the service method description for the addition service method. * * @return addition service method description */ private static ServiceMethodDescription addMethod() { return new ServiceMethodDescription("add", "Adds two numbers.") { @Override public ServiceMethod createServiceMethod(ServiceDescription serviceDescription) { return new AddServiceMethod(this, serviceDescription); } }.addArgument("arg1", "First argument", VNumber.class) .addArgument("arg2", "Second argument", VNumber.class) .addResult("result", "The sum of arg1 and arg2", VNumber.class); }