Portlet Descriptor to OSGi Service Property Map

This article maps portlet XML descriptor values to OSGi service properties for publishing OSGi Portlets.

OSGi service definitions can use properties. OSGi service properties centralize and simplify portlet configuration. They are typically represented as key-value pairs or, more generally, as a Map-like object.

Portlet spec property keys are prefixed by

javax.portlet.

Liferay property keys are prefixed by

com.liferay.portlet.

The mappings essentially flatten what is found in the XML descriptor. The property names resemble the original descriptor names.

This article covers these descriptor mappings:

The standard portlet descriptor mappings are first.

Portlet Descriptor Mappings

Note: XPath notation derived from the Portlet XSD 4 is used in this document for simplicity.

portlet.xml XPathOSGi Portlet Service Property
/portlet-app/container-runtime-optionnot supported
/portlet-app/custom-portlet-modenot supported
/portlet-app/custom-window-statenot supported
/portlet-app/default-namespacejavax.portlet.default-namespace=<String>
/portlet-app/event-definitionjavax.portlet.event-definition=<QNameLocalPart>;<QNameURI>[;<PayloadType>][,<AliasQNameLocalPart>;<AliasQNameURI>] 2
/portlet-app/filter
/portlet-app/filter/init-param/name
/portlet-app/filter-mapping
3
javax.portlet.init-param.<name>=<value> 3, 9
3
/portlet-app/public-render-parameternot supported
/portlet-app/resource-bundlenot supported
/portlet-app/security-constraintnot supported
/portlet-app/user-attributenot supported
/portlet-app/versionjavax.portlet.version=<value>
/portlet-app/portlet/async-supportedjavax.portlet.async-supported=<boolean>
/portlet-app/portlet/cache-scopenot supported
/portlet-app/portlet/container-runtime-optionjavax.portlet.container-runtime-option.<name>=<value> 2
/portlet-app/portlet/dependencyjavax.portlet.dependency=<name>;<scope>;<version> 2, 6
/portlet-app/portlet/descriptionjavax.portlet.description=<String>
/portlet-app/portlet/display-namejavax.portlet.display-name=<String>
/portlet-app/portlet/expiration-cachejavax.portlet.expiration-cache=<int>
/portlet-app/portlet/init-param/namejavax.portlet.init-param.<name>=<value>
/portlet-app/portlet/listenerjavax.portlet.listener=<listener-class>;<ordinal> 2,8
/portlet-app/portlet/multipart-config/file-size-thresholdjavax.portlet.multipart.file-size-threshold=<Integer>
/portlet-app/portlet/multipart-config/locationjavax.portlet.multipart.location=<String>
/portlet-app/portlet/multipart-config/max-file-sizejavax.portlet.multipart.max-file-size=<Long>
/portlet-app/portlet/multipart-config/max-request-sizejavax.portlet.multipart.max-request-size=<Long>
/portlet-app/portlet/portlet-class1
/portlet-app/portlet/portlet-info/keywordsjavax.portlet.info.keywords=<String>
/portlet-app/portlet/portlet-info/short-titlejavax.portlet.info.short-title=<String>
/portlet-app/portlet/portlet-info/titlejavax.portlet.info.title=<String>
/portlet-app/portlet/portlet-name 10javax.portlet.name=<String> 10
/portlet-app/portlet/portlet-preferencesjavax.portlet.preferences=<String>
OR
javax.portlet.preferences=classpath:<path_to_file_in_jar>
/portlet-app/portlet/portlet-preferences/preferences-validatorjavax.portlet.preferences-validator=<String> 1
/portlet-app/portlet/resource-bundlejavax.portlet.resource-bundle=<String>
/portlet-app/portlet/security-role-refjavax.portlet.security-role-ref=<String>[,<String>]2
/portlet-app/portlet/supported-localejavax.portlet.supported-locale=<String> 2
/portlet-app/portlet/supported-processing-eventjavax.portlet.supported-processing-event=<QNameLocalPart> OR javax.portlet.supported-processing-event=<QNameLocalPart>;<QNameURI> 2
/portlet-app/portlet/supported-public-render-parameterjavax.portlet.supported-public-render-parameter=<String>2
/portlet-app/portlet/supported-publishing-eventjavax.portlet.supported-publishing-event=<QNameLocalPart> OR javax.portlet.supported-publishing-event=<QNameLocalPart>;<QNameURI> 2
/portlet-app/portlet/supports/mime-typejavax.portlet.mime-type=<mime-type>
/portlet-app/portlet/supports/portlet-modejavax.portlet.portlet-mode=<mime-type>;<portlet-mode>[,<portlet-mode>]*
/portlet-app/portlet/supports/window-statejavax.portlet.window-state=<mime-type>;<window-state>[,<window-state>]*

