clientMO.xsl revision bb8874d71cdd8e5288297b9727703437c6dfcfed
0N/A<!--
0N/A ! CDDL HEADER START
0N/A !
0N/A ! The contents of this file are subject to the terms of the
0N/A ! Common Development and Distribution License, Version 1.0 only
0N/A ! (the "License"). You may not use this file except in compliance
0N/A ! with the License.
0N/A !
0N/A ! You can obtain a copy of the license at
0N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
0N/A ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
0N/A ! See the License for the specific language governing permissions
0N/A ! and limitations under the License.
0N/A !
0N/A ! When distributing Covered Code, include this CDDL HEADER in each
0N/A ! file and include the License file at
0N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
0N/A ! add the following below this CDDL HEADER, with the fields enclosed
0N/A ! by brackets "[]" replaced with your own identifying information:
0N/A ! Portions Copyright [yyyy] [name of copyright owner]
0N/A !
0N/A ! CDDL HEADER END
0N/A !
0N/A !
0N/A ! Portions Copyright 2007 Sun Microsystems, Inc.
0N/A ! -->
0N/A<xsl:stylesheet version="1.0" xmlns:adm="http://www.opends.org/admin"
0N/A xmlns:admpp="http://www.opends.org/admin-preprocessor"
0N/A xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
0N/A <xsl:import href="java-utilities.xsl" />
0N/A <xsl:import href="preprocessor.xsl" />
0N/A <xsl:import href="property-types.xsl" />
0N/A <xsl:output method="text" encoding="us-ascii" />
0N/A <!--
0N/A Template for generating the interface declaration.
0N/A -->
0N/A <xsl:template name="generate-interface-declaration">
0N/A <xsl:value-of select="'/**&#xa;'" />
0N/A <xsl:call-template name="add-java-comment">
0N/A <xsl:with-param name="indent-text" select="' *'" />
0N/A <xsl:with-param name="content"
0N/A select="concat('A client-side interface for reading and modifying ',
0N/A $this-ufn, ' settings.')" />
0N/A </xsl:call-template>
0N/A <xsl:value-of select="' * &lt;p&gt;&#xa;'" />
0N/A <xsl:call-template name="add-java-comment">
0N/A <xsl:with-param name="indent-text" select="' *'" />
0N/A <xsl:with-param name="content" select="$this/adm:synopsis" />
0N/A </xsl:call-template>
0N/A <xsl:value-of select="' */&#xa;'" />
0N/A <xsl:value-of
0N/A select="concat('public interface ',
0N/A $this-java-class,
0N/A 'CfgClient extends ')" />
0N/A <xsl:choose>
0N/A <xsl:when test="boolean($this/@extends)">
0N/A <xsl:value-of select="concat($parent-java-class,'CfgClient ')" />
0N/A </xsl:when>
0N/A <xsl:otherwise>
0N/A <xsl:value-of select="'ConfigurationClient '" />
0N/A </xsl:otherwise>
0N/A </xsl:choose>
0N/A <xsl:text>{&#xa;</xsl:text>
0N/A </xsl:template>
0N/A <!--
0N/A Template for generating the configuration definition getter.
0N/A -->
0N/A <xsl:template name="generate-configuration-definition-getter">
0N/A <xsl:value-of
0N/A select="concat(' /**&#xa;',
0N/A ' * Get the configuration definition associated with this ', $this-ufn, '.&#xa;',
0N/A ' *&#xa;',
0N/A ' * @return Returns the configuration definition associated with this ', $this-ufn, '.&#xa;',
0N/A ' */&#xa;')" />
0N/A <xsl:value-of
0N/A select="concat(' ManagedObjectDefinition&lt;? extends ', $this-java-class,'CfgClient, ? extends ', $this-java-class,'Cfg&gt; definition();&#xa;')" />
0N/A </xsl:template>
0N/A <!--
0N/A Template for generating the relation getter declarations.
0N/A -->
0N/A <xsl:template name="generate-relation-declarations">
0N/A <xsl:variable name="name" select="@name" />
0N/A <xsl:variable name="ufn">
0N/A <xsl:call-template name="name-to-ufn">
0N/A <xsl:with-param name="value" select="$name" />
0N/A </xsl:call-template>
0N/A </xsl:variable>
0N/A <xsl:variable name="java-relation-name">
0N/A <xsl:call-template name="name-to-java">
0N/A <xsl:with-param name="value" select="$name" />
0N/A </xsl:call-template>
0N/A </xsl:variable>
0N/A <xsl:variable name="java-class-name">
0N/A <xsl:call-template name="name-to-java">
0N/A <xsl:with-param name="value" select="@managed-object-name" />
0N/A </xsl:call-template>
0N/A </xsl:variable>
0N/A <xsl:choose>
0N/A <xsl:when test="adm:one-to-one">
0N/A <xsl:value-of
0N/A select="concat(' /**&#xa;',
0N/A ' * Gets the ', $ufn,'.&#xa;',
0N/A ' *&#xa;',
0N/A ' * @return Returns the ', $ufn,'.&#xa;',
0N/A ' * @throws OperationsException&#xa;',
0N/A ' * If the ', $ufn,' could not be read due to some&#xa;',
0N/A ' * underlying communication problem.&#xa;',
0N/A ' */&#xa;')" />
0N/A <xsl:value-of
0N/A select="concat(' ', $java-class-name, 'CfgClient get',
0N/A $java-relation-name, '() throws OperationsException;&#xa;')" />
0N/A </xsl:when>
0N/A <xsl:when test="adm:one-to-zero-or-one">
0N/A <xsl:value-of
0N/A select="concat(' /**&#xa;',
0N/A ' * Determines whether or not the ', $ufn,' exists.&#xa;',
0N/A ' *&#xa;',
0N/A ' * @return Returns &lt;true&gt; if the ', $ufn,' exists.&#xa;',
0N/A ' * @throws OperationsException&#xa;',
0N/A ' * If the determination could not be made&#xa;',
0N/A ' * due to some underlying communication problem.&#xa;',
0N/A ' */&#xa;')" />
0N/A <xsl:value-of
0N/A select="concat(' boolean has',
0N/A $java-relation-name, '() throws OperationsException;&#xa;')" />
0N/A <xsl:text>&#xa;</xsl:text>
0N/A <xsl:text>&#xa;</xsl:text>
0N/A <xsl:text>&#xa;</xsl:text>
0N/A <xsl:value-of
0N/A select="concat(' /**&#xa;',
0N/A ' * Gets the ', $ufn,' if it is present.&#xa;',
0N/A ' *&#xa;',
0N/A ' * @return Returns the ', $ufn,' if it is present.&#xa;',
0N/A ' * @throws OperationsException&#xa;',
0N/A ' * If the ', $ufn,' does not exist or could not be read&#xa;',
0N/A ' * due to some underlying communication problem.&#xa;',
0N/A ' */&#xa;')" />
<xsl:value-of
select="concat(' ', $java-class-name, 'CfgClient get',
$java-relation-name, '() throws OperationsException;&#xa;')" />
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:value-of
select="concat(' /**&#xa;',
' * Creates the ', $ufn,' if it does not exist yet.&#xa;',
' *&#xa;',
' * @param &lt;C&gt;&#xa;',
' * The type of the ', $ufn,' being added.&#xa;',
' * @param d&#xa;',
' * The definition of the ', $ufn,' to be created.&#xa;',
' * @param p&#xa;',
' * A property provider which can be used to initialize&#xa;',
' * the property values of the new ', $ufn,'.&#xa;',
' * @return Returns the ', $ufn,' instance representing the&#xa;',
' * ', $ufn,' that was created.&#xa;',
' * @throws OperationsException&#xa;',
' * If the ', $ufn,' already exists or could not be created&#xa;',
' * due to some underlying communication problem.&#xa;',
' */&#xa;')" />
<xsl:value-of
select="concat(' &lt;C extends ', $java-class-name,'CfgClient&gt; C create', $java-relation-name, '(&#xa;',
' ManagedObjectDefinition&lt;C, ?&gt; d, PropertyProvider p) throws OperationsException;&#xa;')" />
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:value-of
select="concat(' /**&#xa;',
' * Removes the ', $ufn,' if it exists.&#xa;',
' *&#xa;',
' * @throws OperationsException&#xa;',
' * If the ', $ufn,' does not exist or could not be removed&#xa;',
' * due to some underlying communication problem.&#xa;',
' */&#xa;')" />
<xsl:value-of
select="concat(' void remove',
$java-relation-name, '() throws OperationsException;&#xa;')" />
</xsl:when>
<xsl:when test="adm:one-to-many">
<xsl:variable name="plural-name"
select="adm:one-to-many/@plural-name" />
<xsl:variable name="ufpn">
<xsl:call-template name="name-to-ufn">
<xsl:with-param name="value" select="$plural-name" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="java-relation-plural-name">
<xsl:call-template name="name-to-java">
<xsl:with-param name="value" select="$plural-name" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of
select="concat(' /**&#xa;',
' * Lists the ', $ufpn,'.&#xa;',
' *&#xa;',
' * @return Returns an array containing the names of the&#xa;',
' * ', $ufpn,'.&#xa;',
' * @throws OperationsException&#xa;',
' * If the ', $ufpn,' could not be listed due to some&#xa;',
' * underlying communication problem.&#xa;',
' */&#xa;')" />
<xsl:value-of
select="concat(' String[] list',
$java-relation-plural-name, '() throws OperationsException;&#xa;')" />
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:value-of
select="concat(' /**&#xa;',
' * Gets the named ', $ufn,'.&#xa;',
' *&#xa;',
' * @param name&#xa;',
' * The name of the ', $ufn,' to retrieve.&#xa;',
' * @return Returns the named ', $ufn,'.&#xa;',
' * @throws OperationsException&#xa;',
' * If the ', $ufn,' does not exist or could not be read&#xa;',
' * due to some underlying communication problem.&#xa;',
' */&#xa;')" />
<xsl:value-of
select="concat(' ', $java-class-name, 'CfgClient get',
$java-relation-name, '(String name) throws OperationsException;&#xa;')" />
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:value-of
select="concat(' /**&#xa;',
' * Creates a new ', $ufn,'.&#xa;',
' *&#xa;',
' * @param &lt;C&gt;&#xa;',
' * The type of the ', $ufn,' being added.&#xa;',
' * @param d&#xa;',
' * The definition of the ', $ufn,' to be created.&#xa;',
' * @param name&#xa;',
' * The name of the new ', $ufn,'.&#xa;',
' * @param p&#xa;',
' * A property provider which can be used to initialize&#xa;',
' * the property values of the new ', $ufn,'.&#xa;',
' * @return Returns a new ', $ufn,' instance representing the&#xa;',
' * ', $ufn,' that was created.&#xa;',
' * @throws OperationsException&#xa;',
' * If the ', $ufn,' already exists or could not be created&#xa;',
' * due to some underlying communication problem.&#xa;',
' */&#xa;')" />
<xsl:value-of
select="concat(' &lt;C extends ', $java-class-name,'CfgClient&gt; C create', $java-relation-name, '(&#xa;',
' ManagedObjectDefinition&lt;C, ?&gt; d, String name, PropertyProvider p) throws OperationsException;&#xa;')" />
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:value-of
select="concat(' /**&#xa;',
' * Removes the named ', $ufn,'.&#xa;',
' *&#xa;',
' * @param name&#xa;',
' * The name of the ', $ufn,' to remove.&#xa;',
' * @throws OperationsException&#xa;',
' * If the ', $ufn,' does not exist or could not be removed&#xa;',
' * due to some underlying communication problem.&#xa;',
' */&#xa;')" />
<xsl:value-of
select="concat(' void remove',
$java-relation-name, '(String name) throws OperationsException;&#xa;')" />
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
<xsl:value-of
select="concat('Unknown relation type &quot;', local-name(*), '&quot; in relation &quot;', $name, '&quot;.')" />
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
Main document parsing template.
-->
<xsl:template match="/">
<xsl:call-template name="copyright-notice" />
<xsl:value-of
select="concat('package ', $this-package, '.client;&#xa;')" />
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:call-template name="generate-import-statements">
<xsl:with-param name="imports">
<xsl:for-each select="$this-local-properties">
<xsl:call-template name="get-property-java-imports" />
</xsl:for-each>
<xsl:if test="$this-local-properties[@multi-valued='true']">
<import>java.util.Collection</import>
<import>java.util.SortedSet</import>
</xsl:if>
<xsl:if test="$this-local-properties[not(@read-only='true')]">
<import>
org.opends.server.admin.IllegalPropertyValueException
</import>
</xsl:if>
<xsl:if test="$this-local-relations">
<import>org.opends.server.admin.OperationsException</import>
</xsl:if>
<xsl:if
test="$this-local-relations/adm:one-to-zero-or-one|$this-local-relations/adm:one-to-many">
<import>org.opends.server.admin.PropertyProvider</import>
</xsl:if>
<xsl:choose>
<xsl:when test="$this/@extends">
<xsl:if test="$parent-package != $this-package">
<xsl:element name="import">
<xsl:value-of
select="concat($parent-package, '.client.', $parent-java-class, 'CfgClient')" />
</xsl:element>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<import>org.opends.server.admin.ConfigurationClient</import>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="import">
<xsl:value-of
select="concat($this-package, '.server.', $this-java-class, 'Cfg')" />
</xsl:element>
<import>org.opends.server.admin.ManagedObjectDefinition</import>
</xsl:with-param>
</xsl:call-template>
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:call-template name="generate-interface-declaration" />
<xsl:text>&#xa;</xsl:text>
<xsl:call-template name="generate-configuration-definition-getter" />
<xsl:for-each select="$this-local-properties">
<xsl:sort select="@name" />
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:call-template name="generate-property-getter-declaration">
<xsl:with-param name="interface" select="'client'" />
</xsl:call-template>
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:call-template name="generate-property-setter-declaration" />
</xsl:for-each>
<xsl:for-each select="$this-local-relations">
<xsl:sort select="@name" />
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:call-template name="generate-relation-declarations" />
</xsl:for-each>
<xsl:text>&#xa;</xsl:text>
<xsl:text>}&#xa;</xsl:text>
</xsl:template>
</xsl:stylesheet>