PageRenderTime 153ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/gwtrpccommlayer/src/main/java/com/googlecode/gwtrpccommlayer/client/impl/GwtRpcServiceImpl.java

https://code.google.com/p/gwtrpccommlayer/
Java | 46 lines | 30 code | 7 blank | 9 comment | 0 complexity | ee721b74cbca87df62d96a18922cc5d7 MD5 | raw file
  1. package com.googlecode.gwtrpccommlayer.client.impl;
  2. import com.googlecode.gwtrpccommlayer.client.GwtRpcService;
  3. import org.apache.http.cookie.Cookie;
  4. import java.net.URL;
  5. import java.util.Collection;
  6. /**
  7. * Created by IntelliJ IDEA.
  8. * User: dan
  9. * Date: 10/30/10
  10. * Time: 2:55 PM
  11. */
  12. public class GwtRpcServiceImpl implements GwtRpcService {
  13. @Override
  14. public <T> T create(URL url, Class<T> serviceClass) {
  15. GwtRpcCommLayerClient gwtClient = new GwtRpcCommLayerClient(url);
  16. return returnService(serviceClass, gwtClient);
  17. }
  18. @Override
  19. public <T> T create(URL url, Class<T> serviceClass, Collection<Cookie> cookies) {
  20. GwtRpcCommLayerClient gwtClient = new GwtRpcCommLayerClient(url, cookies);
  21. return returnService(serviceClass, gwtClient);
  22. }
  23. private <T> T returnService(Class<T> serviceClass, GwtRpcCommLayerClient gwtClient) {
  24. try {
  25. T service = gwtClient.createRemoteServicePojoProxy(serviceClass);
  26. return service;
  27. } catch (ClassNotFoundException e) {
  28. //todo: do something interesting with this
  29. e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
  30. } catch (IllegalAccessException e) {
  31. //todo: do something interesting with this
  32. e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
  33. } catch (InstantiationException e) {
  34. //todo: do something interesting with this
  35. e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
  36. }
  37. return null;
  38. }
  39. }