我將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