FELIX-2325 Return the implementation class name from the getName method if the component name has not been explicitly set with the name attribute.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@941594 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java b/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
index 8216b1d..0676efd 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
@@ -381,7 +381,19 @@
*/
public String getName()
{
- return m_name;
+ // FELIX-2325: Be lenient here and return the name if set or
+ // the implementation class name. This allows for the
+ // BundleComponentActivator.loadComponents method to access the
+ // name before validating the component, which then makes sure
+ // that the name may only be unset for DS 1.1 and newer components
+
+ if ( m_name != null )
+ {
+ return m_name;
+ }
+
+ // return the implementation class name if the name is not set
+ return getImplementationClassName();
}