FELIX-4045 Chain Exceptions when possible
* Added some Throwable parameters in Exception sub classes to enable chaining
* Tracked most of the missing chained call in runtime project
* Chaining has not been changed in IT modules
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1478410 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/handler/temporal/temporal-dependency-handler/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalHandler.java b/ipojo/handler/temporal/temporal-dependency-handler/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalHandler.java
index 4dd9a33..14e66da 100644
--- a/ipojo/handler/temporal/temporal-dependency-handler/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalHandler.java
+++ b/ipojo/handler/temporal/temporal-dependency-handler/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalHandler.java
@@ -195,7 +195,7 @@
try {
filter = getInstanceManager().getContext().createFilter(fil);
} catch (InvalidSyntaxException e) {
- throw new ConfigurationException("A requirement filter is invalid : " + filter + " - " + e.getMessage());
+ throw new ConfigurationException("A requirement filter is invalid : " + filter, e);
}
}
diff --git a/ipojo/runtime/api/src/main/java/org/apache/felix/ipojo/api/PrimitiveComponentType.java b/ipojo/runtime/api/src/main/java/org/apache/felix/ipojo/api/PrimitiveComponentType.java
index 33f71fc..bef04d1 100644
--- a/ipojo/runtime/api/src/main/java/org/apache/felix/ipojo/api/PrimitiveComponentType.java
+++ b/ipojo/runtime/api/src/main/java/org/apache/felix/ipojo/api/PrimitiveComponentType.java
@@ -448,7 +448,7 @@
}
m_factory.start();
} catch (ConfigurationException e) {
- throw new IllegalStateException("An exception occurs during factory initialization : " + e.getMessage());
+ throw new IllegalStateException("An exception occurs during factory initialization", e);
}
}
@@ -466,7 +466,7 @@
m_alreadyManipulated = newclazz.length == array.length;
return newclazz;
} catch (IOException e) {
- throw new IllegalStateException("An exception occurs during implementation class manipulation : " + e.getMessage());
+ throw new IllegalStateException("An exception occurs during implementation class manipulation", e);
}
}
diff --git a/ipojo/runtime/api/src/main/java/org/apache/felix/ipojo/api/composite/CompositeComponentType.java b/ipojo/runtime/api/src/main/java/org/apache/felix/ipojo/api/composite/CompositeComponentType.java
index dd43dd2..9fc3f26 100644
--- a/ipojo/runtime/api/src/main/java/org/apache/felix/ipojo/api/composite/CompositeComponentType.java
+++ b/ipojo/runtime/api/src/main/java/org/apache/felix/ipojo/api/composite/CompositeComponentType.java
@@ -318,7 +318,7 @@
m_factory = new CompositeFactory(m_context, m_metadata);
m_factory.start();
} catch (ConfigurationException e) {
- throw new IllegalStateException("An exception occurs during factory initialization : " + e.getMessage());
+ throw new IllegalStateException("An exception occurs during factory initialization", e);
}
}
diff --git a/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandler.java b/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandler.java
index 696217c..f7fe811 100644
--- a/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandler.java
+++ b/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandler.java
@@ -254,7 +254,7 @@
conf = parseInstance(instances[i]);
} catch (ParseException e) {
error("An instance cannot be parsed correctly", e);
- throw new ConfigurationException("An instance cannot be parsed correctly : " + e.getMessage());
+ throw new ConfigurationException("An instance cannot be parsed correctly", e);
}
Properties instanceConfiguration = new Properties();
diff --git a/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceDependencyHandler.java b/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceDependencyHandler.java
index e1686d4..5e30b46 100644
--- a/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceDependencyHandler.java
+++ b/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceDependencyHandler.java
@@ -107,7 +107,7 @@
try {
fil = getCompositeManager().getGlobalContext().createFilter(filter);
} catch (InvalidSyntaxException e) {
- throw new ConfigurationException("Malformed filter " + filter + " : " + e.getMessage());
+ throw new ConfigurationException("Malformed filter " + filter, e);
}
Properties prop = new Properties();
@@ -116,7 +116,7 @@
try {
InstanceHandler.parseProperty(props[k], prop);
} catch (ParseException e) {
- throw new ConfigurationException("An instance configuration is invalid : " + e.getMessage());
+ throw new ConfigurationException("An instance configuration is invalid", e);
}
}
@@ -201,7 +201,7 @@
try {
fil = getCompositeManager().getGlobalContext().createFilter(filter);
} catch (InvalidSyntaxException e) {
- throw new ConfigurationException("A required filter " + filter + " is malformed : " + e.getMessage());
+ throw new ConfigurationException("A required filter " + filter + " is malformed", e);
}
}
diff --git a/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionException.java b/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionException.java
index 9423d3c..801b595 100644
--- a/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionException.java
+++ b/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionException.java
@@ -32,10 +32,13 @@
/**
* Constructor.
- * @param message : a message.
+ * @param message a message.
*/
public CompositionException(String message) {
- super(message);
+ this(message, null);
}
+ public CompositionException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedService.java b/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedService.java
index 6b08b25..28660ae 100644
--- a/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedService.java
+++ b/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedService.java
@@ -125,9 +125,9 @@
// Create the exports
m_exports = new ServiceExporter(spec, filter, false, false, null, DependencyModel.DYNAMIC_BINDING_POLICY, m_scope, m_context, this, m_manager);
} catch (InvalidSyntaxException e) {
- throw new CompositionException("A provided service filter is invalid : " + e.getMessage());
+ throw new CompositionException("A provided service filter is invalid", e);
} catch (ConfigurationException e) {
- throw new CompositionException("The class " + m_composition.getSpecificationMetadata().getName() + " cannot be loaded : " + e.getMessage());
+ throw new CompositionException("The class " + m_composition.getSpecificationMetadata().getName() + " cannot be loaded", e);
}
}
@@ -216,11 +216,11 @@
try {
m_instance = m_factory.createComponentInstance(props, m_manager.getServiceContext());
} catch (UnacceptableConfiguration e) {
- throw new IllegalStateException("Cannot create the service implementation : " + e.getMessage());
+ throw new IllegalStateException("Cannot create the service implementation", e);
} catch (MissingHandlerException e) {
- throw new IllegalStateException("Cannot create the service implementation : " + e.getMessage());
+ throw new IllegalStateException("Cannot create the service implementation", e);
} catch (ConfigurationException e) {
- throw new IllegalStateException("Cannot create the service implementation : " + e.getMessage());
+ throw new IllegalStateException("Cannot create the service implementation", e);
}
} else {
// We have to reconfigure the instance in order to inject up to date glue component instance.
diff --git a/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedServiceHandler.java b/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedServiceHandler.java
index 2c82005..e448912 100644
--- a/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedServiceHandler.java
+++ b/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedServiceHandler.java
@@ -157,7 +157,7 @@
try {
fil = m_context.createFilter(filter);
} catch (InvalidSyntaxException e) {
- throw new ConfigurationException("An exporter filter is invalid " + filter + " : " + e.getMessage());
+ throw new ConfigurationException("An exporter filter is invalid " + filter, e);
}
Comparator cmp = DependencyModel.getComparator(provides[i], m_context);
@@ -350,16 +350,16 @@
return; // No specification field
} catch (ClassNotFoundException e) {
error("[" + getCompositeManager().getInstanceName() + "] The service specification " + svc.getSpecification() + " cannot be load");
- throw new CompositionException("The service specification " + svc.getSpecification() + " cannot be load : " + e.getMessage());
+ throw new CompositionException("The service specification " + svc.getSpecification() + " cannot be loaded", e);
} catch (IllegalArgumentException e) {
error("[" + getCompositeManager().getInstanceName() + "] The field 'specification' of the service specification " + svc.getSpecification() + " is not accessible : " + e.getMessage());
- throw new CompositionException("The field 'specification' of the service specification " + svc.getSpecification() + " is not accessible : " + e.getMessage());
+ throw new CompositionException("The field 'specification' of the service specification " + svc.getSpecification() + " is not accessible", e);
} catch (IllegalAccessException e) {
error("[" + getCompositeManager().getInstanceName() + "] The field 'specification' of the service specification " + svc.getSpecification() + " is not accessible : " + e.getMessage());
- throw new CompositionException("The field 'specification' of the service specification " + svc.getSpecification() + " is not accessible : " + e.getMessage());
+ throw new CompositionException("The field 'specification' of the service specification " + svc.getSpecification() + " is not accessible", e);
} catch (ParseException e) {
error("[" + getCompositeManager().getInstanceName() + "] The field 'specification' of the service specification " + svc.getSpecification() + " does not contain a valid String : " + e.getMessage());
- throw new CompositionException("The field 'specification' of the service specification " + svc.getSpecification() + " does not contain a valid String : " + e.getMessage());
+ throw new CompositionException("The field 'specification' of the service specification " + svc.getSpecification() + " does not contain a valid String", e);
}
}
@@ -428,7 +428,7 @@
handlerManager.init(getCompositeManager(), new Element("composite", ""), new Properties());
} catch (ConfigurationException e) {
error("Internal error : cannot configure the Import Handler : " + e.getMessage());
- throw new CompositionException("Internal error : cannot configure the Import Handler : " + e.getMessage());
+ throw new CompositionException("Internal error : cannot configure the Import Handler", e);
}
handler = (ServiceDependencyHandler) handlerManager.getHandler();
getCompositeManager().addCompositeHandler(handlerManager);
@@ -447,14 +447,14 @@
try {
fil = getCompositeManager().getGlobalContext().createFilter(filter);
} catch (InvalidSyntaxException e) {
- throw new CompositionException("A required filter " + filter + " is malformed : " + e.getMessage());
+ throw new CompositionException("A required filter " + filter + " is malformed", e);
}
Class specToImport = null;
try {
specToImport = getCompositeManager().getGlobalContext().getBundle().loadClass(spec);
} catch (ClassNotFoundException e) {
- throw new CompositionException("A required specification cannot be loaded : " + spec);
+ throw new CompositionException("A required specification cannot be loaded : " + spec, e);
}
ServiceImporter importer = new ServiceImporter(specToImport, fil, agg, opt, null, DependencyModel.DYNAMIC_BINDING_POLICY, context, null, handler);
diff --git a/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/util/SourceManager.java b/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/util/SourceManager.java
index d7f227a..b04b2df 100644
--- a/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/util/SourceManager.java
+++ b/ipojo/runtime/composite/src/main/java/org/apache/felix/ipojo/composite/util/SourceManager.java
@@ -141,7 +141,7 @@
try {
m_dependency.setFilter(m_context.createFilter(filter));
} catch (InvalidSyntaxException e) {
- throw new IllegalStateException("A context filter is invalid : " + filter);
+ throw new IllegalStateException("A context filter is invalid : " + filter, e);
}
}
}
@@ -312,7 +312,7 @@
Filter filter = countext.createFilter(fil);
m_tracker = new Tracker(countext, filter, this);
} catch (InvalidSyntaxException e) {
- throw new ConfigurationException("A Context source filter is invalid " + fil + " : " + e.getMessage());
+ throw new ConfigurationException("A Context source filter is invalid " + fil, e);
}
}
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
index efacda5..11d3711 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
@@ -185,7 +185,7 @@
} catch (Throwable e) { // All others exception are handled here.
instance.dispose();
m_logger.log(Logger.ERROR, e.getMessage(), e);
- throw new ConfigurationException(e.getMessage());
+ throw new ConfigurationException(e.getMessage(), e);
}
}
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/ConfigurationException.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/ConfigurationException.java
index 0bed6f4..4e34f74 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/ConfigurationException.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/ConfigurationException.java
@@ -39,24 +39,32 @@
/**
* Creates a new configuration exception.
- * @param mes the error message
- * @param typ the component type
+ * @param message the error message
* @see Exception#Exception(String)
*/
- ConfigurationException(String mes, String typ) {
- super(mes);
- m_type = typ;
+ public ConfigurationException(String message) {
+ this(message, (String) null);
}
-
+
/**
* Creates a new configuration exception.
* @param mes the error message
+ * @param type the component type
* @see Exception#Exception(String)
*/
- public ConfigurationException(String mes) {
- super(mes);
+ public ConfigurationException(String mes, String type) {
+ this(mes, null, type);
}
-
+
+ public ConfigurationException(String message, Throwable cause) {
+ this(message, cause, null);
+ }
+
+ public ConfigurationException(String message, Throwable cause, String type) {
+ super(message, cause);
+ m_type = type;
+ }
+
/**
* Gets the error message.
* @return the error message.
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/HandlerManagerFactory.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/HandlerManagerFactory.java
index f8c1ed0..e94e843 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/HandlerManagerFactory.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/HandlerManagerFactory.java
@@ -63,7 +63,7 @@
// Get the name
m_factoryName = metadata.getAttribute("name");
- if (m_factoryName == null) { throw new ConfigurationException("An Handler needs a name"); }
+ if (m_factoryName == null) { throw new ConfigurationException("A Handler needs a name"); }
// Get the type
String type = metadata.getAttribute("type");
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
index a5b34a2..2d08991 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
@@ -266,7 +266,7 @@
m_logger.log(Logger.ERROR, "The configuration is not acceptable : " + e.getMessage());
throw new UnacceptableConfiguration("The configuration "
+ configuration + " is not acceptable for " + m_factoryName
- + ": " + e.getMessage());
+ , e);
}
// Find name in the configuration
@@ -307,7 +307,7 @@
} catch (ConfigurationException e) {
INSTANCE_NAME.remove(name);
m_logger.log(Logger.ERROR, e.getMessage());
- throw new ConfigurationException(e.getMessage(), m_factoryName);
+ throw new ConfigurationException(e.getMessage(), e, m_factoryName);
}
@@ -673,13 +673,13 @@
createComponentInstance(properties);
} catch (UnacceptableConfiguration e) {
m_logger.log(Logger.ERROR, "The configuration is not acceptable : " + e.getMessage());
- throw new org.osgi.service.cm.ConfigurationException(properties.toString(), e.getMessage());
+ throw new org.osgi.service.cm.ConfigurationException(properties.toString(), e.getMessage(), e);
} catch (MissingHandlerException e) {
m_logger.log(Logger.ERROR, "Handler not available : " + e.getMessage());
- throw new org.osgi.service.cm.ConfigurationException(properties.toString(), e.getMessage());
+ throw new org.osgi.service.cm.ConfigurationException(properties.toString(), e.getMessage(), e);
} catch (ConfigurationException e) {
m_logger.log(Logger.ERROR, "The Component Type metadata are not correct : " + e.getMessage());
- throw new org.osgi.service.cm.ConfigurationException(properties.toString(), e.getMessage());
+ throw new org.osgi.service.cm.ConfigurationException(properties.toString(), e.getMessage(), e);
}
} else {
try {
@@ -687,10 +687,10 @@
reconfigure(properties); // re-configure the component
} catch (UnacceptableConfiguration e) {
m_logger.log(Logger.ERROR, "The configuration is not acceptable : " + e.getMessage());
- throw new org.osgi.service.cm.ConfigurationException(properties.toString(), e.getMessage());
+ throw new org.osgi.service.cm.ConfigurationException(properties.toString(), e.getMessage(), e);
} catch (MissingHandlerException e) {
m_logger.log(Logger.ERROR, "The factory is not valid, at least one handler is missing : " + e.getMessage());
- throw new org.osgi.service.cm.ConfigurationException(properties.toString(), e.getMessage());
+ throw new org.osgi.service.cm.ConfigurationException(properties.toString(), e.getMessage(), e);
}
}
}
@@ -745,7 +745,7 @@
((Pojo) handler).getComponentInstance().dispose();
m_logger.log(Logger.ERROR, e.getMessage());
stop();
- throw new IllegalStateException(e.getMessage());
+ throw new IllegalStateException(e);
}
}
}
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
index 23f8c31..3cabe83 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
@@ -739,7 +739,7 @@
m_logger.log(Logger.ERROR,
"[" + m_name + "] createInstance -> The POJO constructor is not accessible : " + e.getMessage(), e);
stop();
- throw new RuntimeException("Cannot create a POJO instance, the POJO constructor is not accessible : " + e.getMessage());
+ throw new RuntimeException("Cannot create a POJO instance, the POJO constructor is not accessible", e);
} catch (SecurityException e) {
m_logger.log(
Logger.ERROR,
@@ -748,7 +748,7 @@
+ "] createInstance -> The POJO constructor is not accessible (security reason) : "
+ e.getMessage(), e);
stop();
- throw new RuntimeException("Cannot create a POJO instance, the POJO constructor is not accessible : " + e.getMessage());
+ throw new RuntimeException("Cannot create a POJO instance, the POJO constructor is not accessible", e);
} catch (InvocationTargetException e) {
m_logger.log(
Logger.ERROR,
@@ -758,18 +758,18 @@
+ e.getTargetException().getMessage(), e.getTargetException());
onError(null, m_className, e.getTargetException());
stop();
- throw new RuntimeException("Cannot create a POJO instance, the POJO constructor has thrown an exception: " + e.getTargetException().getMessage());
+ throw new RuntimeException("Cannot create a POJO instance, the POJO constructor has thrown an exception", e.getTargetException());
} catch (NoSuchMethodException e) {
m_logger.log(Logger.ERROR,
"[" + m_name + "] createInstance -> Cannot invoke the constructor (method not found) : " + e.getMessage(), e);
stop();
- throw new RuntimeException("Cannot create a POJO instance, the POJO constructor cannot be found : " + e.getMessage());
+ throw new RuntimeException("Cannot create a POJO instance, the POJO constructor cannot be found", e);
} catch (Throwable e) {
// Catch every other possible error and runtime exception.
m_logger.log(Logger.ERROR,
"[" + m_name + "] createInstance -> The POJO constructor invocation failed : " + e.getMessage(), e);
stop();
- throw new RuntimeException("Cannot create a POJO instance, the POJO constructor invocation has thrown an exception : " + e.getMessage());
+ throw new RuntimeException("Cannot create a POJO instance, the POJO constructor invocation has thrown an exception", e);
}
} else {
try {
@@ -803,7 +803,7 @@
+ "] createInstance -> Cannot invoke the factory-method (method not found) : "
+ e2.getMessage(), e2);
stop();
- throw new RuntimeException("Cannot create a POJO instance, the factory-method cannot be found : " + e2.getMessage());
+ throw new RuntimeException("Cannot create a POJO instance, the factory-method cannot be found", e2);
}
}
@@ -846,13 +846,13 @@
"[" + m_name + "] createInstance -> The factory-method throws an exception : " + e.getTargetException(), e.getTargetException());
onError(null, m_className, e.getTargetException());
stop();
- throw new RuntimeException("Cannot create a POJO instance, the factory-method has thrown an exception: " + e.getTargetException().getMessage());
+ throw new RuntimeException("Cannot create a POJO instance, the factory-method has thrown an exception", e.getTargetException());
} catch (Throwable e) {
// Catch every other possible error and runtime exception.
m_logger.log(Logger.ERROR,
"[" + m_name + "] createInstance -> The factory-method invocation failed : " + e.getMessage(), e);
stop();
- throw new RuntimeException("Cannot create a POJO instance, the factory-method invocation has thrown an exception : " + e.getMessage());
+ throw new RuntimeException("Cannot create a POJO instance, the factory-method invocation has thrown an exception", e);
}
}
return instance;
@@ -977,7 +977,7 @@
setIM.invoke(obj, new Object[] {this});
} catch (Exception e) {
// If anything wrong happened...
- throw new RuntimeException("Cannot attach the injected object with the container of " + m_name + " : " + e.getMessage());
+ throw new RuntimeException("Cannot attach the injected object with the container of " + m_name, e);
}
// Call createInstance on Handlers :
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/UnacceptableConfiguration.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/UnacceptableConfiguration.java
index dab2c99..63f0f13 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/UnacceptableConfiguration.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/UnacceptableConfiguration.java
@@ -35,10 +35,13 @@
/**
* Creates an UnacceptableConfiguration.
- * @param message : message about the error.
+ * @param message message about the error.
*/
public UnacceptableConfiguration(String message) {
- super(message);
+ this(message, null);
}
+ public UnacceptableConfiguration(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
index eb28806..2a5fa3b 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
@@ -396,11 +396,9 @@
} catch (NoClassDefFoundError e) {
// A NoClassDefFoundError is thrown if the specification uses a class not accessible by the actual instance.
// It generally comes from a missing import.
- throw new IllegalStateException("Cannot create the Nullable object, a referenced class cannot be loaded: " + e.getMessage());
+ throw new IllegalStateException("Cannot create the Nullable object, a referenced class cannot be loaded", e);
} catch (Throwable e) { // Catch any other exception that can occurs
- throw new IllegalStateException(
- "Cannot create the Nullable object, an unexpected error occurs: "
- + e.getMessage());
+ throw new IllegalStateException("Cannot create the Nullable object, an unexpected error occurs", e);
}
return m_nullable;
@@ -423,13 +421,13 @@
Class clazz = getHandler().getInstanceManager().getContext().getBundle().loadClass(m_di);
m_nullable = clazz.newInstance();
} catch (IllegalAccessException e) {
- throw new IllegalStateException("Cannot load the default-implementation " + m_di + " : " + e.getMessage());
+ throw new IllegalStateException("Cannot load the default-implementation " + m_di, e);
} catch (InstantiationException e) {
- throw new IllegalStateException("Cannot load the default-implementation " + m_di + " : " + e.getMessage());
+ throw new IllegalStateException("Cannot load the default-implementation " + m_di, e);
} catch (ClassNotFoundException e) {
- throw new IllegalStateException("Cannot load the default-implementation " + m_di + " : " + e.getMessage());
+ throw new IllegalStateException("Cannot load the default-implementation " + m_di, e);
} catch (Throwable e) { // Catch any other exception
- throw new IllegalStateException("Cannot load the default-implementation (unexpected exception) " + m_di + " : " + e.getMessage());
+ throw new IllegalStateException("Cannot load the default-implementation (unexpected exception) " + m_di, e);
}
}
}
@@ -707,7 +705,7 @@
}
} catch (ArrayStoreException e) {
m_handler.error("Cannot create the array - Check that the bundle can access the service interface", e);
- throw new RuntimeException("Cannot create the array - Check that the bundle can access the service interface : " + e.getMessage());
+ throw new RuntimeException("Cannot create the array - Check that the bundle can access the service interface", e);
}
} else if (m_type == DependencyHandler.LIST) {
if (refs == null) {
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
index 1e5a71c..66d2ea3 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
@@ -38,6 +38,7 @@
import org.apache.felix.ipojo.parser.PojoMetadata;
import org.apache.felix.ipojo.util.DependencyModel;
import org.apache.felix.ipojo.util.DependencyStateListener;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
@@ -388,10 +389,12 @@
}
}
+ Bundle bundle = getInstanceManager().getContext().getBundle();
try {
- dep.setSpecification(getInstanceManager().getContext().getBundle().loadClass(className));
+ dep.setSpecification(bundle.loadClass(className));
} catch (ClassNotFoundException e) {
- throw new ConfigurationException("The required service interface cannot be loaded : " + e.getMessage());
+ throw new ConfigurationException("The required service interface (" + className
+ + ") cannot be loaded from bundle " + bundle.getBundleId(), e);
}
}
}
@@ -515,7 +518,7 @@
try {
fil = getInstanceManager().getContext().createFilter(filter);
} catch (InvalidSyntaxException e) {
- throw new ConfigurationException("A requirement filter is invalid : " + filter + " - " + e.getMessage());
+ throw new ConfigurationException("A requirement filter is invalid : " + filter, e);
}
}
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java
index 16f8e09..62580f8 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java
@@ -162,13 +162,13 @@
m_callbacks[i].call();
} catch (NoSuchMethodException e) {
error("[" + getInstanceManager().getInstanceName() + "] The callback method " + m_callbacks[i].getMethod() + " is not found");
- throw new IllegalStateException(e.getMessage());
+ throw new IllegalStateException(e);
} catch (IllegalAccessException e) {
error("[" + getInstanceManager().getInstanceName() + "] The callback method " + m_callbacks[i].getMethod() + " is not accessible");
- throw new IllegalStateException(e.getMessage());
+ throw new IllegalStateException(e);
} catch (InvocationTargetException e) {
error("[" + getInstanceManager().getInstanceName() + "] The callback method " + m_callbacks[i].getMethod() + " has thrown an exception : " + e.getTargetException().getMessage(), e.getTargetException());
- throw new IllegalStateException(e.getTargetException().getMessage());
+ throw new IllegalStateException(e.getTargetException());
}
}
}
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
index 084255d..ddea97b 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
@@ -133,7 +133,7 @@
throw new ConfigurationException("The custom creation policy class " + custom.getName() + " does not implement " + CreationStrategy.class.getName());
}
} catch (ClassNotFoundException e) {
- throw new ConfigurationException("The custom creation policy class " + strategy + " cannot be loaded " + e.getMessage());
+ throw new ConfigurationException("The custom creation policy class " + strategy + " cannot be loaded ", e);
}
@@ -335,13 +335,13 @@
} catch (NoSuchFieldException e) {
return true; // No specification field
} catch (ClassNotFoundException e) {
- throw new ConfigurationException("Service Providing: The service specification " + svc.getServiceSpecifications()[i] + " cannot be load");
+ throw new ConfigurationException("Service Providing: The service specification " + svc.getServiceSpecifications()[i] + " cannot be loaded", e);
} catch (IllegalArgumentException e) {
- throw new ConfigurationException("Service Providing: The field 'specification' of the service specification " + svc.getServiceSpecifications()[i] + " is not accessible : " + e.getMessage());
+ throw new ConfigurationException("Service Providing: The field 'specification' of the service specification " + svc.getServiceSpecifications()[i] + " is not accessible", e);
} catch (IllegalAccessException e) {
- throw new ConfigurationException("Service Providing: The field 'specification' of the service specification " + svc.getServiceSpecifications()[i] + " is not accessible : " + e.getMessage());
+ throw new ConfigurationException("Service Providing: The field 'specification' of the service specification " + svc.getServiceSpecifications()[i] + " is not accessible", e);
} catch (ParseException e) {
- throw new ConfigurationException("Service Providing: The field 'specification' of the service specification " + svc.getServiceSpecifications()[i] + " does not contain a valid String : " + e.getMessage());
+ throw new ConfigurationException("Service Providing: The field 'specification' of the service specification " + svc.getServiceSpecifications()[i] + " does not contain a valid String", e);
}
}
@@ -589,7 +589,7 @@
getLogger().log(Logger.INFO, "Collected interfaces from " + metadata.getAttribute("classname") + " : " + interfaces);
getLogger().log(Logger.INFO, "Collected super classes from " + metadata.getAttribute("classname") + " : " + parentClasses);
} catch (ClassNotFoundException e) {
- throw new ConfigurationException("An interface or parent class cannot be loaded : " + e.getMessage());
+ throw new ConfigurationException("An interface or parent class cannot be loaded", e);
}
String serviceSpecificationStr = provides[i].getAttribute("specifications");
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
index 7a47d1f..f8ee94c 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
@@ -969,11 +969,11 @@
Class cla = context.getBundle().loadClass(comp);
cmp = (Comparator) cla.newInstance();
} catch (ClassNotFoundException e) {
- throw new ConfigurationException("Cannot load a customized comparator : " + e.getMessage());
+ throw new ConfigurationException("Cannot load a customized comparator", e);
} catch (IllegalAccessException e) {
- throw new ConfigurationException("Cannot create a customized comparator : " + e.getMessage());
+ throw new ConfigurationException("Cannot create a customized comparator", e);
} catch (InstantiationException e) {
- throw new ConfigurationException("Cannot create a customized comparator : " + e.getMessage());
+ throw new ConfigurationException("Cannot create a customized comparator", e);
}
}
}
@@ -992,7 +992,7 @@
try {
spec = context.getBundle().loadClass(specification);
} catch (ClassNotFoundException e) {
- throw new ConfigurationException("A required specification cannot be loaded : " + specification);
+ throw new ConfigurationException("A required specification cannot be loaded : " + specification, e);
}
return spec;
}
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/Property.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/Property.java
index 13e2282..f4c87d8 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/Property.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/Property.java
@@ -225,11 +225,11 @@
try {
return context.getBundle().loadClass(type);
} catch (ClassNotFoundException e) {
- throw new ConfigurationException("Class not found exception in setValue on " + type + " : " + e.getMessage());
+ throw new ConfigurationException("Class not found exception in setValue on " + type, e);
} catch (SecurityException e) {
- throw new ConfigurationException("Security execption in setValue on " + type + " : " + e.getMessage());
+ throw new ConfigurationException("Security exception in setValue on " + type, e);
} catch (IllegalArgumentException e) {
- throw new ConfigurationException("Argument issue when calling the constructor of the type " + type);
+ throw new ConfigurationException("Argument issue when calling the constructor of the type " + type, e);
}
}
}
@@ -280,11 +280,11 @@
Object[] object = (Object[]) Array.newInstance(clazz, 0);
return object.getClass();
} catch (ClassNotFoundException e) {
- throw new ConfigurationException("Class not found exception in setValue on " + internalType);
+ throw new ConfigurationException("Class not found exception in setValue on " + internalType, e);
} catch (SecurityException e) {
- throw new ConfigurationException("Security Exception in setValue on " + internalType);
+ throw new ConfigurationException("Security Exception in setValue on " + internalType, e);
} catch (IllegalArgumentException e) {
- throw new ConfigurationException("Argument issue when calling the constructor of the type " + internalType);
+ throw new ConfigurationException("Argument issue when calling the constructor of the type " + internalType, e);
}
}
@@ -456,10 +456,10 @@
return valueOf.invoke(null, new String[] {strValue});
} catch (InvocationTargetException e) {
throw new ConfigurationException("Cannot create an enumerated value for " + type
- + " with " + strValue + " : " + e.getTargetException());
+ + " with " + strValue, e.getTargetException());
} catch (Exception e) {
throw new ConfigurationException("Cannot create an enumerated value for " + type
- + " with " + strValue + " : " + e.getMessage());
+ + " with " + strValue, e);
}
}
@@ -469,17 +469,17 @@
Constructor cst = type.getConstructor(new Class[] { String.class });
return cst.newInstance(new Object[] { strValue });
} catch (SecurityException e) {
- throw new ConfigurationException("Security exception during the creation of " + type + " : " + e.getMessage());
+ throw new ConfigurationException("Security exception during the creation of " + type, e);
} catch (NoSuchMethodException e) {
- throw new ConfigurationException("Constructor not found exception during the creation of " + type + " : " + e.getMessage());
+ throw new ConfigurationException("Constructor not found exception during the creation of " + type, e);
} catch (IllegalArgumentException e) {
- throw new ConfigurationException("Argument issue when calling the constructor of the type " + type);
+ throw new ConfigurationException("Argument issue when calling the constructor of the type " + type, e);
} catch (InstantiationException e) {
- throw new ConfigurationException("Instantiation problem " + type);
+ throw new ConfigurationException("Instantiation problem " + type, e);
} catch (IllegalAccessException e) {
- throw new ConfigurationException("Illegal Access " + type);
+ throw new ConfigurationException("Illegal Access " + type, e);
} catch (InvocationTargetException e) {
- throw new ConfigurationException("Invocation problem during the creation of " + type + " : " + e.getTargetException().getMessage());
+ throw new ConfigurationException("Invocation problem during the creation of " + type, e.getTargetException());
}
}
@@ -560,15 +560,15 @@
}
return object;
} catch (NoSuchMethodException e) {
- throw new ConfigurationException("Constructor not found exception in setValue on " + interntype.getName());
+ throw new ConfigurationException("Constructor not found exception in setValue on " + interntype.getName(), e);
} catch (IllegalArgumentException e) {
- throw new ConfigurationException("Argument issue when calling the constructor of the type " + interntype.getName());
+ throw new ConfigurationException("Argument issue when calling the constructor of the type " + interntype.getName(), e);
} catch (InstantiationException e) {
- throw new ConfigurationException("Instantiation problem " + interntype.getName());
+ throw new ConfigurationException("Instantiation problem " + interntype.getName(), e);
} catch (IllegalAccessException e) {
- throw new ConfigurationException("Illegal Access Exception in " + interntype.getName());
+ throw new ConfigurationException("Illegal Access Exception in " + interntype.getName(), e);
} catch (InvocationTargetException e) {
- throw new ConfigurationException("Invocation problem " + interntype.getName() + " : " + e.getTargetException().getMessage());
+ throw new ConfigurationException("Invocation problem " + interntype.getName(), e.getTargetException());
}
}
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/Tracker.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/Tracker.java
index 9f02c42..4080840 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/Tracker.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/Tracker.java
@@ -114,7 +114,7 @@
try {
this.m_filter = context.createFilter(m_listenerFilter);
} catch (InvalidSyntaxException e) { // we could only get this exception if the ServiceReference was invalid
- throw new IllegalArgumentException("unexpected InvalidSyntaxException: " + e.getMessage()); //$NON-NLS-1$
+ throw new IllegalArgumentException("unexpected InvalidSyntaxException", e); //$NON-NLS-1$
}
}
@@ -147,7 +147,7 @@
} catch (InvalidSyntaxException e) { // we could only get this exception
// if the clazz argument was
// malformed
- throw new IllegalArgumentException("unexpected InvalidSyntaxException: " + e.getMessage());
+ throw new IllegalArgumentException("unexpected InvalidSyntaxException", e);
}
}
@@ -203,7 +203,7 @@
// the initial
// references
} catch (InvalidSyntaxException e) {
- throw new IllegalStateException("unexpected InvalidSyntaxException: " + e.getMessage()); //$NON-NLS-1$
+ throw new IllegalStateException("unexpected InvalidSyntaxException", e); //$NON-NLS-1$
}
}
/* Call tracked outside of synchronized region */