Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package net.nan21.dnet.core.web.controller.data;
  
  
  import  javax.servlet.http.HttpServletRequest;
  import  javax.servlet.http.HttpServletResponse;
  
 
 import  org.apache.commons.lang.time.StopWatch;
 import  org.springframework.web.bind.annotation.PathVariable;
 import  org.springframework.web.bind.annotation.RequestMapping;
 import  org.springframework.web.bind.annotation.RequestMethod;
 import  org.springframework.web.bind.annotation.RequestParam;
 import  org.springframework.web.bind.annotation.ResponseBody;
 
 public class AbstractDsRpcController<M, F, P> extends
 		AbstractDsReadController<M, F, P> {

Default handler for remote procedure call on a single value-object.

Parameters:
resourceName
dataformat
dataString
paramString
Returns:
Throws:
Exception
 
 	@RequestMapping(params = {
 			. + "Type=data" })
 	@ResponseBody
 	public String rpcData(
 			@PathVariable String resourceName,
 			@PathVariable String dataFormat,
 			@RequestParam(value = ., required = trueString rpcName,
 			@RequestParam(value = ., required = false, defaultValue = "{}"String dataString,
 			@RequestParam(value = ., required = false, defaultValue = "{}"String paramString,
 			HttpServletRequest request, HttpServletResponse response)
 			throws Exception {
 
 		try {
 			StopWatch stopWatch = new StopWatch();
 			stopWatch.start();
 
 			this.prepareRequest(requestresponse);
 
 					resourceName.substring(0, resourceName.length() - 2),
 					rpcName);
 
 			if (dataFormat.equals("stream")) {
 				IDsService<M, F, P> service = this.findDsService(resourceName);
 				IDsMarshaller<M, F, P> marshaller = service
 						.createMarshaller("json");
 
 				M data = marshaller.readDataFromString(dataString);
 				P params = marshaller.readParamsFromString(paramString);
 
 				InputStream s = service.rpcDataStream(rpcNamedataparams);
 				this.sendFile(sresponse.getOutputStream());
 				return "";
 			} else {
 				IDsService<M, F, P> service = this.findDsService(resourceName);
 				IDsMarshaller<M, F, P> marshaller = service
 						.createMarshaller(dataFormat);
 
 				M data = marshaller.readDataFromString(dataString);
 				P params = marshaller.readParamsFromString(paramString);
 
 				service.rpcData(rpcNamedataparams);
 				IActionResultRpcData result = this.packRpcDataResult(data,
 						params);
 				stopWatch.stop();
 				result.setExecutionTime(stopWatch.getTime());
 				return marshaller.writeResultToString(result);
 			}
 
 		} catch (Exception e) {
 			return this.handleException(eresponse);
 		} finally {
 			this.finishRequest();
 		}
 	}

Default handler for remote procedure call on a filter.

Parameters:
resourceName
dataformat
dataString
paramString
Returns:
Throws:
Exception
	@RequestMapping(method = RequestMethod.POST, params = {
			. + "Type=filter" })
	@ResponseBody
	public String rpcFilter(
			@PathVariable String resourceName,
			@PathVariable String dataFormat,
			@RequestParam(value = ., required = trueString rpcName,
			@RequestParam(value = ., required = false, defaultValue = "{}"String dataString,
			@RequestParam(value = ., required = false, defaultValue = "{}"String paramString,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		try {
			StopWatch stopWatch = new StopWatch();
			stopWatch.start();
			this.prepareRequest(requestresponse);
					resourceName.substring(0, resourceName.length() - 2),
					rpcName);
			IDsService<M, F, P> service = this.findDsService(resourceName);
			IDsMarshaller<M, F, P> marshaller = service
					.createMarshaller(dataFormat);
filter = marshaller.readFilterFromString(dataString);
params = marshaller.readParamsFromString(paramString);
			service.rpcFilter(rpcNamefilterparams);
					params);
			stopWatch.stop();
			result.setExecutionTime(stopWatch.getTime());
			return marshaller.writeResultToString(result);
finally {
		}
	}
	public IActionResultRpcData packRpcDataResult(M data, P params) {
		pack.setData(data);
		pack.setParams(params);
		return pack;
	}
	public IActionResultRpcFilter packRpcFilterResult(F filter, P params) {
		pack.setData(filter);
		pack.setParams(params);
		return pack;
	}
New to GrepCode? Check out our FAQ X