Portletは、Portlet Applicationという単位で、WARファイル形式でアーカイブされます。これはWeb Applicationの一種で、1つ以上のPortletと単一のPortlet配備記述子(portlet.xml)を含みます。さらに、Servlet、JSP、HTML、またはクラスライブラリ、その他のリソースなども含めることができます。以下に、標準的なPortlet Applicationディレクトリの構成例を示します。
/WEB-INF/web.xml |
web.xml
アプリケーションの名前やServlet定義などを記述します。
portlet.xml
アプリケーションに含まれるすべてのPortletと関連する定義を記述します。以下に、基本的なportlet.xmlファイルの例を示します。
<?xml version="1.0" encoding="UTF-8"?> <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"> <portlet> <portlet-name>Sample</portlet-name> <portlet-class>portlets.Sample</portlet-class> <expiration-cache>-1</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>VIEW</portlet-mode> <portlet-mode>EDIT</portlet-mode> <portlet-mode>HELP</portlet-mode> </supports> <portlet-info> <title>Sample Portlet</title> </portlet-info> </portlet> </portlet-app>
<portlet-app>
portlet.xmlのルート要素です。必ず記述します。
<portlet>
このタグ内に個々のPortletの情報を記述します。
<portlet-name>
Portletの名前を記述します。
<portlet-class>
Portletのクラス名(パッケージ名も含む)を記述します。
<expiration-cache>
コンテンツをキャッシュする時間を記述します。
“-1”が指定された場合、無制限にキャッシュします。
“0”を指定された場合、キャッシュしません。
単位は秒数です。(300と記述した場合は5分です。)
<supports>
PortletでサポートするContent-TypeとPortlet Modeの組を記述します。
<portlet-info>
Portletのタイトルなどの情報を記述します。
その他の定義可能な項目については、“Java Portlet Specification”の“21章 Packaging and Deployment Descriptor”を参照してください。