You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2008/05/14 21:15:36 UTC
svn commit: r656371 - in
/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo:
ComponentFactory.java parser/PojoMetadata.java
Author: clement
Date: Wed May 14 12:15:36 2008
New Revision: 656371
URL: http://svn.apache.org/viewvc?rev=656371&view=rev
Log:
Allows the early discovery of manipulation error and stops the factory as soon as detected.
Modified:
felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java
Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java?rev=656371&r1=656370&r2=656371&view=diff
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java (original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java Wed May 14 12:15:36 2008
@@ -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;
}
Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java?rev=656371&r1=656370&r2=656371&view=diff
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java (original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java Wed May 14 12:15:36 2008
@@ -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++) {