Liferay DXP 中的 ConfigurationAPI 可以用于 Plugin sdk portlet 吗?

Can the ConfigurationAPI in Liferay DXP be used for Plugin sdk portlet?

我已按照给出的 2 个教程在使用 Ant/Ivy 构建的 Liferay dxp 插件 SDK portlet 中使用 COnfigurationAPI。 COnfiguration API 1 COnfiguration API 2.

下面是class使用的配置:

package com.preferences.interfaces;

import com.liferay.portal.configuration.metatype.annotations.ExtendedObjectClassDefinition;

import aQute.bnd.annotation.metatype.Meta;

@ExtendedObjectClassDefinition(
    category = "preferences",
    scope = ExtendedObjectClassDefinition.Scope.GROUP
)
@Meta.OCD(
    id = "com.preferences.interfaces.UnsupportedBrowserGroupServiceConfiguration",
    name = "UnsupportedBrowser.group.service.configuration.name"
)
public interface UnsupportedBrowserGroupServiceConfiguration {

    @Meta.AD(deflt = "", required = false)
    public String displayStyle();

    @Meta.AD(deflt = "0", required = false)
    public long displayStyleGroupId(long defaultDisplayStyleGroupId);

}

Post 按照步骤操作,我收到以下错误:

ERROR [CM Configuration Updater (ManagedService Update: pid=[com.preferences.interfaces.UnsupportedBrowserGroupServiceConfiguration])][org_apache_felix_configadmin:97] [org.osgi.service.cm.ManagedService, id=7082, bundle=297//com.liferay.portal.configuration.settings-2.0.15.jar?lpkgPath=C:\dev\Liferay\osgi\marketplace\Liferay Foundation.lpkg]: Unexpected problem updating configuration com.preferences.interfaces.UnsupportedBrowserGroupServiceConfiguration {org.osgi.service.cm.ConfigurationAdmin}={service.vendor=Apache Software Foundation, service.pid=org.apache.felix.cm.ConfigurationAdmin, service.description=Configuration Admin Service Specification 1.2 Implementation, service.id=56, service.bundleid=643, service.scope=bundle}

Caused by: java.lang.IllegalArgumentException: wrong number of arguments

那么,这个过程是否需要一个强制性的 osgi 模块,或者我们也可以使用使用 ant 构建的 plusings sdk portlet 来完成?

不分析错误信息Caused by: java.lang.IllegalArgumentException: wrong number of arguments

您构建插件的方式(Ant、Maven、Gradle,手动)没有区别,只要您构建的插件能被运行时理解。 aQute.bnd.annotation.metatype.Meta 坚定地指向 OSGi 世界,并且几乎可以肯定您将需要一个 OSGi 模块。当然,您可以使用 Ant 构建它。即使在 Ant 中,您也可以嵌入像 bnd 这样的工具,或者您可以编写适当的 Manifest.mf 以手动包含在您的模块中(开玩笑 - 您不想手动执行,但它会起作用)。

建议:不要移动所有内容:尝试在 gradle 或更好的 Liferay Workspace(基于 gradle)中使用最小示例重现此内容,只是为了获得所有自动布线. 检查它是否有所不同,并将 Ant 构建过程生成的输出与工作区输出进行比较。特别注意清单。

为了构建正确的 Manifest,您想要使用 bnd - 如果 Manifest 最终成为您的问题:找到一种拥抱 bnd 的方法 - 如果那是通过与 Ant 说再见,或者通过调整您的构建脚本由您决定。