removed "changed/removed" callbacks from temporal service dependency annotation
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@903433 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/TemporalServiceDependency.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/TemporalServiceDependency.java
index bf2546e..c243f8c 100644
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/TemporalServiceDependency.java
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/api/TemporalServiceDependency.java
@@ -97,14 +97,4 @@
* the annotation is applied on a class field.
*/
String added() default "";
-
- /**
- * Returns the callback method to be invoked when the service properties have changed.
- */
- String changed() default "";
-
- /**
- * Returns the callback method to invoke when the service is lost.
- */
- String removed() default "";
}
diff --git a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
index 02e3f4f..7827c57 100644
--- a/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
+++ b/dependencymanager/annotation/src/main/java/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
@@ -88,39 +88,41 @@
private final static Pattern m_methodCompoPattern = Pattern.compile("\\(\\)\\[Ljava/lang/Object;");
// List of component descriptor entry types
- enum EntryTypes {
- Service,
- ServiceDependency,
- TemporalServiceDependency,
+ enum EntryTypes
+ {
+ Service,
+ ServiceDependency,
+ TemporalServiceDependency,
ConfigurationDependency,
};
-
+
// List of component descriptor parameters
- enum Params {
- init,
- start,
- stop,
- destroy,
- impl,
- provide,
- properties,
- factory,
- factoryMethod,
- composition,
- service,
- filter,
- defaultImpl,
- required,
- added,
+ enum Params
+ {
+ init,
+ start,
+ stop,
+ destroy,
+ impl,
+ provide,
+ properties,
+ factory,
+ factoryMethod,
+ composition,
+ service,
+ filter,
+ defaultImpl,
+ required,
+ added,
changed,
removed,
- autoConfig,
- pid,
- propagate,
- updated,
+ autoConfig,
+ pid,
+ propagate,
+ updated,
timeout
};
-
+
/**
* This class represents a parsed DependencyManager component descriptor entry.
* (either a Service, a ServiceDependency, or a ConfigurationDependency descriptor entry).
@@ -129,7 +131,7 @@
{
/** The component descriptor entry type: either Service, (Temporal)ServiceDependency, or ConfigurationDependency */
EntryTypes m_entry;
-
+
/** The component descriptor entry parameters (init/start/stop ...) */
Map<Params, Object> m_params = new HashMap<Params, Object>();
@@ -360,7 +362,7 @@
else if (annotation.getName().equals(A_CONFIGURATION_DEPENDENCY))
{
parseConfigurationDependencyAnnotation(annotation);
- }
+ }
else if (annotation.getName().equals(A_TEMPORAL_SERVICE_DEPENDENCY))
{
parseServiceDependencyAnnotation(annotation, true);
@@ -404,7 +406,8 @@
*/
private void parseServiceDependencyAnnotation(Annotation annotation, boolean temporal)
{
- Info info = new Info(temporal ? EntryTypes.TemporalServiceDependency : EntryTypes.ServiceDependency);
+ Info info = new Info(temporal ? EntryTypes.TemporalServiceDependency
+ : EntryTypes.ServiceDependency);
m_infos.add(info);
// service attribute
@@ -443,24 +446,25 @@
// defaultImpl attribute
info.addClassParam(annotation, Params.defaultImpl, null);
- // required attribute (not valid if parsing a temporal service dependency)
- if (! temporal) {
- info.addParam(annotation, Params.required, null);
- }
-
// added callback
info.addParam(annotation, Params.added, (!m_isField) ? m_method : null);
- // changed callback
- info.addParam(annotation, Params.changed, null);
-
- // removed callback
- info.addParam(annotation, Params.removed, null);
-
- // timeout attribute (only valid if parsing a temporal service dependency)
- if (temporal) {
+ if (temporal)
+ {
+ // timeout attribute (only valid if parsing a temporal service dependency)
info.addParam(annotation, Params.timeout, null);
}
+ else
+ {
+ // required attribute (not valid if parsing a temporal service dependency)
+ info.addParam(annotation, Params.required, null);
+
+ // changed callback
+ info.addParam(annotation, Params.changed, null);
+
+ // removed callback
+ info.addParam(annotation, Params.removed, null);
+ }
}
/**
@@ -528,7 +532,7 @@
{
sb.append("\n\t").append(info.toString());
}
- m_reporter.warning(sb.toString());
+ m_reporter.warning(sb.toString());
}
/**
diff --git a/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/ComponentManager.java b/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/ComponentManager.java
index cda68ea..5c0ab85 100644
--- a/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/ComponentManager.java
+++ b/dependencymanager/runtime/src/main/java/org/apache/felix/dm/runtime/ComponentManager.java
@@ -313,21 +313,10 @@
sd.setDefaultImplementation(defaultServiceImplClass);
}
- // Set required flag (always true for a temporal dependency)
- if (temporal)
- {
- sd.setRequired(true);
- }
- else
- {
- String required = parser.getString(DescriptorParam.required, "true");
- sd.setRequired("true".equals(required));
- }
-
// Set bind/unbind/rebind
String added = parser.getString(DescriptorParam.added, null);
- String changed = parser.getString(DescriptorParam.changed, null);
- String removed = parser.getString(DescriptorParam.removed, null);
+ String changed = temporal ? null : parser.getString(DescriptorParam.changed, null);
+ String removed = temporal ? null : parser.getString(DescriptorParam.removed, null);
sd.setCallbacks(added, changed, removed);
// Set AutoConfig
@@ -337,14 +326,22 @@
sd.setAutoConfig(autoConfigField);
}
- // Set the timeout value for a temporal service dependency
+ // Do specific parsing for temporal service dependency
if (temporal)
{
+ // Set the timeout value for a temporal service dependency
String timeout = parser.getString(DescriptorParam.timeout, null);
if (timeout != null)
{
((TemporalServiceDependency) sd).setTimeout(Long.parseLong(timeout));
}
+
+ // Set required flag (always true for a temporal dependency)
+ sd.setRequired(true);
+ } else {
+ // for ServiceDependency, get required flag.
+ String required = parser.getString(DescriptorParam.required, "true");
+ sd.setRequired("true".equals(required));
}
return sd;
}