Liferay Descriptor Mappings

Liferay Display

liferay-display.xml XPathOSGi Portlet Service Property
/display/category[@name]com.liferay.portlet.display-category=<value>

Liferay Portlet

Note: XPath notation derived from Liferay Portlet 5 is used in this document for simplicity.

liferay-portlet.xml XPathOSGi Liferay Portlet Service Property
/liferay-portlet-app/portlet/action-timeoutcom.liferay.portlet.action-timeout=<int>
/liferay-portlet-app/portlet/action-url-redirectcom.liferay.portlet.action-url-redirect=<boolean>
/liferay-portlet-app/portlet/activecom.liferay.portlet.active=<boolean>
/liferay-portlet-app/portlet/add-default-resourcecom.liferay.portlet.add-default-resource=<boolean>
/liferay-portlet-app/portlet/ajaxablecom.liferay.portlet.ajaxable=<boolean>
/liferay-portlet-app/portlet/asset-renderer-factory3
/liferay-portlet-app/portlet/atom-collection-adapter3
/liferay-portlet-app/portlet/autopropagated-parameterscom.liferay.portlet.autopropagated-parameters=<String>2
/liferay-portlet-app/portlet/configuration-action-class3
/liferay-portlet-app/portlet/configuration-pathcom.liferay.portlet.configuration-path=<String>
/liferay-portlet-app/portlet/control-panel-entry-categorycom.liferay.portlet.control-panel-entry-category=<String>
/liferay-portlet-app/portlet/control-panel-entry-class3
/liferay-portlet-app/portlet/control-panel-entry-weightcom.liferay.portlet.control-panel-entry-weight=<double>
/liferay-portlet-app/portlet/css-class-wrappercom.liferay.portlet.css-class-wrapper=<String>
/liferay-portlet-app/portlet/custom-attributes-display3
/liferay-portlet-app/portlet/ddm-display3
/liferay-portlet-app/portlet/facebook-integrationcom.liferay.portlet.facebook-integration=<String>
/liferay-portlet-app/portlet/footer-portal-csscom.liferay.portlet.footer-portal-css=<String>2
/liferay-portlet-app/portlet/footer-portal-javascriptcom.liferay.portlet.footer-portal-javascript=<String>2
/liferay-portlet-app/portlet/footer-portlet-csscom.liferay.portlet.footer-portlet-css=<String>2
/liferay-portlet-app/portlet/footer-portlet-javascriptcom.liferay.portlet.footer-portlet-javascript=<String>2
/liferay-portlet-app/portlet/friendly-url-mapper-class3
/liferay-portlet-app/portlet/friendly-url-mappingcom.liferay.portlet.friendly-url-mapping=<String>
/liferay-portlet-app/portlet/friendly-url-routescom.liferay.portlet.friendly-url-routes=<String>
/liferay-portlet-app/portlet/header-portal-csscom.liferay.portlet.header-portal-css=<String>2
/liferay-portlet-app/portlet/header-portal-javascriptcom.liferay.portlet.header-portal-javascript=<String>2
/liferay-portlet-app/portlet/header-portlet-csscom.liferay.portlet.header-portlet-css=<String>2
/liferay-portlet-app/portlet/header-portlet-javascriptcom.liferay.portlet.header-portlet-javascript=<String>2
/liferay-portlet-app/portlet/header-request-attribute-prefixcom.liferay.portlet.header-request-attribute-prefix=<String> 7
/liferay-portlet-app/portlet/header-timeoutheader-timeout=<int>
/liferay-portlet-app/portlet/iconcom.liferay.portlet.icon=<String>
/liferay-portlet-app/portlet/includenot supported
/liferay-portlet-app/portlet/indexer-class3
/liferay-portlet-app/portlet/instanceablecom.liferay.portlet.instanceable=<boolean>
/liferay-portlet-app/portlet/layout-cacheablecom.liferay.portlet.layout-cacheable=<boolean>
/liferay-portlet-app/portlet/maximize-editcom.liferay.portlet.maximize-edit=<boolean>
/liferay-portlet-app/portlet/maximize-helpcom.liferay.portlet.maximize-help=<boolean>
/liferay-portlet-app/portlet/open-search-class3
/liferay-portlet-app/portlet/parent-struts-pathcom.liferay.portlet.parent-struts-path=<String>
/liferay-portlet-app/portlet/permission-propagator3
/liferay-portlet-app/portlet/poller-processor-class3
/liferay-portlet-app/portlet/pop-message-listener-class3
/liferay-portlet-app/portlet/pop-up-printcom.liferay.portlet.pop-up-print=<boolean>
/liferay-portlet-app/portlet/portlet-data-handler-class3
/liferay-portlet-app/portlet/portlet-layout-listener-class3
/liferay-portlet-app/portlet/portlet-namenot supported
/liferay-portlet-app/portlet/portlet-url-class3
/liferay-portlet-app/portlet/preferences-company-widecom.liferay.portlet.preferences-company-wide=<boolean>
/liferay-portlet-app/portlet/preferences-owned-by-groupcom.liferay.portlet.preferences-owned-by-group=<boolean>
/liferay-portlet-app/portlet/preferences-unique-per-layoutcom.liferay.portlet.preferences-unique-per-layout=<boolean>
/liferay-portlet-app/portlet/private-request-attributescom.liferay.portlet.private-request-attributes=<boolean>
/liferay-portlet-app/portlet/private-session-attributescom.liferay.portlet.private-session-attributes=<boolean>
/liferay-portlet-app/portlet/remoteablecom.liferay.portlet.remoteable=<boolean>
/liferay-portlet-app/portlet/render-timeoutcom.liferay.portlet.render-timeout=<int>
/liferay-portlet-app/portlet/render-weightcom.liferay.portlet.render-weight=<int>
/liferay-portlet-app/portlet/requires-namespaced-parameterscom.liferay.portlet.requires-namespaced-parameters=<boolean>
/liferay-portlet-app/portlet/restore-current-viewcom.liferay.portlet.restore-current-view=<boolean>
/liferay-portlet-app/portlet/scheduler-entry3
/liferay-portlet-app/portlet/scopeablecom.liferay.portlet.scopeable=<boolean>
/liferay-portlet-app/portlet/show-portlet-access-deniedcom.liferay.portlet.show-portlet-access-denied=<boolean>
/liferay-portlet-app/portlet/show-portlet-inactivecom.liferay.portlet.show-portlet-inactive=<boolean>
/liferay-portlet-app/portlet/single-page-applicationcom.liferay.portlet.single-page-application=<boolean>
/liferay-portlet-app/portlet/social-activity-interpreter-class3
/liferay-portlet-app/portlet/social-request-interpreter-class3
/liferay-portlet-app/portlet/social-interactions-configuration3
/liferay-portlet-app/portlet/staged-model-data-handler-class3
/liferay-portlet-app/portlet/struts-pathcom.liferay.portlet.struts-path=<String>
/liferay-portlet-app/portlet/systemcom.liferay.portlet.system=<boolean>
/liferay-portlet-app/portlet/template-handler3
/liferay-portlet-app/portlet/trash-handler3
/liferay-portlet-app/portlet/url-encoder-class3
/liferay-portlet-app/portlet/use-default-templatecom.liferay.portlet.use-default-template=<boolean>
/liferay-portlet-app/portlet/user-notification-definitionsnot supported
/liferay-portlet-app/portlet/user-notification-handler-class3
/liferay-portlet-app/portlet/user-principal-strategycom.liferay.portlet.user-principal-strategy=<String>
/liferay-portlet-app/portlet/virtual-pathcom.liferay.portlet.virtual-path=<String>
/liferay-portlet-app/portlet/webdav-storage-class3
/liferay-portlet-app/portlet/webdav-storage-tokennot supported
/liferay-portlet-app/portlet/workflow-handler3
/liferay-portlet-app/portlet/xml-rpc-method-class3
  • [1] Portlets are registered as concrete objects.

  • [2] Multiples of these properties may be used. This results in an array of values.

  • [3] This type is registered as an OSGi service.

  • [4] https://xmlns.jcp.org/xml/ns/portlet/portlet-app_3_0.xsd

  • [5] http://www.liferay.com/dtd/liferay-portlet-app_7_1_0.dtd

  • [6] Here’s an example of using multiple javax.portlet.dependency properties.

    Old:

    <portlet>
    	...
    	<dependency>
    		<name>jquery</name>
    		<scope>com.jquery</scope>
    		<version>2.1.1</version>
    	</dependency>
    	<dependency>
    		<name>jsutil</name>
    		<scope>com.mycompany</scope>
    		<version>1.0.0</version>
    	</dependency>
    	...
    </portlet>
    

    New:

    @Component(
        immediate = true, property = {
            "javax.portlet.name=my_portlet",
            "javax.portlet.display-name=my-portlet",
            "javax.portlet.dependency=jquery;com.jquery;2.1.1",
            "javax.portlet.dependency=jsutil;com.mycompany;1.0.0"
        }, service = Portlet.class
    )
    public class MyPortlet extends GenericPortlet {
        ...
    } 
    
  • [7] Here’s an example for the com.liferay.portlet.header-request-attribute-prefix property.

    Old:

    <portlet>
    	...
    	<header-request-attribute-prefix>com.mycompany</header-request-attribute-prefix>
    	...
    </portlet>
    

    New:

    @Component(
        immediate = true, property = {
            "javax.portlet.name=my_portlet",
            "javax.portlet.display-name=my-portlet",
            "javax.portlet.dependency=jquery;com.jquery;2.1.1",
            "javax.portlet.dependency=jsutil;com.mycompany;1.0.0",
            "com.liferay.portlet.header-request-attribute-prefix=com.mycompany"
        }, service = Portlet.class
    )
    public class MyPortlet extends GenericPortlet {
        ...
    } 
    
  • [8] Here’s an example for the javax.portlet.listener property.

    Old:

    <portlet>
        ...
        <listener>
            <listener-class>com.mycompany.MyPortletURLGenerationListener</listener-class>
            <ordinal>1</ordinal>
        </listener>
        ...
    </portlet>
    

    New:

    @Component(
        immediate = true,
        property = {"javax.portlet.name=myPortlet",
            "javax.portlet.listener=com.mycompany.MyPortletURLGenerationListener;1"
        }, service = Portlet.class
    )
    public class MyPortlet extends GenericPortlet {
        ...
    } 
    
  • [9] An javax.portlet.init-param property can be declared like this:

    @Component(
        immediate = true,
        property = {"javax.portlet.name=myPortlet", 
            "javax.portlet.init-param.myInitParam=1234"},
        service = PortletFilter.class
    )
    public class MyFilter implements RenderFilter {
        ...
    }
    
  • [10] Liferay DXP creates each portlet’s ID based on the portlet’s name (i.e., the portlet-name descriptor in liferay-portlet.xml or the javax.portlet.name OSGi service property). Dashes, periods, and spaces are allowed in the portlet name, but they and all other JavaScript unsafe characters are stripped from the name value that’s used for the portlet ID. Therefore, make your portlet name unique in light of the characters that are removed. Otherwise, if you try to deploy a portlet whose ID is the same as a portlet that’s already deployed, your portlet deployment fails and Liferay DXP logs a message like this:

    Portlet id [portletId] is already in use
    
« Third Party Packages Portal ExportsClasses Moved from portal-service.jar »
Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0