Allows the early discovery of manipulation error and stops the factory as soon as detected.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@656371 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
index 2a28084..f68e1a9 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
@@ -67,12 +67,14 @@
/**
* Component Implementation Class Name.
* Immutable once set.
+ * This attribute is set during the construction of the factory.
*/
private String m_classname;
/**
* Manipulation Metadata of the internal POJO.
* Immutable once set.
+ * This attribute is set during the construction of the factory.
*/
private PojoMetadata m_manipulation;
@@ -114,6 +116,7 @@
public void check(Element element) throws ConfigurationException {
m_classname = element.getAttribute("classname");
if (m_classname == null) { throw new ConfigurationException("A component needs a class name : " + element); }
+ m_manipulation = new PojoMetadata(m_componentMetadata);
}
/**
@@ -339,15 +342,9 @@
/**
* Returns manipulation metadata of this component type.
- * The returned object is computed at the first call and then is cached.
* @return manipulation metadata of this component type.
*/
public PojoMetadata getPojoMetadata() {
- synchronized (this) {
- if (m_manipulation == null) {
- m_manipulation = new PojoMetadata(m_componentMetadata);
- }
- }
return m_manipulation;
}
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java
index ee8c6fc..a45d066 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java
@@ -18,6 +18,7 @@
*/
package org.apache.felix.ipojo.parser;
+import org.apache.felix.ipojo.ConfigurationException;
import org.apache.felix.ipojo.metadata.Element;
/**
@@ -54,9 +55,14 @@
* Manipulation Metadata object are created from component type metadata by
* parsing manipulation metadata.
* @param metadata : component type metadata
+ * @throws ConfigurationException : the manipulation metadata cannot be found
*/
- public PojoMetadata(Element metadata) {
- Element manip = metadata.getElements("manipulation", "")[0];
+ public PojoMetadata(Element metadata) throws ConfigurationException {
+ Element[] elems = metadata.getElements("manipulation", "");
+ if (elems == null) {
+ throw new ConfigurationException("The component " + metadata/*.getAttribute("classname")*/ + " has no manipulation metadata");
+ }
+ Element manip = elems[0];
m_super = manip.getAttribute("super");
Element[] fields = manip.getElements("field");
for (int i = 0; fields != null && i < fields.length; i++) {