PageRenderTime 42ms CodeModel.GetById 27ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/v3.2/nimbits-sdk/src/com/nimbits/client/NimbitsClientFactory.java

http://nimbits-server.googlecode.com/
Java | 53 lines | 36 code | 10 blank | 7 comment | 12 complexity | daf6c7555be5b6657632da210b5ebceb MD5 | raw file
 1package com.nimbits.client;
 2
 3import com.nimbits.client.model.email.EmailAddress;
 4import com.nimbits.user.GoogleUser;
 5import com.nimbits.user.NimbitsUser;
 6
 7/**
 8 * Created by bsautner
 9 * User: benjamin
10 * Date: 3/13/11
11 * Time: 12:41 PM
12 *
13 */
14public class NimbitsClientFactory {
15    private static NimbitsClientImpl instance;
16
17    protected NimbitsClientFactory() {
18    }
19
20
21    public static NimbitsClient getInstance(final NimbitsUser n,final String hostUrl) {
22        if (instance == null) {
23            instance = new NimbitsClientImpl(n, hostUrl);
24        }
25        else if (! instance.getHost().equals(hostUrl)) {
26            instance = new NimbitsClientImpl(n, hostUrl);
27        }
28        return instance;
29
30    }
31
32    public static NimbitsClient getInstance(final GoogleUser g,final String hostUrl) throws Exception {
33        if (instance == null) {
34            instance = new NimbitsClientImpl(g, hostUrl);
35        }
36        else if (! instance.getHost().equals(hostUrl)) {
37            instance = new NimbitsClientImpl(g, hostUrl);
38        }
39        return instance;
40
41    }
42    public static NimbitsClient getInstance(final String authToken,final EmailAddress email,final String hostUrl) throws Exception {
43        if (instance == null) {
44            instance = new NimbitsClientImpl(authToken, email, hostUrl);
45        }
46        else if (! instance.getHost().equals(hostUrl)) {
47            instance = new NimbitsClientImpl(authToken, email, hostUrl);
48        }
49
50        return instance;
51
52    }
53}