I'm Migrating from Felix SCR Annotations to R6 OSGI Declarative Services but the Service is not listed inside karaf .As per below code SampleServiceImpl should list is karaf .But it is not listing . Is there any other configuration i have to in pom.xml ?
package com.sample.test;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.osgi.service.component.annotations.ConfigurationPolicy;
import org.osgi.service.component.annotations.Deactivate;
@Component (configurationPolicy = ConfigurationPolicy.OPTIONAL, immediate = true, service = SampleService.class)
public class SampleServiceImpl implements SampleService
{
@Reference (policy = ReferencePolicy.DYNAMIC, service = AgentService.class , bind = "bindAgentService",unbind ="unbindAgentService")
private AgentService agentService;
@Activate
protected void activate() {
System.out.println("activate ");
}
@Deactivate
protected void deactivate() {
System.out.println("de-activate ");
}
}
This is the pom.xml I am using .
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>com.test.sample</groupId>
<artifactId>compile</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>