abstract class DominoActivator extends OsgiContext with CapsuleConvenience with BundleWatching with ConfigurationWatching with ServiceConsuming with ServiceProviding with ServiceWatching
This is the main entry point to the Domino DSL.
By having your bundle activator extend from this class, you get full access to the Domino DSL. In most cases DominoActivator is all you need because it mixes in all the other functionality.
Note that if you use watchServices or watchBundles, you might additionally want to import the relevant watcher events.
Example 1: Wait for a service
package org.example.domino_test_one import domino.DominoActivator import org.osgi.service.http.HttpService class MyService(httpService: HttpService) class Activator extends DominoActivator { whenBundleActive { // Make MyService available as long as HttpService is present whenServicePresent[HttpService] { httpService => val myService = new MyService(httpService) myService.providesService[MyService] } } }
Example 2: Listen for configuration changes
package org.example.domino_test_two import domino.DominoActivator class KeyService(key: String) class Activator extends DominoActivator { whenBundleActive { // Reregister KeyService whenever configuration changes whenConfigurationActive("my_service") { conf => val key = conf.get("key") map { _.asInstanceOf[String] } getOrElse "defaultKey" new KeyService(key).providesService[KeyService] } } }
- Note
I suggest extending from this class instead of mixing in the subpackage traits. Then you don't need to recompile your bundle if minor internal changes are made to Domino. This results in greater upwards compatibility.
- Alphabetic
- By Inheritance
- DominoActivator
- ServiceWatching
- ServiceProviding
- ServiceConsuming
- DominoImplicits
- ConfigurationWatching
- BundleWatching
- CapsuleConvenience
- OsgiContext
- EmptyBundleActivator
- BundleActivator
- DynamicCapsuleContext
- CapsuleContext
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
DominoActivator()
Will be called by the OSGi framework.
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
addCapsule(capsule: Capsule): Unit
Starts the given capsule and adds it to the current capsule scope.
Starts the given capsule and adds it to the current capsule scope.
- capsule
capsule
- Definition Classes
- DynamicCapsuleContext → CapsuleContext
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
bundleContext: BundleContext
Returns the bundle context as long as the bundle is active.
Returns the bundle context as long as the bundle is active.
- Definition Classes
- OsgiContext
-
val
capsuleContext: DominoActivator
Dependency
Dependency
- Attributes
- protected
- Definition Classes
- DominoActivator → ServiceWatching → ServiceProviding → ConfigurationWatching → BundleWatching → CapsuleConvenience
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
executeWithinNewCapsuleScope(f: ⇒ Unit): CapsuleScope
Creates a new capsule scope on top of the active one and executes the given function in it.
Creates a new capsule scope on top of the active one and executes the given function in it. So the function sees the new capsule scope as the current one.
- f
the function which might add capsules to the new scope
- returns
the new scope
- Definition Classes
- DynamicCapsuleContext → CapsuleContext
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
onStart(f: ⇒ Unit): Unit
Adds the given start logic.
Adds the given start logic. The logic is executed immediately.
- f
start logic
- Definition Classes
- CapsuleConvenience
-
def
onStop(f: ⇒ Unit): Unit
Adds the given stop logic.
Adds the given stop logic. The given function will be executed when the current scope is stopped.
- f
stop logic
- Definition Classes
- CapsuleConvenience
-
def
service[S <: AnyRef](filter: String)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S], arg1: ClassTag[S]): Option[S]
Returns the first available service of the specified class which satisfies the filter if available.
Returns the first available service of the specified class which satisfies the filter if available. If the service is not available, it returns
None
. The service is not explicitly released.- S
service type
- filter
filter expression
- returns
service if available
- Definition Classes
- ServiceConsuming
-
def
service[S <: AnyRef](implicit arg0: ClassTag[S]): Option[S]
Returns the highest-ranked service of the specified type if available.
Returns the highest-ranked service of the specified type if available. The service is not explicitly released. It's assumed that the service will be used until the bundle stops. Doesn't take type parameters into account!
- S
service type
- returns
service if available
- Definition Classes
- ServiceConsuming
-
val
serviceConsuming: DominoActivator
Dependency
Dependency
- Attributes
- protected
- Definition Classes
- DominoActivator → ConfigurationWatching
-
val
serviceProviding: DominoActivator
Dependency
Dependency
- Attributes
- protected
-
def
serviceRef[S <: AnyRef](filter: String)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S], arg1: ClassTag[S]): Option[ServiceReference[S]]
Like service with filter but returns the service reference.
Like service with filter but returns the service reference.
- Definition Classes
- ServiceConsuming
-
def
serviceRef[S <: AnyRef](implicit arg0: ClassTag[S]): Option[ServiceReference[S]]
Like service but returns the reference so you can access meta information about that service.
Like service but returns the reference so you can access meta information about that service. An implicit conversion adds a
service
property to the reference, so you can simply use that to obtain the service. Doesn't take type parameters into account!- Definition Classes
- ServiceConsuming
-
implicit
def
serviceRefToRichServiceRef[S <: AnyRef](serviceRef: ServiceReference[S]): RichServiceReference[S]
Converts a service reference to a rich service reference so one can easily obtain the corresponding service by calling
service
, for example.Converts a service reference to a rich service reference so one can easily obtain the corresponding service by calling
service
, for example.- Definition Classes
- DominoImplicits
-
def
serviceRefs[S <: AnyRef](filter: String)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S], arg1: ClassTag[S]): Seq[ServiceReference[S]]
Like services with filters but returns the references.
Like services with filters but returns the references.
- Definition Classes
- ServiceConsuming
-
def
serviceRefs[S <: AnyRef](implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S], arg1: ClassTag[S]): Seq[ServiceReference[S]]
Like services but returns service references.
Like services but returns service references.
- Definition Classes
- ServiceConsuming
-
implicit
def
serviceToProvidableService[S](service: S): ProvidableService[S]
Automatically converts any object to a ProvidableService.
Automatically converts any object to a ProvidableService.
- Definition Classes
- ServiceProviding
- See also
ProvidableService for the list of service registration methods
-
def
services[S <: AnyRef](filter: String)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S], arg1: ClassTag[S]): Seq[S]
Returns all services of the specified type which satisfy the given filter.
Returns all services of the specified type which satisfy the given filter.
- S
service type
- filter
filter expression
- returns
services
- Definition Classes
- ServiceConsuming
-
def
services[S <: AnyRef](implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S], arg1: ClassTag[S]): Seq[S]
Returns all services of the given type.
-
def
start(context: BundleContext): Unit
- Definition Classes
- OsgiContext → EmptyBundleActivator → BundleActivator
-
def
stop(context: BundleContext): Unit
- Definition Classes
- OsgiContext → EmptyBundleActivator → BundleActivator
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
watchAdvancedServices[S <: AnyRef](filter: String)(f: (ServiceWatcherEvent[S]) ⇒ Unit)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S], arg1: ClassTag[S]): ServiceTracker[S, S]
Lets you react to service events for services with the specified type which match the given filter.
Lets you react to service events for services with the specified type which match the given filter.
- S
Service type
- f
Service event handler
- returns
Underlying service tracker
- Definition Classes
- ServiceWatching
-
def
watchBundles(f: (BundleWatcherEvent) ⇒ Unit): BundleTracker[Bundle]
Reacts to bundle events with the given event handler.
Reacts to bundle events with the given event handler.
- f
bundle event handler
- returns
underlying bundle tracker
- Definition Classes
- BundleWatching
-
def
watchServices[S <: AnyRef](f: (ServiceWatcherEvent[S]) ⇒ Unit)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S], arg1: ClassTag[S]): ServiceTracker[S, S]
Lets you react to service events for services with the specified type.
Lets you react to service events for services with the specified type.
- S
Service type
- f
Service event handler
- returns
Underlying service tracker
- Definition Classes
- ServiceWatching
-
def
whenAdvancedServicePresent[S <: AnyRef](filter: String)(f: (S) ⇒ Unit)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S], arg1: ClassTag[S]): ServiceTracker[S, S]
Activates the given inner logic as long as the first service of the given type is present.
Activates the given inner logic as long as the first service of the given type is present. This implements the concept of required services. The inner logic is started as soon as a service s of the given type gets present and stopped when s is removed.
- Definition Classes
- ServiceWatching
- To do
Idea for roadmap: Fallback to another service if s is removed and another service of the type is available (reevaluate capsule).
-
def
whenBundleActive(f: ⇒ Unit): Unit
Defines a handler
f
to be executed when the bundle becomes active.Defines a handler
f
to be executed when the bundle becomes active.f
is executed as soon as the bundle activator'sstart
method is called. This should be called in the constructor of your activator.In
f
, you have the opportunity to add so called capsules, which have their ownstart
andstop
methods (a kind of mini bundles). Theirstop
methods will be invoked as soon as the bundle activator'sstop
method is called. So you have the big chance here to encapsulate start and stop logic at one place, making the bundle activator less error-prone, better readable and easier to write.- f
Handler
- Definition Classes
- OsgiContext
-
def
whenConfigurationActive(objectClassDefinition: ObjectClassDefinition)(f: (Map[String, Any]) ⇒ Unit): ServiceRegistration[ManagedService]
Like the same-named method which expects the service PID but takes the service PID from the given object class definition and registers a corresponding meta type provider so a nice configuration GUI will be created.
Like the same-named method which expects the service PID but takes the service PID from the given object class definition and registers a corresponding meta type provider so a nice configuration GUI will be created.
- objectClassDefinition
object class definition
- f
handler
- returns
the managed service registration
- Definition Classes
- ConfigurationWatching
-
def
whenConfigurationActive(servicePid: String, metaTypeProvider: Option[MetaTypeProvider] = None)(f: (Map[String, Any]) ⇒ Unit): ServiceRegistration[ManagedService]
Executes the given handler with the initial configuration or an empty map if none exists.
Executes the given handler with the initial configuration or an empty map if none exists. Whenever the configuration is changed, the capsules registered in the handler are stopped and the handler is executed again with the new configuration.
- servicePid
service PID
- metaTypeProvider
optional metatype provider
- f
handler
- returns
the managed service registration
- Definition Classes
- ConfigurationWatching
-
def
whenFactoryConfigurationActive(objectClassDefinition: ObjectClassDefinition)(f: (Map[String, Any], String) ⇒ Unit): ServiceRegistration[ManagedServiceFactory]
Like the same-named method which expects the service PID but takes the service PID from the given object class definition and registers a corresponding meta type provider so a nice configuration GUI will be created.
Like the same-named method which expects the service PID but takes the service PID from the given object class definition and registers a corresponding meta type provider so a nice configuration GUI will be created.
- objectClassDefinition
object class definition
- f
handler
- returns
the managed service factory registration
- Definition Classes
- ConfigurationWatching
-
def
whenFactoryConfigurationActive(servicePid: String, name: String, metaTypeProvider: Option[MetaTypeProvider] = None)(f: (Map[String, Any], String) ⇒ Unit): ServiceRegistration[ManagedServiceFactory]
Executes the given handler whenever a new factory configuration is created.
Executes the given handler whenever a new factory configuration is created. Whenever a factory configuration is changed, the correct capsules registered in the corresponding handler are stopped and the handler is executed again with the new factory configuration. When the factory configuration is removed, the corresponding capsules are stopped.
- servicePid
service PID
- name
descriptive name for the factory
- metaTypeProvider
optional metatype provider
- f
handler
- returns
the managed service factory registration
- Definition Classes
- ConfigurationWatching
-
def
whenServicePresent[S <: AnyRef](f: (S) ⇒ Unit)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S], arg1: ClassTag[S]): ServiceTracker[S, S]
Waits until a service of the specified type is available and executes the given event handler with it.
Waits until a service of the specified type is available and executes the given event handler with it. When the service disappears, the capsules added in the handlers are stopped. You can wait on a bunch of services if you nest
whenServicePresent
methods.- S
Service type
- f
Handler
- returns
Underlying service tracker
- Definition Classes
- ServiceWatching
-
def
whenServicesPresent[S1 <: AnyRef, S2 <: AnyRef, S3 <: AnyRef, S4 <: AnyRef, S5 <: AnyRef](f: (S1, S2, S3, S4, S5) ⇒ Unit)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S1], arg1: ClassTag[S1], arg2: scala.reflect.api.JavaUniverse.TypeTag[S2], arg3: ClassTag[S2], arg4: scala.reflect.api.JavaUniverse.TypeTag[S3], arg5: ClassTag[S3], arg6: scala.reflect.api.JavaUniverse.TypeTag[S4], arg7: ClassTag[S4], arg8: scala.reflect.api.JavaUniverse.TypeTag[S5], arg9: ClassTag[S5]): ServiceTracker[S1, S1]
- Definition Classes
- ServiceWatching
-
def
whenServicesPresent[S1 <: AnyRef, S2 <: AnyRef, S3 <: AnyRef, S4 <: AnyRef](f: (S1, S2, S3, S4) ⇒ Unit)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S1], arg1: ClassTag[S1], arg2: scala.reflect.api.JavaUniverse.TypeTag[S2], arg3: ClassTag[S2], arg4: scala.reflect.api.JavaUniverse.TypeTag[S3], arg5: ClassTag[S3], arg6: scala.reflect.api.JavaUniverse.TypeTag[S4], arg7: ClassTag[S4]): ServiceTracker[S1, S1]
- Definition Classes
- ServiceWatching
-
def
whenServicesPresent[S1 <: AnyRef, S2 <: AnyRef, S3 <: AnyRef](f: (S1, S2, S3) ⇒ Unit)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S1], arg1: ClassTag[S1], arg2: scala.reflect.api.JavaUniverse.TypeTag[S2], arg3: ClassTag[S2], arg4: scala.reflect.api.JavaUniverse.TypeTag[S3], arg5: ClassTag[S3]): ServiceTracker[S1, S1]
- Definition Classes
- ServiceWatching
-
def
whenServicesPresent[S1 <: AnyRef, S2 <: AnyRef](f: (S1, S2) ⇒ Unit)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S1], arg1: ClassTag[S1], arg2: scala.reflect.api.JavaUniverse.TypeTag[S2], arg3: ClassTag[S2]): ServiceTracker[S1, S1]
- Definition Classes
- ServiceWatching
-
def
withAdvancedService[S <: AnyRef, R](filter: String)(f: (Option[S]) ⇒ R)(implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S], arg1: ClassTag[S]): R
Executes the given handler with the first available service of the specified class which satisfies the filter if available.
Executes the given handler with the first available service of the specified class which satisfies the filter if available. If it's not available, it still executes it but with
None
.When the handler returns, the service is released using org.osgi.framework.BundleContext#ungetService.
- S
service type
- R
function result type
- filter
filter expression
- f
handler that uses the service
- returns
handler result
- Definition Classes
- ServiceConsuming
-
def
withService[S <: AnyRef, R](f: (Option[S]) ⇒ R)(implicit arg0: ClassTag[S]): R
Executes the given handler with the highest-ranked service of the specified type.
Executes the given handler with the highest-ranked service of the specified type. If it's not available, it still executes it but with
None
. Doesn't take type parameters into account!When the handler returns, the service is released using org.osgi.framework.BundleContext#ungetService.
- S
service type
- R
function result type
- f
handler that uses the service
- returns
handler result
- Definition Classes
- ServiceConsuming
Inherited from ServiceWatching
Inherited from ServiceProviding
Inherited from ServiceConsuming
Inherited from DominoImplicits
Inherited from ConfigurationWatching
Inherited from BundleWatching
Inherited from CapsuleConvenience
Inherited from OsgiContext
Inherited from EmptyBundleActivator
Inherited from BundleActivator
Inherited from DynamicCapsuleContext
Inherited from CapsuleContext
Inherited from AnyRef
Inherited from Any
Basics
Basic methods
Consume service references
Methods for obtaining access to OSGi service references
Consume services
Methods for obtaining access to OSGi services
Provide services
Functionality for exposing arbitrary objects in the OSGi service registry.
Wait for services
Methods for waiting until services become available
Watch bundles
Methods for reacting to bundle events
Watch configurations
Methods for listening to configuration updates
Watch factory configurations
Methods for listening to factory configuration additions, updates and removals
Watch services
Methods for reacting to service events