Packages

  • package root
    Definition Classes
    root
  • package domino

    Contains Domino, a lightweight Scala library for writing elegant OSGi bundle activators.

    Contains Domino, a lightweight Scala library for writing elegant OSGi bundle activators.

    For getting started, please see DominoActivator, the main entry point to the Domino DSL. Each sub package contains functionality for a specific part of the DSL.

    Definition Classes
    root
  • package bundle_watching

    Contains functionality related to watching OSGi bundles coming and going.

    Contains functionality related to watching OSGi bundles coming and going.

    Definition Classes
    domino
  • package capsule

    Contains a basic API and default implementation for building, using and extending a capsule-based DSL.

    Contains a basic API and default implementation for building, using and extending a capsule-based DSL.

    A capsule-based DSL is a generalization of the DSL used in the project "Domino". Here's an illustrative example how a capsuled-based DSL might look like:

    // Somewhere in your code
    whenTurnedOn {
      whenDevicePluggedIn {
        lightLED()
      }
    }

    The documentation distinguishes between 3 types of API clients: End users, capsule providers and context providers. The majority of developers will just come into contact with this API as end users.

    Definition Classes
    domino
  • package configuration_watching

    Contains functionality related to watching OSGi configuration changes.

    Contains functionality related to watching OSGi configuration changes.

    Definition Classes
    domino
  • package logging

    Contains functionality related to OSGi logging.

    Contains functionality related to OSGi logging.

    Definition Classes
    domino
  • package scala_logging

    Contains a simple Scala API for logging along with a Java Logging API implementation.

    Contains a simple Scala API for logging along with a Java Logging API implementation.

    The generic logging interface is provided by the Logger trait. Implementations for various logging frameworks such as SLF4J or OSGi LogService are provided in separate modules.

    See JavaUtilLogging for a convenient way to use Java Logging API.

    Definition Classes
    domino
  • package scala_osgi_metatype

    Contains Scala interfaces, adapters and builders for easily building OSGi Metatype descriptions.

    Contains Scala interfaces, adapters and builders for easily building OSGi Metatype descriptions. OSGi Metatype descriptions are very well suited for quickly providing administration user interfaces.

    You probably want to check out the builders.

    Definition Classes
    domino
    Note

    I created totally new Scala interfaces and adapters instead of directly implementing the Java interfaces of the OSGi Metatype API in order to prevent name clashes and confusion about what method to call. Scala Swing does it the same way, I guess for the same reasons.

  • package service_consuming

    Contains functionality related to acquiring OSGi services.

    Contains functionality related to acquiring OSGi services.

    Definition Classes
    domino
  • package service_providing

    Contains functionality related to registering objects in the OSGi service registry.

    Contains functionality related to registering objects in the OSGi service registry.

    Definition Classes
    domino
  • package service_watching

    Contains functionality related to watching OSGi services coming and going.

    Contains functionality related to watching OSGi services coming and going.

    Definition Classes
    domino
  • DominoActivator
  • DominoImplicits
  • DominoUtil
  • EmptyBundleActivator
  • OsgiContext
  • RichServiceReference
c

domino

DominoActivator

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.

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. DominoActivator
  2. ServiceWatching
  3. ServiceProviding
  4. ServiceConsuming
  5. DominoImplicits
  6. ConfigurationWatching
  7. BundleWatching
  8. CapsuleConvenience
  9. OsgiContext
  10. EmptyBundleActivator
  11. BundleActivator
  12. DynamicCapsuleContext
  13. CapsuleContext
  14. AnyRef
  15. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new DominoActivator()

    Will be called by the OSGi framework.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. 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
    DynamicCapsuleContextCapsuleContext
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. 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
  7. val capsuleContext: DominoActivator

    Dependency

    Dependency

    Attributes
    protected
    Definition Classes
    DominoActivatorServiceWatchingServiceProvidingConfigurationWatchingBundleWatchingCapsuleConvenience
  8. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  11. 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
    DynamicCapsuleContextCapsuleContext
  12. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  16. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. 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
  20. 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
  21. 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
  22. 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
  23. val serviceConsuming: DominoActivator

    Dependency

    Dependency

    Attributes
    protected
    Definition Classes
    DominoActivatorConfigurationWatching
  24. val serviceProviding: DominoActivator

    Dependency

    Dependency

    Attributes
    protected
  25. 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
  26. 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
  27. 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
  28. 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
  29. 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
  30. 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

  31. 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
  32. def services[S <: AnyRef](implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[S], arg1: ClassTag[S]): Seq[S]

    Returns all services of the given type.

    Returns all services of the given type.

    S

    service type

    Definition Classes
    ServiceConsuming
  33. def start(context: BundleContext): Unit
    Definition Classes
    OsgiContextEmptyBundleActivator → BundleActivator
  34. def stop(context: BundleContext): Unit
    Definition Classes
    OsgiContextEmptyBundleActivator → BundleActivator
  35. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  36. def toString(): String
    Definition Classes
    AnyRef → Any
  37. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  40. 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
  41. 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
  42. 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
  43. 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).

  44. 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's start 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 own start and stop methods (a kind of mini bundles). Their stop methods will be invoked as soon as the bundle activator's stop 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
  45. 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
  46. 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
  47. 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
  48. 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
  49. 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
  50. 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
  51. 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
  52. 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
  53. 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
  54. 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
  55. 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

Ungrouped