Fix some minor formatting issue
Improve a log message in composite service providing
Change the log level of a useless message
Modify external handler tests to check when the namespace (o the external handler) is not the class name.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@648046 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionMetadata.java b/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionMetadata.java
index 8ccf749..f4cd823 100644
--- a/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionMetadata.java
+++ b/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionMetadata.java
@@ -252,7 +252,7 @@
*/
protected Element buildMetadata(String name) {
Element elem = new Element("component", "");
- Attribute className = new Attribute("className", m_name);
+ Attribute className = new Attribute("classname", m_name);
Attribute factory = new Attribute("factory", "false");
elem.addAttribute(className);
elem.addAttribute(factory);
diff --git a/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedService.java b/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedService.java
index f76aea1..64df649 100644
--- a/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedService.java
+++ b/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedService.java
@@ -112,10 +112,11 @@
// Create the factory
try {
m_factory = new ComponentFactory(m_context, clazz, metadata);
+ m_factory.start();
} catch (ConfigurationException e) {
// Should not happen.
+ m_manager.getFactory().getLogger().log(Logger.ERROR, "A factory cannot be created", e);
}
- m_factory.start();
try {
Class spec = DependencyModel.loadSpecification(m_composition.getSpecificationMetadata().getName(), m_context);
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 1c62ecf..dbd73f2 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
@@ -107,7 +107,7 @@
* @throws ConfigurationException occurs when the element describing the factory is malformed.
*/
public void check(Element element) throws ConfigurationException {
- m_classname = element.getAttribute("className");
+ m_classname = element.getAttribute("classname");
if (m_classname == null) { throw new ConfigurationException("A component needs a class name : " + element); }
}
@@ -215,7 +215,7 @@
if (name == null) { // No factory name, try with factory attribute
name = m_componentMetadata.getAttribute("factory");
if (name == null || name.equalsIgnoreCase("true") || name.equalsIgnoreCase("false")) { // Avoid boolean case
- name = m_componentMetadata.getAttribute("className");
+ name = m_componentMetadata.getAttribute("classname");
}
}
return name;
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java
index 47b754a..6e53c4a 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java
@@ -152,7 +152,7 @@
for (int i = 0; i < toRemove.size(); i++) {
ManagedAbstractFactoryType mft = (ManagedAbstractFactoryType) toRemove.get(i);
- m_logger.log(Logger.WARNING, "The factory type available: " + mft.m_type + " is no more available");
+ m_logger.log(Logger.INFO, "The factory type: " + mft.m_type + " is no more available");
mft.m_bundle = null;
mft.m_clazz = null;
mft.m_created = null;
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
index 01172df..82dbd94 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
@@ -140,7 +140,7 @@
* @throws ConfigurationException : occurs if the metadata are not correct
*/
public void configure(Element metadata, Dictionary configuration) throws ConfigurationException {
- m_className = metadata.getAttribute("className");
+ m_className = metadata.getAttribute("classname");
// Add the name
m_name = (String) configuration.get("name");
diff --git a/ipojo/tests/tests.composite/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp0.java b/ipojo/tests/tests.composite/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp0.java
index 6d5458d..d3e26a8 100644
--- a/ipojo/tests/tests.composite/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp0.java
+++ b/ipojo/tests/tests.composite/src/main/java/org/apache/felix/ipojo/test/composite/provides/TestComp0.java
@@ -72,6 +72,7 @@
try {
under = factory.createComponentInstance(props2);
} catch(Exception e) {
+ e.printStackTrace();
fail("Cannot create an instance : " + e.getMessage());
}
}
diff --git a/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/handler/CheckServiceHandler.java b/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/handler/CheckServiceHandler.java
index 865234c..b3ead6f 100644
--- a/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/handler/CheckServiceHandler.java
+++ b/ipojo/tests/tests.core/src/main/java/org/apache/felix/ipojo/test/handler/CheckServiceHandler.java
@@ -34,13 +34,13 @@
ServiceRegistration sr;
boolean isValid;
int changes = 0;
- static final String NAMESPACE = org.apache.felix.ipojo.test.handler.CheckServiceHandler.class.getName();
+ static final String NAMESPACE = "org.apache.felix.ipojo.test.handler.checkservice";
Properties props = new Properties();
public void configure(Element metadata, Dictionary configuration) {
- Element[] meta = metadata.getElements("Check", NAMESPACE);
- if(meta.length == 0) { return; }
+ Element[] meta = metadata.getElements("check", NAMESPACE);
+ if(meta == null) { return; }
// Get handler props
props.put("instance.name", configuration.get("name"));
if(configuration.get("csh.simple") != null) { props.put("Simple", configuration.get("csh.simple")); }
diff --git a/ipojo/tests/tests.core/src/main/resources/metadata.xml b/ipojo/tests/tests.core/src/main/resources/metadata.xml
index 65b63fe..3e295e2 100644
--- a/ipojo/tests/tests.core/src/main/resources/metadata.xml
+++ b/ipojo/tests/tests.core/src/main/resources/metadata.xml
@@ -1,5 +1,5 @@
<ipojo
- xmlns:cs="org.apache.felix.ipojo.test.handler.CheckServiceHandler">
+ xmlns:cs="org.apache.felix.ipojo.test.handler.checkservice">
<component classname="org.apache.felix.ipojo.test.log.LogImpl"
factory="true" name="log">
<provides />
@@ -1077,7 +1077,7 @@
<handler
classname="org.apache.felix.ipojo.test.handler.CheckServiceHandler"
name="check"
- namespace="org.apache.felix.ipojo.test.handler.CheckServiceHandler"
+ namespace="org.apache.felix.ipojo.test.handler.checkservice"
architecture="false">
<controller field="isValid" />
</handler>