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
2
votes
3 answers

How to Use New OSGi Declarative Services Annotations?

According to a proposal described in RFC 0172 Declarative Services Annotations (page 187)?
2
votes
2 answers

Unsatisfied reference Configuration on Service Builder Liferay 7.2

We are trying to migrate code from Liferay 6.2 to Liferay 7.2, but we've hit a wall when it comes to service builder. We've followed the guide (changing the dependency-injector to ds, adding the @Component to impl classes...) but when we run a…
2
votes
1 answer

How to keep service/componnet running while update bundle OSGI

I have implemented 2 services A,B in my bundle. I would like to change the code of service A by building a new jar file and do update command but keep the service B running without start it again.
DM CHAU
  • 67
  • 6
2
votes
1 answer

Referencing a Configuration Admin factory-created OSGi service

I read this answer by Neil Bartlett that stated that DS is able to replace the old ManagedServiceFactory approach of instantiating services: A component can be used as either a singleton (i.e. MS) or a factory (i.e. MSF) by adding…
Salem
  • 13,516
  • 4
  • 51
  • 70
2
votes
1 answer

Declarative Services Strategy Pattern

I'm new at OSGI and Declarative Services, and I'm trying to implement a strategy, but I'm having trouble to get components Satisfied and/or Active My BillConfig has the useMocks(), when it's true the Repo that should be returned by the factory is…
Marco Sousa
  • 185
  • 1
  • 1
  • 9
2
votes
0 answers

Unable to deploy a Karaf kar file containing a ComponentFactory OSGi declarative service

I'm having hard time to get a simple PoC application to work in Karaf 4.2.1 and 4.0.9 (ServiceMix - 7.0.1). The application tries to create services using a org.osgi.service.component.ComponentFactory but during deployment time via Karaf's feature…
2
votes
2 answers

Updating Apache Felix SCR to OSGi Declarative Services R6 - @Property

I'm updating from Apache Felix SCR Annotations to OSGi DS R6 ones and the one is causing me more problem is the @Property inside the class. Before I had: @Component (immediate = true) @Service (A.class) public class AImpl implements A { …
Tiberio
  • 73
  • 1
  • 6
2
votes
1 answer

OSGi declarative service is active, but bind() is not called

I'm facing an issue in OSGi context with declarative services which I don't understand. I try to explain: I have a FooService which needs the FooManagerService (1..1 static). The FooManagerService references the FooService, but it's optional (0..n…
2
votes
1 answer

Why implement interface for creating Apache Felix services?

I noticed multiple ways in which developers create an Apache Felix Service. Each of the attached snippets seem to work. Would need some help to understand, which syntax is best for which scenario Sample 1: Service created without…
2
votes
1 answer

Dependency selection for DS components using configuration properties

Consider this situation: Within a network management system which is fully OSGi based and has heavily employed service layer SOA concepts, it's decided to transform NE management modules to DS components. There is a DS component in the role of a…
Hamid Nazari
  • 506
  • 1
  • 6
  • 18
2
votes
2 answers

OSGI: getting property information from DS

I have the following declarative service: @Component( immediate = false, property={"propA=valueA","propB=valueB","propC=valueC"}, scope=ServiceScope.SINGLETON ) public class ServiceImpl implements ServiceI{...} And this the code I do to…
Pavel_K
  • 10,748
  • 13
  • 73
  • 186
2
votes
1 answer

OSGi modify event method not called

I'm playing around with OSGi DS components and the ConfigurationAdmin. I created a simple configurable component @Component(service=ConfigurableService.class) public class ConfigurableService { private String message; @Activate public void…
Dirk Fauth
  • 4,128
  • 2
  • 13
  • 23
2
votes
2 answers

How to discover unsatisfied declarative services references in OSGi programmatically

How can I reach the information that is available through the "ls" and "comp [id]" commands in the OSGi console programmatically so that I can log information about unsatisfied references?
2
votes
2 answers

How to construct an OSGi service with dependencies and publish via DS

My sample classes: public class MyModel implements Model { : : } public class SingleModelProvider implements ModelProvider { public SingleModelProvider(Model providedModel, List actions) { : } } The plan is to reuse…
Robin
  • 24,062
  • 5
  • 49
  • 58
2
votes
1 answer

Best way to handle dynamic OSGi service dependencies

I have a optional service dependency that looks something like this: @Component class TestComponent { private AtomicReference testServiceRef; @Reference(type = '?') protected void setTestService(TestService testService) { …
user3284913
  • 113
  • 2