Giter Club home page Giter Club logo

servicedep's Introduction

OSGi service dependencies

The idea is to provide simple Scala traits for common OSGi service dependencies - they can be so easy injected using Declarative Services. Thus, if say you want to get HttpService in you component, you just need to follow two simple steps:

  1. Extend you component with trait HttpServiceDep
  2. Refer HttpService in your component description along with bind and unbind methods.

Example:

import com.osinka.services.dep.HttpServiceDep

class MyWebFrontend extends HttpServiceDep {
    def whatever = {
        for (httpSvc <- httpService) {
            // do whatever you want -- if you have HttpService injected
        }
    }
}

And your DS XML descriptor (e.g. OSGI-INF/frontend.xml):

<?xml version="1.0" encoding="UTF-8"?>
<component name="WWW frontend">
    <implementation class="example.MyWebFrontend"/>
    <reference
        name="HTTP service"
        interface="org.osgi.service.http.HttpService"
        bind="bindHttpService"
        unbind="unbindHttpService"
        cardinality="0..1"
        policy="dynamic"/>
</component>

Services:

  • LogServiceDep
    • Provides log(level: Int, message: String) method as well (will log only if LogService was injected)
  • HttpServiceDep
  • ConfigAdminServiceDep

Something special

  • ServiceComponent provides activate/deactivate methods and componentContext variable (Option[ComponentContext]). It also has bundleContext: Option[BundleContext] method for convinience.

servicedep's People

Stargazers

Alexander Azarov avatar

Watchers

Alexander Azarov avatar James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.