1
2
3
4
5
6
7
8
9 package de.fhg.first.resmatch.client;
10
11 import org.apache.log4j.Logger;
12 import org.apache.axis.AxisProperties;
13
14 import java.net.URL;
15
16 /***
17 * Singleton pattern
18 *
19 * @author Andreas Hoheisel
20 * (<a href="http://www.andreas-hoheisel.de">www.andreas-hoheisel.de</a>)
21 * @version $Id: ResourceMatcherClient.java 530 2008-08-05 11:38:56Z kwfgrid.bassheide $
22 */
23 public class ResourceMatcherClient {
24
25 /***
26 * log4j logger.
27 */
28 final static Logger logger = Logger.getLogger(ResourceMatcherClient.class);
29
30 private static ResourceMatcherClient ourInstance;
31
32 public ResourceMatcher resmatch;
33
34 public synchronized static ResourceMatcherClient getInstance() throws Exception {
35 if (ResourceMatcherClient.ourInstance == null) {
36 ResourceMatcherClient.ourInstance = new ResourceMatcherClient();
37 }
38 return ResourceMatcherClient.ourInstance;
39 }
40
41 private ResourceMatcherClient() throws Exception {
42 String resmatchServiceStr = System.getProperty("resource.resmatch.service.url");
43 if (resmatchServiceStr == null) {
44 throw new Exception("The resource matcher client has not been configured correctly. Please set the property\n"
45 + "resource.resmatch.service.url in the file gwes.properties or as system property");
46 }
47
48 URL resmatchServiceUrl = new URL(resmatchServiceStr);
49 ResourceMatcherService service = new ResourceMatcherServiceLocator();
50 resmatch = service.getResourceMatcher(resmatchServiceUrl);
51 if (resmatch == null) throw new Exception("Could not connect to resource matcher at "+resmatchServiceUrl);
52 ResourceMatcherClient.logger.info("connected to " + resmatchServiceUrl);
53 }
54
55 }