问题描述
我正在从 Felix SCR 注释迁移到 R6 OSGI 声明性服务,但该服务未在 karaf 中列出。根据下面的代码 SampleServiceImpl 应该列出的是 karaf 。但它没有列出。 在 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 ");
}
}
这是我正在使用的 pom.xml。
<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>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)