FELIX-1284 implementation of "modified" attribute support
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@792487 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/ComponentMetadata.java b/scr/src/main/java/org/apache/felix/scr/impl/ComponentMetadata.java
index 31c5f79..7c3c6b5 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/ComponentMetadata.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ComponentMetadata.java
@@ -75,6 +75,9 @@
// 112.5.12 deactivate can be specified (since DS 1.1)
private String m_deactivate = null;
+ // 112.??.?? modified method (configuration update, since DS 1.1)
+ private String m_modified = null;
+
// 112.4.3 configuration-policy (since DS 1.1)
private String m_configurationPolicy = null;
@@ -235,6 +238,22 @@
/**
+ * Sets the name of the modified method
+ *
+ * @param modified a method name
+ * @since 1.2.0 (DS 1.1)
+ */
+ public void setModified( String modified )
+ {
+ if ( m_validated )
+ {
+ return;
+ }
+ m_modified = modified;
+ }
+
+
+ /**
* Used to add a property to the instance
*
* @param newProperty a property metadata object
@@ -406,6 +425,18 @@
/**
+ * Returns the name of the modified method
+ *
+ * @return the name of the modified method
+ * @since 1.2.0 (DS 1.1)
+ */
+ public String getModified()
+ {
+ return m_modified;
+ }
+
+
+ /**
* Returns the associated ServiceMetadata
*
* @return a ServiceMetadata object or null if the Component does not provide any service
@@ -532,6 +563,15 @@
m_deactivate = "deactivate";
}
+ // 112.??.?? modified can be specified (since DS 1.1)
+ if ( m_modified != null && m_namespaceCode < XmlHandler.DS_VERSION_1_1 )
+ {
+ // require new namespace if modified is specified
+ logger.log( LogService.LOG_WARNING,
+ "Ignoring modified method declaration, DS 1.1 or later namespace required", this, null );
+ m_modified = null;
+ }
+
// Next check if the properties are valid (and extract property values)
Iterator propertyIterator = m_propertyMetaData.iterator();
while ( propertyIterator.hasNext() )
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/XmlHandler.java b/scr/src/main/java/org/apache/felix/scr/impl/XmlHandler.java
index 0295731..ce8febf 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/XmlHandler.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/XmlHandler.java
@@ -47,22 +47,22 @@
// Namespace URI of DS 1.0
public static final String NAMESPACE_URI = "http://www.osgi.org/xmlns/scr/v1.0.0";
-
+
// Namespace URI of DS 1.1
public static final String NAMESPACE_URI_1_1 = "http://www.osgi.org/xmlns/scr/v1.1.0";
-
+
// namespace code for non-DS namespace
public static final int DS_VERSION_NONE = -1;
-
+
// namespace code for the DS 1.0 specification
public static final int DS_VERSION_1_0 = 0;
-
+
// namespace code for the DS 1.0 specification
public static final int DS_VERSION_1_1 = 1;
// mapping of namespace URI to namespace code
private static final Map NAMESPACE_CODE_MAP;
-
+
// the bundle containing the XML resource being parsed
private final Bundle m_bundle;
@@ -201,6 +201,12 @@
m_currentComponent.setDeactivate( attrib.getProperty( "deactivate" ) );
}
+ // modified attribute is optional (since DS 1.1)
+ if ( attrib.getProperty( "modified" ) != null )
+ {
+ m_currentComponent.setModified( attrib.getProperty( "modified" ) );
+ }
+
// Add this component to the list
m_components.add( m_currentComponent );
}
@@ -292,7 +298,7 @@
m_currentComponent.addDependency( ref );
}
-
+
// unexpected element
else
{
@@ -306,7 +312,7 @@
throw new ParseException( "Exception during parsing", ex );
}
}
-
+
// unexpected namespace
else
{