domino icon indicating copy to clipboard operation
domino copied to clipboard

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

= Domino :toc: :toc-placement: preamble :stable-version: 1.1.5 :example-scala-version: 2.13.2

ifdef::env-github[] image:https://github.com/domino-osgi/domino/actions/workflows/build.yml/badge.svg["Build and Test", link="https://github.com/domino-osgi/domino/actions/workflows/build.yml"] image:https://www.codacy.com/project/badge/afcdfefe80494be4bf729437dc3e2a9b["Codacy code quality", link="https://www.codacy.com/app/lefou/domino"] image:https://badge.waffle.io/domino-osgi/domino.svg?label=ready&title=Ready["Ready Stories", link="https://waffle.io/domino-osgi/domino"] image:https://badges.gitter.im/Join%20Chat.svg["Gitter chat", link="https://gitter.im/domino-osgi/domino?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge"] image:https://javadoc.io/badge2/com.github.domino-osgi/domino_2.13/javadoc.svg["ScalaDoc", link="https://javadoc.io/doc/com.github.domino-osgi/domino_2.13"] endif::[]

Domino is a small library for the programming language http://www.scala-lang.org[Scala] designed to support developers in writing http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleActivator.html[bundle activators] for the Java module system http://www.osgi.org/Technology/WhyOSGi[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 http://ipojo.org[iPOJO], http://wiki.osgi.org/wiki/Blueprint[Blueprint] and http://wiki.osgi.org/wiki/Declarative_Services[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 http://en.wikipedia.org/wiki/Domain-specific_language[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. // Most importantly, it let's you encapsulates the code for activating logic and for deactivating logic in one unit. It's not separated in start() and stop() method anymore. That greatly enhances the cohesion of your logic.

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. // You can access the bundle context at any time. Many methods expose the underlying low-level API objects. Domino tries to scale with your needs, much like Scala.

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 http://www.scala-lang.org/api/current/scala/Option.html[Option], http://www.scala-lang.org/api/current/scala/collection/immutable/List.html[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

[source,scala]

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

[source,scala]

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 link:UserGuide.adoc[Domino User Guide].

== Download

The latest stable version is {stable-version} and can be downloaded from http://search.maven.org/#search|ga|1|g%3A%22com.github.domino-osgi%22[Maven Central].

Maven:: [source,xml,subs="attributes,verbatim"]

com.github.domino-osgi domino_${scala.version} {stable-version} ----

Mill:: [source,scala,subs="attributes"] ivy"com.github.domino-osgi::domino:{stable-version}"

SBT:: [source,scala,subs="attributes"] "com.github.domino-osgi" %% "domino" % "{stable-version}"

Gradle:: [source,groovy,subs="attributes"] compile 'com.github.domino-osgi:domino_${scala.version}:{stable-version}'

Manual:: [horizontal] Scala 2.13::: http://search.maven.org/remotecontent?filepath=com/github/domino-osgi/domino_2.13/{stable-version}/domino_2.13-{stable-version}.jar[domino_2.13-{stable-version}.jar], http://search.maven.org/remotecontent?filepath=com/github/domino-osgi/domino_2.13/{stable-version}/domino_2.13-{stable-version}-sources.jar[domino_2.13-{stable-version}-sources.jar], http://search.maven.org/remotecontent?filepath=com/github/domino-osgi/domino_2.13/{stable-version}/domino_2.13-{stable-version}-javadoc.jar[domino_2.13-{stable-version}-scaladoc.jar] Scala 2.12::: http://search.maven.org/remotecontent?filepath=com/github/domino-osgi/domino_2.12/{stable-version}/domino_2.12-{stable-version}.jar[domino_2.12-{stable-version}.jar], http://search.maven.org/remotecontent?filepath=com/github/domino-osgi/domino_2.12/{stable-version}/domino_2.12-{stable-version}-sources.jar[domino_2.12-{stable-version}-sources.jar], http://search.maven.org/remotecontent?filepath=com/github/domino-osgi/domino_2.12/{stable-version}/domino_2.12-{stable-version}-javadoc.jar[domino_2.12-{stable-version}-scaladoc.jar] Scala 2.11::: http://search.maven.org/remotecontent?filepath=com/github/domino-osgi/domino_2.11/{stable-version}/domino_2.11-{stable-version}.jar[domino_2.11-{stable-version}.jar], http://search.maven.org/remotecontent?filepath=com/github/domino-osgi/domino_2.11/{stable-version}/domino_2.11-{stable-version}-sources.jar[domino_2.11-{stable-version}-sources.jar], http://search.maven.org/remotecontent?filepath=com/github/domino-osgi/domino_2.11/{stable-version}/domino_2.11-{stable-version}-javadoc.jar[domino_2.11-{stable-version}-scaladoc.jar] Scala 2.10::: http://search.maven.org/remotecontent?filepath=com/github/domino-osgi/domino_2.10/{stable-version}/domino_2.10-{stable-version}.jar[domino_2.10-{stable-version}.jar], http://search.maven.org/remotecontent?filepath=com/github/domino-osgi/domino_2.10/{stable-version}/domino_2.10-{stable-version}-sources.jar[domino_2.10-{stable-version}-sources.jar], http://search.maven.org/remotecontent?filepath=com/github/domino-osgi/domino_2.10/{stable-version}/domino_2.10-{stable-version}-javadoc.jar[domino_2.10-{stable-version}-scaladoc.jar]

== Documentation

  • link:UserGuide.adoc[User Guide]
  • ScalaDoc hosted on https://javadoc.io/doc/com.github.domino-osgi/domino_2.13[javadoc.io]
  • https://domino-osgi.github.io/domino/scaladoc/1.0.0_2.10[Scaladoc (1.0.0)]
  • link:FAQ.adoc[FAQ]
  • https://gitter.im/domino-osgi/domino[Gitter chat]

== Development

=== Contribute

If you want to report a bug or suggest a feature, please do it in the https://github.com/domino-osgi/domino/issues[GitHub issues section].

If you want to provide a fix or improvement, please fork Domino and send us a pull request on https://github.com/domino-osgi/domino[GitHub]. Thank you!

If you want to give general feedback, please do it in the https://gitter.im/domino-osgi/domino[Gitter chat].

If you want to show appreciation for the project, please "star" it on https://github.com/domino-osgi/domino[GitHub]. That helps us setting our priorities.

=== Building Domino

Domino is build with the https://github.com/lihaoyi/mill[Mill build tool].

To cleanly build domino (for Scala {example-scala-version}), you can use the bundles start script or your locally installed mill executable:

[subs="attributes"]

./mill domino[{example-scala-version}].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 ...

  • https://github.com/helgoboss[helgoboss] for creating Domino 1.0.0
  • http://github.com/weiglewilczek/scalamodules[ScalaModules] for being an inspiration, in particular for the bundle and service watching functionality
  • http://commons.wikimedia.org/wiki/User:Nyenyec[Nyenyec] for creating the image from which the Domino logo is derived

== License

Domino is licensed under the http://www.opensource.org/licenses/mit-license[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