Author: pier
Date: Sun Nov 7 19:23:59 2004
New Revision: 56895
Modified:
cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Deployer.java
cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/plugins/Utilities.java
Log:
Small changes for logging
Modified:
cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Deployer.java
==============================================================================
---
cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Deployer.java
(original)
+++
cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/deployment/Deployer.java
Sun Nov 7 19:23:59 2004
@@ -12,6 +12,7 @@
*
===============================================================================
*/
package org.apache.cocoon.kernel.deployment;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URL;
@@ -43,6 +44,9 @@
*/
public class Deployer implements StartupKernel {
+ /** <p>The name returned when the kernel is the caller.</p>*/
+ public static final String KERNEL_NAME = "kernel";
+
/** <p>An empty array of [EMAIL PROTECTED] Object}s to be using in
reflection.</p> */
private static final Object NULL[] = new Object[0];
@@ -195,6 +199,9 @@
thread.setContextClassLoader(instance);
try {
if (destructor != null) destructor.invoke(component, NULL);
+ } catch (InvocationTargetException exception) {
+ Throwable t = exception.getCause();
+ this.logger.error("Exception destroying singleton: " +
current, t);
} catch (Throwable t) {
this.logger.error("Exception destroying singleton: " +
current, t);
}
@@ -273,8 +280,14 @@
if (name == null) throw new NullPointerException("Null name");
if (inst == null) throw new NullPointerException("Null instance");
if (conf == null) throw new NullPointerException("Null config");
+ if (KERNEL_NAME.equals(name)) {
+ String message = "Invalid instance name \"" + name + "\"";
+ throw new IllegalArgumentException(message);
+ }
+
if (this.wrappers.get(name) != null) {
- throw new DeployerException("Instance \"" + name + "\" aready
added");
+ String message = "Duplicate instance with name \"" + name + "\"";
+ throw new DeployerException(message);
} else {
this.wrappers.put(name, new Wrapper(inst, conf));
}
@@ -355,6 +368,9 @@
try {
/* Non singletons will never have an initializer method set */
if (initializer != null) initializer.invoke(component, NULL);
+ } catch (InvocationTargetException exception) {
+ Throwable t = exception.getCause();
+ throw new DeployerException("Can't initialize component " + name,
t);
} catch (Throwable t) {
throw new DeployerException("Can't initialize component " + name,
t);
} finally {
Modified:
cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/plugins/Utilities.java
==============================================================================
---
cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/plugins/Utilities.java
(original)
+++
cocoon/whiteboard/kernel/sources/runtime/org/apache/cocoon/kernel/plugins/Utilities.java
Sun Nov 7 19:23:59 2004
@@ -12,7 +12,9 @@
*
===============================================================================
*/
package org.apache.cocoon.kernel.plugins;
+import org.apache.cocoon.kernel.deployment.Deployer;
import org.apache.cocoon.kernel.deployment.Instance;
+import org.apache.cocoon.kernel.startup.KernelLoader;
/**
* <p>Shared kernel [EMAIL PROTECTED] Plugin} uptilities.</p>
@@ -34,23 +36,23 @@
/**
* <p>Retrieve the block instance calling this method.</p>
*/
- public static Instance getCaller() {
+ public static String getCallerName() {
+
Class context[] = Utilities.instance.getClassContext();
if (context == null) return(null);
+
for (int x = 0; x < context.length; x++) {
if (context[x].getClassLoader() instanceof Instance) {
- return((Instance)(context[x].getClassLoader()));
+ return ((Instance)(context[x].getClassLoader())).getName();
+ }
+ }
+
+ for (int x = 0; x < context.length; x++) {
+ if (context[x].getClassLoader() instanceof KernelLoader) {
+ return(Deployer.KERNEL_NAME);
}
}
- return(null);
- }
- /**
- * <p>Retrieve the block instance calling this method.</p>
- */
- public static String getCallerName() {
- Instance instance = Utilities.getCaller();
- if (instance != null) return (instance.getName());
return(null);
}
}