FELIX-4252 Make Extender's ThreadPool size configurable
* Oops, forgot to register my service under ManagedService interface ...
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1527960 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/AbstractService.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/AbstractService.java
index e07455f..1444451 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/AbstractService.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/AbstractService.java
@@ -62,7 +62,11 @@
* On start, registers the service.
*/
public void start() {
- m_registration = m_bundleContext.registerService(m_type.getName(), this, getServiceProperties());
+ m_registration = registerService();
+ }
+
+ protected ServiceRegistration<?> registerService() {
+ return m_bundleContext.registerService(m_type.getName(), this, getServiceProperties());
}
/**
@@ -82,6 +86,10 @@
return null;
}
+ protected BundleContext getBundleContext() {
+ return m_bundleContext;
+ }
+
protected ServiceRegistration<?> getRegistration() {
return m_registration;
}
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueService.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueService.java
index 6cbb2c8..cc87048 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueService.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueService.java
@@ -26,6 +26,7 @@
import org.apache.felix.ipojo.extender.queue.QueueService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedService;
@@ -71,6 +72,7 @@
* Initial thread pool size.
*/
private final int initialSize;
+ private ServiceRegistration<?> m_serviceRegistration;
/**
* Creates the queue service using the default pool size.
@@ -117,6 +119,14 @@
m_properties = getDefaultProperties();
}
+ @Override
+ protected ServiceRegistration<?> registerService() {
+ // Register the instance under QueueService and ManagedService types
+ return getBundleContext().registerService(new String[] {QueueService.class.getName(), ManagedService.class.getName()},
+ this,
+ getServiceProperties());
+ }
+
/**
* Stops the service.
*/
diff --git a/ipojo/runtime/core/src/test/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueServiceTestCase.java b/ipojo/runtime/core/src/test/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueServiceTestCase.java
index 6699cd4..550828a 100644
--- a/ipojo/runtime/core/src/test/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueServiceTestCase.java
+++ b/ipojo/runtime/core/src/test/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueServiceTestCase.java
@@ -70,11 +70,11 @@
public void testQueueServiceRegistration() throws Exception {
ExecutorQueueService queueService = new ExecutorQueueService(m_bundleContext);
- Mockito.<ServiceRegistration<?>>when(m_bundleContext.registerService(eq(QueueService.class.getName()), eq(queueService), any(Dictionary.class))).thenReturn(m_registration);
+ Mockito.<ServiceRegistration<?>>when(m_bundleContext.registerService(any(String[].class), eq(queueService), any(Dictionary.class))).thenReturn(m_registration);
queueService.start();
- verify(m_bundleContext).registerService(eq(QueueService.class.getName()), eq(queueService), any(Dictionary.class));
+ verify(m_bundleContext).registerService(any(String[].class), eq(queueService), any(Dictionary.class));
queueService.stop();
@@ -125,14 +125,14 @@
public void testConfigurationUpdate() throws Exception {
ExecutorQueueService queueService = new ExecutorQueueService(m_bundleContext, 1);
- Mockito.<ServiceRegistration<?>>when(m_bundleContext.registerService(eq(QueueService.class.getName()),
+ Mockito.<ServiceRegistration<?>>when(m_bundleContext.registerService(any(String[].class),
eq(queueService),
any(Dictionary.class)))
.thenReturn(m_registration);
queueService.start();
- verify(m_bundleContext).registerService(eq(QueueService.class.getName()), eq(queueService), m_captor.capture());
+ verify(m_bundleContext).registerService(any(String[].class), eq(queueService), m_captor.capture());
// Verify initial value is 1
Dictionary<String, ?> initial = m_captor.getValue();
@@ -149,14 +149,14 @@
public void testManagedServiceUpdatedWithNull() throws Exception {
ExecutorQueueService queueService = new ExecutorQueueService(m_bundleContext, 1);
- Mockito.<ServiceRegistration<?>>when(m_bundleContext.registerService(eq(QueueService.class.getName()),
+ Mockito.<ServiceRegistration<?>>when(m_bundleContext.registerService(any(String[].class),
eq(queueService),
any(Dictionary.class)))
.thenReturn(m_registration);
queueService.start();
- verify(m_bundleContext).registerService(eq(QueueService.class.getName()), eq(queueService), m_captor.capture());
+ verify(m_bundleContext).registerService(any(String[].class), eq(queueService), m_captor.capture());
// Verify initial value is 1
Dictionary<String, ?> initial = m_captor.getValue();
@@ -176,7 +176,7 @@
public void testConfigurationUpdatedWithNoChanges() throws Exception {
ExecutorQueueService queueService = new ExecutorQueueService(m_bundleContext, 1);
- Mockito.<ServiceRegistration<?>>when(m_bundleContext.registerService(eq(QueueService.class.getName()),
+ Mockito.<ServiceRegistration<?>>when(m_bundleContext.registerService(any(String[].class),
eq(queueService),
any(Dictionary.class)))
.thenReturn(m_registration);