01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.plugin;
18:
19: import java.util.ArrayList;
20: import java.util.List;
21:
22: import org.kuali.rice.config.Config;
23: import org.kuali.rice.core.Core;
24:
25: import edu.iu.uis.eden.EdenConstants;
26: import edu.iu.uis.eden.util.Utilities;
27:
28: /**
29: * A factory for creating {@link PluginRegistry} instances based on the configured
30: * client protocol of the application.
31: *
32: * @see PluginRegistry
33: *
34: * @author ewestfal
35: */
36: public class PluginRegistryFactory {
37:
38: public PluginRegistry createPluginRegistry() {
39: String clientProtocol = Core.getCurrentContextConfig()
40: .getClientProtocol();
41: if (EdenConstants.EMBEDDED_CLIENT_PROTOCOL
42: .equals(clientProtocol)) {
43: return new EmbeddedPluginRegistry();
44: } else if (EdenConstants.WEBSERVICE_CLIENT_PROTOCOL
45: .equals(clientProtocol)) {
46: return new WebservicePluginRegistry();
47: } else if (EdenConstants.RMI_CLIENT_PROTOCOL
48: .equals(clientProtocol)) {
49: return new RMIPluginRegistry();
50: } else {
51: ServerPluginRegistry registry = new ServerPluginRegistry();
52: String institutionalPluginDir = Core
53: .getCurrentContextConfig().getProperty(
54: Config.INSTITUTIONAL_PLUGIN_DIR);
55: String pluginDir = Core.getCurrentContextConfig()
56: .getProperty(Config.PLUGIN_DIR);
57: List<String> pluginDirectories = new ArrayList<String>();
58: // TODO: maybe ensure that if these directories are the same, that
59: // only one gets through
60: if (!Utilities.isEmpty(institutionalPluginDir)) {
61: pluginDirectories.add(institutionalPluginDir);
62: }
63: if (!Utilities.isEmpty(pluginDir)) {
64: pluginDirectories.add(pluginDir);
65: }
66: registry.setPluginDirectories(pluginDirectories);
67: return registry;
68: }
69: }
70:
71: }
|