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
1
vote
4 answers

JAVA OSGi: InstantiationException with Declarative Services

I'm new to OSGi and am building a first DS-implementation. Everything is coded according to "the book" but when running I get this error: java.lang.InstantiationException: com.mine.logger.internal.udp.UdpListener at…
Frank
  • 5,741
  • 4
  • 28
  • 49
1
vote
0 answers

Only activate component when a valid configuration can be bound in Apache Felix

We're using declarative services to create components. We have a hard requirement that the service provided by the component should be available only when a configuration exists and is valid. We also need the component (and service) to be…
medalik
  • 139
  • 1
  • 10
1
vote
2 answers

Using declarative services in Karaf 4.1.0

I'm trying to develop a Karaf 4.1.0 application using NetBeans 8.2, Maven 3.3.9 and declarative services. Really simple services work, but as soon as I try to do something vaguely useful I get the dreaded osgi.component missing requirement…
1
vote
1 answer

Backporting OSGI DS component to OSGI R4

I have a component which was developed for Apache Karaf 4.0.5. However, it turns out it needs to be deployed on glassfish 4, which is based on an older version of Felix. I get this message when trying to deploy it: missing requirement [319.0]…
user1432855
1
vote
1 answer

Reference annotation on bundle field

I'm developing an application with OSGi. Looking inside the OSGi compendium 6.0 (section 112.8.1) I've come across the declarative service; in particular I looked the following paragraph: For a field, the defaults for the Reference annotation are:…
Koldar
  • 1,317
  • 15
  • 35
1
vote
1 answer

How can I get current bundle's BundleContext instance while using declarative services in karaf 3.0.2

In ONOS on karaf 3.0.2, I wish to get current bundle's BundleContext instance for tracking bundle's status and configuring it. But ONOS uses declarative service, so I cannot use function like BundleContext.getServiceReference() to get it. Could…
闫伯元
  • 445
  • 1
  • 4
  • 9
1
vote
1 answer

OSGi: Do DS-service consumers get notified synchronously when a certain service become available

I have a DS-service consumer of the IFoo interface: @Component public class IFooListener { @Reference(bind = "bind", unbind = "unbind", referenceInterface = IFoo.class, cardinality =…
mdzh
  • 1,030
  • 2
  • 17
  • 34
1
vote
0 answers

How to override bnd Require-Capability generated from DS annotation?

I have a bundle with an "optional" Component : It should be started if at leat one service of type X exist, and deactivated when the last service is unregistered. This component is "optional": It doesn't matter if X is registered or not, or if my…
Jérémie B
  • 10,611
  • 1
  • 26
  • 43
1
vote
0 answers

SCR Bundle within Felix on Android

I'm embedding Apache Felix 5.4.0 implementation of OSGi framework within an Android app, together with a couple of standard Bundles (like EventAdmin, Log, SCR, etc.). I embedded and configured the framework with no problems, but when I dynamically…
PeppeMir
  • 163
  • 7
1
vote
1 answer

OSGi ConfigAdmin service deletion

i'm using multiple instances of osgi components/services. These osgi components are configured with configuration policy = required and instantiated and deleted by adding or deleting configurations via ConfigurationAdmin. Furthermore I use "sets" of…
andineupert
  • 341
  • 2
  • 6
  • 19
1
vote
1 answer

What's the proper way to generate a manifest with DS and maven-bundle-plugin?

I am using today maven-bundle-plugin to generate the manifest of my projects. Due to others constraints, my modules use the "jar" packaging (i can't use the "bundle" packaging), and currently, my pom look like this :
Jérémie B
  • 10,611
  • 1
  • 26
  • 43
1
vote
2 answers

OSGi: when to use component framework and when to create objects yourself

I've been an AEM developer for almost a year now. I know AEM uses 'Declarative Services component framework' to manage life cycle of OSGi components. Consider a scenario when i would export a package from a bundle and import that package from…
Shashi
  • 746
  • 10
  • 39
1
vote
1 answer

Dynamic target for declarative service in OSGI

Given a consumer which uses a service, how can this consumer select a specific provider dynamically using declarative service ? Example Service.java public interface Service { public void do(); } Provider1.java public class Provider1 implements…
cde
  • 187
  • 1
  • 12
1
vote
1 answer

Issue with null service with Declarative Services in Karaf 4.0.1

I'm attempting to create a service deployable on karaf that imports a file into a repository. The way my project has been set up is I have a command line class to handle the creation of the command in karaf (by using org.apache.felix.gogo.commands…
1
vote
1 answer

OSGi reading configurations

I am trying to code a OSGi bundle which can be initiated using multiple configurations. Purpose of my bundle is to rewrite static links in html and redirect it to a CDN URL. I am using org.apache.sling.rewriter.Transformer to achieve…
Prashant Onkar
  • 414
  • 3
  • 15