Fix FELIX-4147 Add getProvidedService in ProvidedServiceDescription and allow external service management
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1496547 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java
index 5a98d3a..adbb126 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java
@@ -143,6 +143,10 @@
return m_dependency.getSpecification().getName();
}
+ /**
+ * Gets the described dependency.
+ * @return the dependency.
+ */
public Dependency getDependency() {
return m_dependency;
}
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
index 9fbefc9..37e7dd1 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
@@ -352,7 +352,7 @@
* service.
* This method also notifies the creation strategy of the publication.
*/
- protected void registerService() {
+ public void registerService() {
ServiceRegistration reg = null;
Properties serviceProperties = null;
synchronized (this) {
@@ -420,9 +420,9 @@
}
/**
- * Unregisters the service.
+ * Withdraws the service from the service registry.
*/
- protected void unregisterService() {
+ public void unregisterService() {
ServiceReference ref = null;
synchronized (this) {
// Create a copy of the service reference in the case we need
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceDescription.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceDescription.java
index 6584273..310fee0 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceDescription.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceDescription.java
@@ -44,7 +44,7 @@
/**
* The describe provided service.
*/
- private ProvidedService m_ps;
+ private final ProvidedService m_ps;
/**
* Constructor.
@@ -55,6 +55,14 @@
}
/**
+ * Gets the represented provided service.
+ * @return the provided service
+ */
+ public ProvidedService getProvidedService() {
+ return m_ps;
+ }
+
+ /**
* Gets the list of provided service specifications.
* @return the provided contract name.
*/
@@ -98,7 +106,7 @@
/**
* Gets provided service state.
- * @return the state of the provided service (UNREGISTERED | REGISTRED).
+ * @return the state of the provided service (UNREGISTERED | REGISTERED).
*/
public int getState() {
return m_ps.getState();
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
index 1b623b9..49f62ae 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
@@ -1072,23 +1072,23 @@
// Leaving the locked region to invoke callbacks
releaseWriteLockIfHeld();
- for (ServiceReference ref : departures) {
- onServiceDeparture(ref);
- // Notify service unbinding to listeners
- Object svc = services.get(ref);
- notifyListeners(DependencyEventType.UNBINDING, ref, svc);
- }
- for (ServiceReference ref : arrivals) {
- onServiceArrival(ref);
- // Notify service binding to listeners
- Object svc = services.get(ref);
- notifyListeners(DependencyEventType.BINDING, ref, svc);
- }
- // Do we have a modified service ?
- if (set.modified != null && m_boundServices.contains(set.modified)) {
- onServiceModification(set.modified);
- // TODO call boundServiceModified on listeners???
- }
+ for (ServiceReference ref : departures) {
+ onServiceDeparture(ref);
+ // Notify service unbinding to listeners
+ Object svc = services.get(ref);
+ notifyListeners(DependencyEventType.UNBINDING, ref, svc);
+ }
+ for (ServiceReference ref : arrivals) {
+ onServiceArrival(ref);
+ // Notify service binding to listeners
+ Object svc = services.get(ref);
+ notifyListeners(DependencyEventType.BINDING, ref, svc);
+ }
+ // Do we have a modified service ?
+ if (set.modified != null && m_boundServices.contains(set.modified)) {
+ onServiceModification(set.modified);
+ // TODO call boundServiceModified on listeners???
+ }
// Did our state changed ?
// this method will manage its own synchronization.