diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-09-15 11:41:39 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-09-15 11:41:39 +0200 |
| commit | 3bb0aefa38c27221114a2db749d2eaa1a9df0336 (patch) | |
| tree | 022a172278d54a35ae464ecd3fc8a19ab6231bf9 /src/main/java/com/c2kernel/process/Bootstrap.java | |
| parent | 95b8f12336bbc46f8d3e7cd407b89911aba8d2c5 (diff) | |
Add trim calls to ObjectProperties.getString() to discard any extra
whitespace around the values. Fixes #165
Remove old Gateway.getProperty methods - there should be no deprecated
methods in the 3.0 release
Move all getProperty() calls to getString or other so they will be
trimmed.
Introduce ObjectProperties.getInstances to create ArrayLists of objects
from comma-separated class name lists.
Diffstat (limited to 'src/main/java/com/c2kernel/process/Bootstrap.java')
| -rw-r--r-- | src/main/java/com/c2kernel/process/Bootstrap.java | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java index 3b61ad3..0f06616 100644 --- a/src/main/java/com/c2kernel/process/Bootstrap.java +++ b/src/main/java/com/c2kernel/process/Bootstrap.java @@ -224,21 +224,17 @@ public class Bootstrap private static ResourceImportHandler getHandler(String resType) throws Exception {
if (resHandlerCache.containsKey(resType))
return resHandlerCache.get(resType);
- ResourceImportHandler handler;
- Object handlerProp = Gateway.getProperties().get("ResourceImportHandler."+resType);
- if (handlerProp instanceof ResourceImportHandler)
- handler = (ResourceImportHandler)handlerProp;
- else if (handlerProp instanceof String) { //class name
+ ResourceImportHandler handler = null;
+ if (Gateway.getProperties().containsKey("ResourceImportHandler."+resType)) {
try {
- Class<?> handlerClass = Class.forName((String)handlerProp);
- handler = (ResourceImportHandler) handlerClass.newInstance();
- } catch (ClassNotFoundException e) {
- throw new Exception("Handler class "+handlerProp+" for importing "+resType+" resources not found");
- } catch (ClassCastException e) {
- throw new Exception(handlerProp+" for importing "+resType+" was not a ResourceImportHandler");
- }
+ handler = (ResourceImportHandler) Gateway.getProperties().getInstance("ResourceImportHandler."+resType);
+ } catch (Exception ex) {
+ Logger.error(ex);
+ Logger.error("Exception loading ResourceHandler for "+resType+". Using default.");
+ }
}
- else
+
+ if (handler == null)
handler = new DefaultResourceImportHandler(resType);
resHandlerCache.put(resType, handler);
@@ -327,7 +323,7 @@ public class Bootstrap */
public static void checkAdminAgents() throws Exception {
// check for administrative user
- String adminPassword = Gateway.getProperties().getProperty("AdminPassword", "admin12345");
+ String adminPassword = Gateway.getProperties().getString("AdminPassword", "admin12345");
// check for import user
checkAgent("system", adminPassword, "Admin", new UUID(0, 0), false);
@@ -340,7 +336,7 @@ public class Bootstrap public static void createServerItem() throws Exception {
LookupManager lookupManager = Gateway.getLookupManager();
- String serverName = Gateway.getProperties().getProperty("ItemServer.name");
+ String serverName = Gateway.getProperties().getString("ItemServer.name", InetAddress.getLocalHost().getHostName());
thisServerPath = new DomainPath("/servers/"+serverName);
ItemPath serverEntity;
try {
@@ -356,12 +352,12 @@ public class Bootstrap Gateway.getStorage().put(serverEntity, new Property("Name", serverName, false), null);
Gateway.getStorage().put(serverEntity, new Property("Type", "Server", false), null);
Gateway.getStorage().put(serverEntity, new Property("KernelVersion", Gateway.getKernelVersion(), true), null);
- if (Gateway.getProperties().getProperty("ItemServer.Proxy.port") != null)
- Gateway.getStorage().put(serverEntity,
- new Property("ProxyPort", Gateway.getProperties().getProperty("ItemServer.Proxy.port"), false), null);
+ int proxyPort = Gateway.getProperties().getInt("ItemServer.Proxy.port", 1553);
+ Gateway.getStorage().put(serverEntity,
+ new Property("ProxyPort", String.valueOf(proxyPort), false), null);
Gateway.getStorage().put(serverEntity,
new Property("ConsolePort", String.valueOf(Logger.getConsolePort()), true), null);
- Gateway.getProxyManager().connectToProxyServer(Gateway.getProperties().getProperty("ItemServer.name"), Gateway.getProperties().getInt("ItemServer.Proxy.port"));
+ Gateway.getProxyManager().connectToProxyServer(serverName, proxyPort);
}
|
