PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/example/src/main/java/example/server/GreetingServiceImpl.java

https://code.google.com/p/gwtrpccommlayer/
Java | 48 lines | 24 code | 7 blank | 17 comment | 0 complexity | d79ac87c836d556d3f6e9e9cd24e6003 MD5 | raw file
 1package example.server;
 2
 3import com.googlecode.gwtrpccommlayer.server.GwtRpcCommLayerServlet;
 4import example.client.GreetingService;
 5import example.shared.UserFormData;
 6
 7import java.util.ArrayList;
 8
 9/**
10 * The server side implementation of the RPC service.
11 */
12@SuppressWarnings("serial")
13public class GreetingServiceImpl extends GwtRpcCommLayerServlet/*RemoteServiceServlet*/ implements GreetingService
14{
15	ArrayList<UserFormData> list = new ArrayList<UserFormData>();
16	
17	@Override
18	public String addUserFormData(UserFormData data)
19	{
20		list.add(data);
21		return "Data saved. Thank you.";
22	}
23
24	public UserFormData[] getUserFormData(Integer startIndex, Integer length)
25	{
26		return list.subList(startIndex, length).toArray(new UserFormData[0]);
27	}
28
29	public Integer getUserFormDataCount()
30	{
31		return list.size();
32	}
33
34//	public String greetServer(String input) throws IllegalArgumentException
35//	{
36//		// Verify that the input is valid. 
37//		if (!FieldVerifier.isValidName(input))
38//		{
39//			// If the input is not valid, throw an IllegalArgumentException back to
40//			// the client.
41//			throw new IllegalArgumentException("Name must be at least 4 characters long");
42//		}
43//
44//		String serverInfo = getServletContext().getServerInfo();
45//		String userAgent = getThreadLocalRequest().getHeader("User-Agent");
46//		return "Hello, " + input + "!<br><br>I am running " + serverInfo + ".<br><br>It looks like you are using:<br>" + userAgent;
47//	}
48}