1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package com.buckosoft.BuckoVidLib.web.plex.client;
23
24 import static com.buckosoft.BuckoVidLib.web.plex.client.RestClientConstants.CXF_CLIENT_CONNECTION_TIMEOUT_PROP_KEY;
25 import static com.buckosoft.BuckoVidLib.web.plex.client.RestClientConstants.CXF_CLIENT_LOGGING_IN_INTERCEPTOR_PROP_KEY;
26 import static com.buckosoft.BuckoVidLib.web.plex.client.RestClientConstants.CXF_CLIENT_LOGGING_OUT_INTERCEPTOR_PROP_KEY;
27 import static com.buckosoft.BuckoVidLib.web.plex.client.RestClientConstants.CXF_CLIENT_RECEIVE_TIMEOUT_PROP_KEY;
28 import static com.buckosoft.BuckoVidLib.web.plex.client.RestClientConstants.DEFAULT_CXF_CLIENT_CONNECTION_TIMEOUT;
29 import static com.buckosoft.BuckoVidLib.web.plex.client.RestClientConstants.DEFAULT_CXF_CLIENT_RECEIVE_TIMEOUT;
30 import static com.buckosoft.BuckoVidLib.web.plex.client.RestClientConstants.REST_SERVER_URL_PROP_KEY;
31 import static com.buckosoft.BuckoVidLib.web.plex.client.RestClientConstants.DEFAULT_REST_SERVER_LOCATION;
32
33 import org.apache.commons.logging.Log;
34 import org.apache.commons.logging.LogFactory;
35
36 import com.buckosoft.BuckoVidLib.util.ConfigManager;
37
38 public class ClientFactory {
39 private static LibraryClient libraryClient;
40
41 private final Log log = LogFactory.getLog(getClass());
42 public static String SERVER_ENDPOINT_URL = null;
43
44 static {
45 new ClientFactory();
46 }
47 private ClientFactory() {
48 SERVER_ENDPOINT_URL = ConfigManager.getString(REST_SERVER_URL_PROP_KEY, null);
49
50
51 if (SERVER_ENDPOINT_URL == null)
52 SERVER_ENDPOINT_URL = System.getProperty(REST_SERVER_URL_PROP_KEY, DEFAULT_REST_SERVER_LOCATION);
53
54 log.info("Rest server location: " + SERVER_ENDPOINT_URL);
55
56 int connectionTimeout = ConfigManager.getInt(CXF_CLIENT_CONNECTION_TIMEOUT_PROP_KEY, DEFAULT_CXF_CLIENT_CONNECTION_TIMEOUT);
57 log.info("CXF Client connection timeout set to: " + connectionTimeout);
58
59 int receiveTimeout = ConfigManager.getInt(CXF_CLIENT_RECEIVE_TIMEOUT_PROP_KEY, DEFAULT_CXF_CLIENT_RECEIVE_TIMEOUT);
60 log.info("CXF Client receive time out set to: " + receiveTimeout);
61
62 log.info("CXF Client Logging-In Interceptor enabled: " + ConfigManager.isEnabled(CXF_CLIENT_LOGGING_IN_INTERCEPTOR_PROP_KEY));
63 log.info("CXF Client Logging-Out Interceptor enabled: " + ConfigManager.isEnabled(CXF_CLIENT_LOGGING_OUT_INTERCEPTOR_PROP_KEY));
64
65 }
66
67 public static LibraryClient getLibraryClient() {
68 if (libraryClient == null)
69 libraryClient = new LibraryClient(SERVER_ENDPOINT_URL);
70 return(libraryClient);
71 }
72 }