Skip to content

kuki/domino

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Domino

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.

Examples

Wait for service and register service

import org.helgoboss.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 org.helgoboss.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]
    }
  }
}

Further reading

Learn more on Domino's project website.

Packages

No packages published