我将AEM 6.1应用程序迁移到AEM 6.3。由于Felix注释(org.apache.felix.scr.annotations。*)已被弃用,我决定将我的组件迁移到OSGi注释(org.osgi.service.component.annotations。*)。AEM 6.3 - 将Felix迁移到OSGi注释:如何处理propertyPrivate?
一旦我想清楚它是如何工作的,它很容易。但有一种情况我不知道如何处理:属性propertyPriavte = true。
旧的实现看起来是这样的:
@Component(metatype = true)
@Service(Servlet.class)
@Properties({
@Property(name = "sling.servlet.selectors", value = "overlay", propertyPrivate = true),
})
public class OverlayServletImpl extends OverlayServlet {
...
}
酒店sling.servlet.selectors不会在该AEM控制台配置管理器配置的,但它是可配置由于配置文件, 对?所以,我仍然需要定义这个属性。
对于其他属性我改变了我实现这样的:
// OverlayServletImpl
@Component(
service = Servlet.class,
configurationPid = "my.package.path.OverlayServletImpl"
)
@Designate(
ocd = OverlayServletImplConfiguration.class
)
public class OverlayServletImpl extends OverlayServlet {
...
}
// Configuration
@ObjectClassDefinition(name = "Overlay Servlet")
public @interface OverlayServletImplConfiguration {
String sling_servlet_selectors() default "overlay";
...
}
现在,我的财产sling.servlet.selectors,但它也可以在配置管理器,它的价值才会有改变。但我不想那样。
我该怎么做?这可能与OSGi注释?
谢谢,最好的问候!
你有相关的OSGI注释迁移任何文件?我也从AEM6.1迁移到6.3 ..是否有必要迁移它们? – Sara
你好! Felix注释已弃用,但它们仍在AEM 6.3中工作。这意味着它没有必要迁移它们,但它将在未来的AEM版本中。 作为文件,我推荐以下页面[AEM官方OSGI宣言服务注释](http://www.nateyolles.com/blog/2017/05/osgi-declarative-services-annotations-in-aem)。还有一个GitHub项目的链接,该项目显示了如何使用Felix注释和官方OSGi注释来实现同样的服务。这对我的迁移帮助很大。 – user2960606