summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2006-12-11 14:58:33 +0000
committerDwayne Boone <dwayne@zeroc.com>2006-12-11 14:58:33 +0000
commit88a8137d50e3a7fac4b20fc2e82ee8e005f54fd5 (patch)
tree1a67611fe4ebfe3fe8bddfcaa5787660aaf5b2ea /java/src
parentFix (diff)
downloadice-88a8137d50e3a7fac4b20fc2e82ee8e005f54fd5.tar.bz2
ice-88a8137d50e3a7fac4b20fc2e82ee8e005f54fd5.tar.xz
ice-88a8137d50e3a7fac4b20fc2e82ee8e005f54fd5.zip
Added LoggerPlugin
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Ice/LoggerFactory.java15
-rw-r--r--java/src/Ice/PluginManagerI.java106
-rw-r--r--java/src/IceInternal/Instance.java5
-rw-r--r--java/src/IceInternal/PropertyNames.java3
4 files changed, 100 insertions, 29 deletions
diff --git a/java/src/Ice/LoggerFactory.java b/java/src/Ice/LoggerFactory.java
new file mode 100644
index 00000000000..e725638e041
--- /dev/null
+++ b/java/src/Ice/LoggerFactory.java
@@ -0,0 +1,15 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package Ice;
+
+public interface LoggerFactory
+{
+ Logger create(Communicator communicator, String[] args);
+}
diff --git a/java/src/Ice/PluginManagerI.java b/java/src/Ice/PluginManagerI.java
index d0583e7b192..56d9ea989d4 100644
--- a/java/src/Ice/PluginManagerI.java
+++ b/java/src/Ice/PluginManagerI.java
@@ -111,6 +111,7 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag
p.destroy();
}
+ _logger = null;
_communicator = null;
}
}
@@ -159,7 +160,7 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag
if(plugins.containsKey(key))
{
final String value = (String)plugins.get(key);
- loadPlugin(names[i], value, cmdArgs);
+ loadPlugin(names[i], value, cmdArgs, false);
plugins.remove(key);
}
else
@@ -180,10 +181,19 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag
java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
String name = ((String)entry.getKey()).substring(prefix.length());
String value = (String)entry.getValue();
- loadPlugin(name, value, cmdArgs);
+ loadPlugin(name, value, cmdArgs, false);
}
//
+ // Check for a Logger Plugin
+ //
+ String loggerStr = properties.getProperty("Ice.LoggerPlugin");
+ if(loggerStr.length() != 0)
+ {
+ loadPlugin("Logger", loggerStr, cmdArgs, true);
+ }
+
+ //
// An application can set Ice.InitPlugins=0 if it wants to postpone
// initialization until after it has interacted directly with the
// plugins.
@@ -195,7 +205,7 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag
}
private void
- loadPlugin(String name, String pluginSpec, StringSeqHolder cmdArgs)
+ loadPlugin(String name, String pluginSpec, StringSeqHolder cmdArgs, boolean isLogger)
{
assert(_communicator != null);
@@ -236,19 +246,28 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag
//
// Instantiate the class.
//
- PluginFactory factory = null;
+ PluginFactory pluginFactory = null;
+ LoggerFactory loggerFactory = null;
try
{
Class c = Class.forName(className);
java.lang.Object obj = c.newInstance();
try
{
- factory = (PluginFactory)obj;
+ if(isLogger)
+ {
+ loggerFactory = (LoggerFactory)obj;
+ }
+ else
+ {
+ pluginFactory = (PluginFactory)obj;
+ }
}
catch(ClassCastException ex)
{
PluginInitializationException e = new PluginInitializationException();
- e.reason = "class " + className + " does not implement Ice.PluginFactory";
+ e.reason = "class " + className + " does not implement " +
+ (isLogger ? "Ice.LoggerFactory" : "Ice.PluginFactory");
e.initCause(ex);
throw e;
}
@@ -278,36 +297,67 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag
//
// Invoke the factory.
//
- Plugin plugin = null;
- try
- {
- plugin = factory.create(_communicator, name, args);
- }
- catch(PluginInitializationException ex)
- {
- throw ex;
- }
- catch(Throwable ex)
- {
- PluginInitializationException e = new PluginInitializationException();
- e.reason = "exception in factory " + className;
- e.initCause(ex);
- throw e;
- }
+ if(isLogger)
+ {
+ try
+ {
+ _logger = loggerFactory.create(_communicator, args);
+ }
+ catch(Throwable ex)
+ {
+ PluginInitializationException e = new PluginInitializationException();
+ e.reason = "exception in factory " + className;
+ e.initCause(ex);
+ throw e;
+ }
- if(plugin == null)
+ if(_logger == null)
+ {
+ PluginInitializationException e = new PluginInitializationException();
+ e.reason = "failure in factory " + className;
+ throw e;
+ }
+ }
+ else
{
- PluginInitializationException e = new PluginInitializationException();
- e.reason = "failure in factory " + className;
- throw e;
+ Plugin plugin = null;
+ try
+ {
+ plugin = pluginFactory.create(_communicator, name, args);
+ }
+ catch(PluginInitializationException ex)
+ {
+ throw ex;
+ }
+ catch(Throwable ex)
+ {
+ PluginInitializationException e = new PluginInitializationException();
+ e.reason = "exception in factory " + className;
+ e.initCause(ex);
+ throw e;
+ }
+
+ if(plugin == null)
+ {
+ PluginInitializationException e = new PluginInitializationException();
+ e.reason = "failure in factory " + className;
+ throw e;
+ }
+
+ _plugins.put(name, plugin);
+ _initOrder.add(plugin);
}
+ }
- _plugins.put(name, plugin);
- _initOrder.add(plugin);
+ public Logger
+ getLogger()
+ {
+ return _logger;
}
private Communicator _communicator;
private java.util.HashMap _plugins = new java.util.HashMap();
private java.util.ArrayList _initOrder = new java.util.ArrayList();
+ private Logger _logger = null;
private boolean _initialized;
}
diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java
index a3fc3e9ba1e..a2a82c6d21b 100644
--- a/java/src/IceInternal/Instance.java
+++ b/java/src/IceInternal/Instance.java
@@ -476,6 +476,11 @@ public final class Instance
//
Ice.PluginManagerI pluginManagerImpl = (Ice.PluginManagerI)_pluginManager;
pluginManagerImpl.loadPlugins(args);
+ Ice.Logger logger = pluginManagerImpl.getLogger();
+ if(logger != null)
+ {
+ _initData.logger = logger;
+ }
//
// Get default router and locator proxies. Don't move this
diff --git a/java/src/IceInternal/PropertyNames.java b/java/src/IceInternal/PropertyNames.java
index 67c53e4e10d..5fa671f2164 100644
--- a/java/src/IceInternal/PropertyNames.java
+++ b/java/src/IceInternal/PropertyNames.java
@@ -7,7 +7,7 @@
//
// **********************************************************************
-// Generated by makeprops.py from file `./config/PropertyNames.def', Mon Dec 4 13:26:07 2006
+// Generated by makeprops.py from file `./config/PropertyNames.def', Mon Dec 11 11:13:50 2006
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
@@ -47,6 +47,7 @@ public final class PropertyNames
"^Ice\\.GC\\.Interval$",
"^Ice\\.ImplicitContext$",
"^Ice\\.InitPlugins$",
+ "^Ice\\.LoggerPlugin$",
"^Ice\\.MessageSizeMax$",
"^Ice\\.MonitorConnections$",
"^Ice\\.Nohup$",