1
2
3
4
5
6
7 package org.astrogrid.registry.client;
8
9 import org.apache.commons.logging.Log;
10 import org.apache.commons.logging.LogFactory;
11
12
13 import java.io.IOException;
14
15 import org.astrogrid.registry.client.query.RegistryService;
16 import org.astrogrid.registry.client.admin.RegistryAdminService;
17 import org.astrogrid.registry.client.harvest.RegistryHarvestService;
18
19
20 import java.net.URL;
21
22 import org.astrogrid.config.Config;
23
24 /***
25 * Creates the appropriate delegates to access the registry.
26 * @author Kevin Benson
27 */
28
29 public class RegistryDelegateFactory {
30 /***
31 * Commons Logger for this class
32 */
33 private static final Log logger = LogFactory
34 .getLog(RegistryDelegateFactory.class);
35
36
37 public static Config conf = null;
38
39 public static final String QUERY_URL_PROPERTY = "org.astrogrid.registry.query.endpoint";
40 public static final String ALTQUERY_URL_PROPERTY = "org.astrogrid.registry.query.altendpoint";
41 public static final String ADMIN_URL_PROPERTY = "org.astrogrid.registry.admin.endpoint";
42 public static final String HARVEST_URL_PROPERTY = "org.astrogrid.registry.harvest.endpoint";
43 /***
44 * @todo - why is a static reference to the config necessary? wouldn't it be simpler to call config directly each timie
45 */
46 static {
47 if(conf == null) {
48 conf = org.astrogrid.config.SimpleConfig.getSingleton();
49 }
50 }
51
52 /***
53 *
54 * @return
55 */
56 public static synchronized RegistryService createQuery() {
57 return createQuery(conf.getUrl(QUERY_URL_PROPERTY,null));
58 }
59
60 /***
61 *
62 * @todo check for null endpoint and return illegal argument exception?
63 * @param endPoint
64 * @return
65 */
66 public static synchronized RegistryService createQuery(URL endPoint) {
67 logger.info("createQuery(URL) - the ENDPOINT AT DELEGATE = "
68 + "'" + endPoint + "'");
69 return new org.astrogrid.registry.client.query.QueryRegistry(endPoint);
70 }
71
72 /***
73 *
74 * @return
75 */
76 public static synchronized RegistryAdminService createAdmin() {
77 return createAdmin(conf.getUrl(ADMIN_URL_PROPERTY,null));
78 }
79
80 /***
81 *
82 * @todo check for null endpoint and return illegal argument exception?
83 * @param endPoint
84 * @return
85 */
86 public static synchronized RegistryAdminService createAdmin(URL endPoint) {
87 return new org.astrogrid.registry.client.admin.UpdateRegistry(endPoint);
88 }
89
90 /***
91 *
92 * @return
93 */
94 public static synchronized RegistryHarvestService createHarvest() {
95 return createHarvest(conf.getUrl(HARVEST_URL_PROPERTY,null));
96 }
97
98 /***
99 * @todo check for null endpoint and return illegal argument exception?
100 * @param endPoint
101 * @return
102 */
103 public static synchronized RegistryHarvestService createHarvest(URL endPoint) {
104 return new org.astrogrid.registry.client.harvest.RegistryHarvestService(endPoint);
105 }
106
107 }