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