Skip to content

OSGi dynamics made easy - A Scala DSL to master OSGi dynamics

License

Notifications You must be signed in to change notification settings

domino-osgi/domino

Repository files navigation

Domino

Build and Test Codacy code quality Ready Stories Gitter chat ScalaDoc

Domino is a small library for the programming language Scala designed to support developers in writing bundle activators for the Java module system OSGi. It strives to make writing complex and highly-dynamic bundle activators as easy as possible without sacrificing the power of the OSGi API.

As such, Domino is a lightweight alternative to OSGi component models like iPOJO, Blueprint and Declarative Services. Especially for those who want to leverage the power of pure code instead of reverting to an XML- or annotation-based approach.

Features

Expressive

Domino offers an expressive DSL which reflects the event-driven nature of OSGi and allows you to define very easily when your logic is made available and when it is revoked.

Unrestrictive

Some libraries just cover the most common use cases and let you fall deeply whenever you need to do something more special. Then you suddenly find yourself bypassing the library completely. Domino tries to prevent this by staying close to the low-level OSGi API.

Type safe

Most features in Domino benefit from static typing. That means the compiler and your IDE can help you write correct code. Additionally, there’s support for using generic type parameters in the service registry.

Familiar

Instead of inventing a completely foreign DSL, Domino tries to use familiar Scala data types such as Option, List etc. whenever possible so you can make use of those many nice methods like filter or map you probably fell in love with.

Extensible

If the Domino core DSL is not enough for you, simply extend it. Do you want to run a job as long as a certain service is available? Such things can be easily integrated.

Comprehensive

Many of OSGi’s core features are natively supported by the DSL (services, configuration, bundles, meta types).

Getting started

Some lines of code often say more than 1000 words.

Wait for service and register service

import domino.DominoActivator
import org.osgi.service.http.HttpService

class MyService(httpService: HttpService)

class Activator extends DominoActivator {
  whenBundleActive {
    // Make service available as long as another
    // service is present
    whenServicePresent[HttpService] { httpService =>
      val myService = new MyService(httpService)
      myService.providesService[MyService]
    }
  }
}

Listen for configuration updates

import domino.DominoActivator

class KeyService(key: String)

class Activator extends DominoActivator {
  whenBundleActive {
    // Reregister service whenever configuration changes
    whenConfigurationActive("my_service") { conf =>
      val key = conf.getOrElse("key", "defaultKey")
      new KeyService(key).providesService[KeyService]
    }
  }
}

Read more in the complete Domino User Guide.

Download

The latest stable version is 1.1.5 and can be downloaded from Maven Central.

Maven
<dependency>
  <groupId>com.github.domino-osgi</groupId>
  <artifactId>domino_${scala.version}</artifactId>
  <version>1.1.5</version>
</dependency>
Mill
ivy"com.github.domino-osgi::domino:1.1.5"
SBT
"com.github.domino-osgi" %% "domino" % "1.1.5"
Gradle
compile 'com.github.domino-osgi:domino_${scala.version}:1.1.5'

Documentation

Development

Contribute

If you want to report a bug or suggest a feature, please do it in the GitHub issues section.

If you want to provide a fix or improvement, please fork Domino and send us a pull request on GitHub. Thank you!

If you want to give general feedback, please do it in the Gitter chat.

If you want to show appreciation for the project, please "star" it on GitHub. That helps us setting our priorities.

Building Domino

Domino is build with the Mill build tool.

To cleanly build domino (for Scala 2.13.2), you can use the bundles start script or your locally installed mill executable:

./mill domino[2.13.2].jar

Creating a Release

  • Bump version in build.sc file

  • Update Changelog

  • Review documentation

  • Create a git tag with the version

  • Upload the release artifacts up to Maven Central

Deploy to Maven Central / Sonatype Open Source Respository (OSSRH)

./mill mill.scalalib.PublishModule/publishAll \
  --release true \
  --signed true \
  --publishArtifacts __.publishArtifacts \
  --sonatypeCreds <YourSonatypeCreds>

Credits

Thanks to …​

  • helgoboss for creating Domino 1.0.0

  • ScalaModules for being an inspiration, in particular for the bundle and service watching functionality

  • Nyenyec for creating the image from which the Domino logo is derived

License

Domino is licensed under the MIT License.

Changelog

Domino 1.1.5 - 2020-05-05

  • Fixed Maven Central packaging

Domino 1.1.4 - 2020-05-05

  • Support for Scala 2.13

  • Bumped supported Scala versions to latest releases

  • Added option to log currently unsatisfied service watchers

Domino 1.1.3 - 2018-10-01

  • Log un-/regististration of services

  • Log registrations of service trackers

Domino 1.1.2 - 2017-04-28

  • Support for Scala 2.12

  • More test cases

Domino 1.1.1 - 2016-02-03

  • Removed Logging trait from DominoActivator. You can restore the old behavior be mixing in the trait into your activator class.

  • Improved test suite and implemented more tests. Now we use PojoSR to test OSGi dynamics without the need to run a separate container.

  • Fixed naming issues for service provisioning and comsumption.

  • Fixed unnecessary re-configuration issues with whenConfigurationActive and whenFactoryConfigurationActive.

Domino 1.1.0 - 2015-05-28

  • Switched Maintainer to Tobias Roeser

  • Renamed base package from org.helgoboss.domino to domino

  • Embedded former dependencies (org.helgoboss.capsule, org.helgoboss.scala-osgi-metatype, org.helgoboss.scala-logging) as sub packages

  • Switched to Polyglot Scala extension for Maven 3.3

  • Cross-Release for Scala 2.10 and 2.11

Domino 1.0.0 - 2013-03-31

  • Initial release for Scala 2.10