org.clazzes.util.sched.osgi
public class OsgiExecutorServiceProvider extends Object implements org.osgi.service.cm.ManagedService, org.osgi.service.cm.ConfigurationListener
A provider of an ExecutorService
and
a ScheduledExecutorService
as OSGi service for
use by various bundles.
This provider reads the OSGi configuration with the PID
org.clazzes.util.sched
and interprets the two configuration
properties executorPoolSize
and scheduledCorePoolSize
.
Typically, the exported thread pools are used like follows:
<bp:reference id="executorService" availability="optional" interface="java.util.concurrent.ExecutorService" filter="(pool.name=sched-util)"> </bp:reference> <bp:bean id="oneTimeScheduler" class="org.clazzes.util.sched.impl.OneTimeSchedulerImpl" init-method="start" destroy-method="shutdownNow"> <bp:property name="executorService" ref="executorService"/> <bp:property name="resultLifeTime" value="60000"/> <bp:property name="gcInterval" value="60000"/> <bp:property name="threadLocalValues"> <bp:map> <bp:entry key="org.clazzes.login::Locale"><bp:null/></bp:entry> <bp:entry key="org.clazzes.login::Principal"><bp:null/></bp:entry> </bp:map> </bp:property> </bp:bean>
An example involving the exported scheduled executor service is:
<bp:reference id="executorService" availability="optional" interface="java.util.concurrent.ScheduledExecutorService" filter="(pool.name=sched-util)"> </bp:reference> <bp:bean id="oneTimeScheduler" class="org.clazzes.util.sched.impl.OneTimeSchedulerImpl" init-method="start" destroy-method="shutdownNow"> <bp:property name="executorService" ref="executorService"/> <bp:property name="resultLifeTime" value="60000"/> <bp:property name="gcInterval" value="60000"/> <bp:property name="threadLocalValues"> <bp:map> <bp:entry key="org.clazzes.login::Locale"><bp:null/></bp:entry> <bp:entry key="org.clazzes.login::Principal"><bp:null/></bp:entry> </bp:map> </bp:property> </bp:bean>
Constructor and Description |
---|
OsgiExecutorServiceProvider() |
Modifier and Type | Method and Description |
---|---|
void |
configurationEvent(org.osgi.service.cm.ConfigurationEvent event) |
void |
createDefaultConfig() |
void |
destroy() |
void |
setBundle(org.osgi.framework.Bundle bundle) |
void |
setConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin configurationAdmin) |
protected void |
shutdownInternals(boolean hard) |
protected void |
shutdownScheduledInternals(boolean hard) |
protected void |
startInternals() |
protected void |
startScheduledInternals() |
void |
updated(Dictionary properties) |
public void createDefaultConfig()
public void configurationEvent(org.osgi.service.cm.ConfigurationEvent event)
configurationEvent
in interface org.osgi.service.cm.ConfigurationListener
public void updated(Dictionary properties) throws org.osgi.service.cm.ConfigurationException
updated
in interface org.osgi.service.cm.ManagedService
org.osgi.service.cm.ConfigurationException
protected void startInternals()
protected void shutdownInternals(boolean hard)
protected void startScheduledInternals()
protected void shutdownScheduledInternals(boolean hard)
public void destroy()
public void setBundle(org.osgi.framework.Bundle bundle)
public void setConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin configurationAdmin)
Copyright © 2014 Clazzes.org. All Rights Reserved.