summaryrefslogtreecommitdiff
path: root/same/src/main/java/com/orbekk/same/ConnectionManagerImpl.java
blob: 841d5fa6e917408d78da220eb3c095f54c3ffb38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.orbekk.same;

import com.googlecode.jsonrpc4j.JsonRpcHttpClient;
import com.googlecode.jsonrpc4j.ProxyUtil;
import java.net.MalformedURLException;
import java.net.URL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ConnectionManagerImpl implements ConnectionManager {

    private Logger logger = LoggerFactory.getLogger(getClass());

    public ConnectionManagerImpl() {
    }

    @Override
    public SameService getConnection(String url) {
        SameService service = null;
        try {
            JsonRpcHttpClient client = new JsonRpcHttpClient(new URL(url));
            service = ProxyUtil.createProxy(
                    this.getClass().getClassLoader(),
                    SameService.class,
                    client);
        } catch (MalformedURLException e) {
            logger.warn("Unable to create client for {}, {}", url, e);
        }
        return service;
    }
}