我一直在使用this http://helpx.adobe.com/experience-manager/using/using-query-builder-api1.html教程作为参考。
我碰到this http://felix.apache.org/documentation/subprojects/apache-felix-service-component-runtime.html关于 Felix 服务组件运行时 (SCR)
所以我实施了以下
protected void activate(ComponentContext context) {
LOGGER.info("activating {}", this.getClass().getName());
}
protected void unbindQueryBuilder(QueryBuilder queryBuilder) {
this.queryBuilder = null;
}
protected void bindQueryBuilder(QueryBuilder queryBuilder) {
this.queryBuilder = queryBuilder;
}
成功了!因此,经过仔细调查,我了解到这些绑定/取消绑定方法实际上应该是由 maven-scr-plugin 生成的,我的版本是 1.6.0
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>
<goals>
<goal>scr</goal>
</goals>
<configuration>
<!-- Private service properties for all services. -->
<properties>
<service.vendor>Adobe</service.vendor>
</properties>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies>
</plugin>
对于注释我有 1.4.0
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<version>1.4.0</version>
<scope>provided</scope>
</dependency>
所以虽然我不确定为什么没有生成绑定/取消绑定方法,但我知道它们应该是,所以我手动生成它们。
Update我尝试将 maven-scr-plugin 更新到版本 1.20.0,这在 mvn build 期间产生了以下错误
[ERROR] Project depends on org.apache.felix:org.apache.felix.scr.annotations:jar:1.4.0:provided
[ERROR] Minimum required version is 1.9.0
所以...我将 org.apache.felix.scr.annotations 更新到 1.9.0。它有效!我的绑定/取消绑定访问器已生成,一切都很好。但是,我很担心,不知道是否应该使用 org.apache.felix.scr.annotations 的 1.9.0 版本,因为我将其标记为provided
在 Maven 依赖项中,当我查看 cq 实例上安装的 OSGi 包时,我看到以下内容
Apache Felix Declarative Services (org.apache.felix.scr) : Version 1.6.3.R1409029