Questions tagged [declarative-services]

Declarative Services (DS) is a component model that simplifies the creation of components that publish and/or reference OSGi Services.

Declarative Services (DS) is a component model that simplifies the creation of components that publish and/or reference OSGi Services. It was first defined in OSGi Release 4.0 and is inspired by an earlier model known as service binder by Richard Hall and Humberto Cervantes.

Its main features are:

  • Declarative : no need to write explicit code to publish or consume services.
  • Lazy : components that publish services are delayed, meaning that the service implementation class is not loaded or instantiated until the service is actually requested by a client.
  • Lifecycle: components have their own lifecycle (i.e. activation and deactivation), bounded by the lifecycle of the bundle in which they are defined.
  • Configuration: components can automatically receive configuration data from Configuration Admin.
198 questions
4
votes
3 answers

Dynamically setting target property in OSGi Reference annotatation

After reading an article on Reference target (and corresponding properties), I still don't understand how to retrieve a service, when target is set at runtime (typically target and properties are set at compile time and evaluated by SCR at…
mike
  • 4,929
  • 4
  • 40
  • 80
4
votes
1 answer

Why is it a bad idea to manually wire OSGi services?

In order to favor certain service implementations over others, I wrote a customizable version of java.util.ServiceLoader (adds priority and enabled/disabled flag to implementations via preference files for non-OSGi code). The client was pleased and…
mike
  • 4,929
  • 4
  • 40
  • 80
4
votes
1 answer

How to use java properties file in OSGI Declarative Services Annotations

I'm trying to use bndtools to create my OSGI program. Here is my previous code, and it can work well with the felix console. package com.buaa.ate.service.data.command; import org.osgi.service.component.annotations.Component; import…
Wubin
  • 141
  • 2
  • 11
4
votes
2 answers

How do you communicate between eclipse declarative services and Views (ContentProviders)

Say you have an eclipse plugin with various views, these views should display data from some OSGi bundle that pushes data to the Views. Rather than have every view communicate with the OSGi bundle, I have an intermediate Facade class that acts as a…
rcreswick
  • 16,483
  • 15
  • 59
  • 70
4
votes
2 answers

I can't click in this JTextField to edit it, why not?

UPDATE This only happens when running on OS X. The issue isn't present on Windows. I'm using Eclipse Kepler and Oracle 1.7.0_45.jdk The code below is a basic GUI running from an OSGI declarative services component. The problem is that when the…
conorgriffin
  • 4,282
  • 7
  • 51
  • 88
4
votes
2 answers

Using annotations from a library which is not a bundle in a Tycho build

I'm building an Eclipse plugin using Tycho and am making use of Declarative Services for my OSGi services. Eclipse has a nice Editor for DS files, but it still is a manual process, which means it's slow and error-prone. In non-Tycho OSGi projects I…
Robert Munteanu
  • 67,031
  • 36
  • 206
  • 278
4
votes
2 answers

In OSGi, how do you gracefully handle initialisation exceptions?

I am using Maven-SCR. By using the @Component and @Service tags, I can have my class instance register the interfaces it provides automatically. On occasion, however, the activate method (marked as @Activate) or even the constructor, might throw an…
Miquel
  • 15,405
  • 8
  • 54
  • 87
4
votes
1 answer

OSGi Declarative Services and Config Admin

I'm writting bundle with declarative services usage. For configuration I'm using properties in DS declaration. Those props can be normally changed by Config Admin, but they are not persisted. After container restart, component has default…
Jakub Truneček
  • 8,800
  • 3
  • 20
  • 35
4
votes
1 answer

Programmatically adding declarative services

Is it possible to add declarative services using some kind of api? A little background: I have a server application based on dynamic scripts (they can be added, edited or removed at any time). Those scripts have dependencies to OSGi services and…
Frank Lee
  • 2,728
  • 19
  • 30
4
votes
1 answer

How do you properly handle logging in OSGi while separating service components?

I am working with OSGi and declarative services (DS) and am currently thinking of how to handle the logging properly. Since i'm working with DS anyways, it seems natural to use the LogService specified by the OSGi service compendium as a mandatory…
benjamin
  • 1,066
  • 11
  • 22
3
votes
1 answer

OSGi services - best practice

I start loving OSGi services more and more and want to realize a lot more of my components as services. Now I'm looking for best-practice, especially for UI components. For Listener-relations I use the whiteboard-pattern, which IMHO opinion is the…
Muki
  • 3,513
  • 3
  • 27
  • 50
3
votes
3 answers

OSGi DS: Omit unbind method with Felix SCR @Reference annotation

OSGi declarative services are explicitly allowed to have a bind method without a matching unbind method for a reference because "Once the component configuration is deactivated, SCR must discard all references to the component instance and component…
Chris Dolan
  • 8,905
  • 2
  • 35
  • 73
3
votes
2 answers

OSGi: Is it valid to register services within a declarative service component activation method?

This is a duplicate of another question, but copying from the other one: I've run into an issue with Felix SCR where I get the message: ServiceFactory.getService() resulted in a cycle The reason this appers to be occuring is because within an…
Dave H
  • 547
  • 1
  • 5
  • 16
3
votes
3 answers

Dynamically choose OSGi references based on property using Declarative Services

I'm new to OSGi and am quickly becoming overwhelmed by its complexity. I believe this should be fairly simple, but I haven't been able to find a complete working example of what I'm trying to achieve. I have a Java class Foo which contains a…
roadkill
  • 315
  • 1
  • 2
  • 12
3
votes
2 answers

How to start with OSGi

In my working place, they asked to me to learn the OSGi framework and to decide what is the best approach to work with it. In the last two weeks, I surfed the web and I discovered a lot of different approaches to work with OSGi, for example, I found…
Sarcares
  • 57
  • 1
  • 2
  • 11
1
2
3
13 14