serverMO.xsl revision bb8874d71cdd8e5288297b9727703437c6dfcfed
1177N/A<!--
1177N/A ! CDDL HEADER START
1177N/A !
1177N/A ! The contents of this file are subject to the terms of the
1177N/A ! Common Development and Distribution License, Version 1.0 only
1177N/A ! (the "License"). You may not use this file except in compliance
1177N/A ! with the License.
1177N/A !
1177N/A ! You can obtain a copy of the license at
1177N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
1177N/A ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
1177N/A ! See the License for the specific language governing permissions
1177N/A ! and limitations under the License.
1177N/A !
1177N/A ! When distributing Covered Code, include this CDDL HEADER in each
1177N/A ! file and include the License file at
1177N/A ! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
1177N/A ! add the following below this CDDL HEADER, with the fields enclosed
1177N/A ! by brackets "[]" replaced with your own identifying information:
1177N/A ! Portions Copyright [yyyy] [name of copyright owner]
1177N/A !
1177N/A ! CDDL HEADER END
1177N/A !
1177N/A !
4134N/A ! Portions Copyright 2007 Sun Microsystems, Inc.
1177N/A ! -->
1177N/A<xsl:stylesheet version="1.0" xmlns:adm="http://www.opends.org/admin"
1177N/A xmlns:admpp="http://www.opends.org/admin-preprocessor"
4134N/A xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
1177N/A <xsl:import href="java-utilities.xsl" />
1177N/A <xsl:import href="preprocessor.xsl" />
1177N/A <xsl:import href="property-types.xsl" />
4134N/A <xsl:output method="text" encoding="us-ascii" />
4134N/A <!--
4134N/A Template for generating the interface declaration.
4134N/A -->
4134N/A <xsl:template name="generate-interface-declaration">
4134N/A <xsl:value-of select="'/**&#xa;'" />
4134N/A <xsl:call-template name="add-java-comment">
4134N/A <xsl:with-param name="indent-text" select="' *'" />
4134N/A <xsl:with-param name="content"
1177N/A select="concat('A server-side interface for querying ', $this-ufn,
1177N/A ' settings.')" />
1177N/A </xsl:call-template>
1177N/A <xsl:value-of select="' * &lt;p&gt;&#xa;'" />
1177N/A <xsl:call-template name="add-java-comment">
1177N/A <xsl:with-param name="indent-text" select="' *'" />
1177N/A <xsl:with-param name="content" select="$this/adm:synopsis" />
1177N/A </xsl:call-template>
2095N/A <xsl:value-of select="' */&#xa;'" />
2095N/A <xsl:value-of
2095N/A select="concat('public interface ',
2095N/A $this-java-class ,
2095N/A 'Cfg extends ')" />
1177N/A <xsl:choose>
1177N/A <xsl:when test="boolean($this/@extends)">
1177N/A <xsl:value-of select="concat($parent-java-class,'Cfg ')" />
1400N/A </xsl:when>
1400N/A <xsl:otherwise>
1400N/A <xsl:value-of select="'Configuration '" />
1400N/A </xsl:otherwise>
1400N/A </xsl:choose>
1177N/A <xsl:text>{&#xa;</xsl:text>
1177N/A </xsl:template>
1177N/A <!--
1177N/A Template for generating the configuration definition getter.
1177N/A -->
1177N/A <xsl:template name="generate-configuration-definition-getter">
1177N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
1177N/A ' * Get the configuration definition associated with this ', $this-ufn, '.&#xa;',
1177N/A ' *&#xa;',
1177N/A ' * @return Returns the configuration definition associated with this ', $this-ufn, '.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' ManagedObjectDefinition&lt;? extends ', $this-java-class,'CfgClient, ? extends ', $this-java-class,'Cfg&gt; definition();&#xa;')" />
1177N/A </xsl:template>
1177N/A <!--
1177N/A Template for generating the change listener declaration.
1177N/A -->
1177N/A <xsl:template name="generate-change-listener-declaration">
1177N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
1177N/A ' * Register to be notified when this ', $this-ufn,' is changed.&#xa;',
1177N/A ' *&#xa;',
1177N/A ' * @param listener&#xa;',
1177N/A ' * The ', $this-ufn,' configuration change listener.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' void add', $this-short-java-class,
1177N/A 'ChangeListener(ConfigurationChangeListener&lt;',
1177N/A $this-java-class,'Cfg&gt; listener);&#xa;')" />
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
1177N/A ' * Deregister an existing ', $this-ufn,' configuration change listener.&#xa;',
1177N/A ' *&#xa;',
1177N/A ' * @param listener&#xa;',
1177N/A ' * The ', $this-ufn,' configuration change listener.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' void remove', $this-short-java-class,
1177N/A 'ChangeListener(ConfigurationChangeListener&lt;',
1177N/A $this-java-class,'Cfg&gt; listener);&#xa;')" />
1177N/A </xsl:template>
1177N/A <!--
1177N/A Template for generating the relation getter declarations.
1177N/A -->
1177N/A <xsl:template name="generate-relation-declarations">
1177N/A <xsl:variable name="name" select="@name" />
1177N/A <xsl:variable name="ufn">
1177N/A <xsl:call-template name="name-to-ufn">
1177N/A <xsl:with-param name="value" select="$name" />
1177N/A </xsl:call-template>
1177N/A </xsl:variable>
1177N/A <xsl:variable name="java-relation-name">
1177N/A <xsl:call-template name="name-to-java">
1177N/A <xsl:with-param name="value" select="$name" />
1177N/A </xsl:call-template>
1177N/A </xsl:variable>
1177N/A <xsl:variable name="java-class-name">
1177N/A <xsl:call-template name="name-to-java">
1177N/A <xsl:with-param name="value" select="@managed-object-name" />
1177N/A </xsl:call-template>
1177N/A </xsl:variable>
1177N/A <xsl:choose>
1177N/A <xsl:when test="adm:one-to-one">
1177N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
1177N/A ' * Gets the ', $ufn,'.&#xa;',
1177N/A ' *&#xa;',
1177N/A ' * @return Returns the ', $ufn,'.&#xa;',
1177N/A ' * @throws ConfigException&#xa;',
1177N/A ' * If the ', $ufn,' could not be found or it could not&#xa;',
1177N/A ' * be successfully decoded.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' ', $java-class-name, 'Cfg get',
1177N/A $java-relation-name, '() throws ConfigException;&#xa;')" />
1177N/A </xsl:when>
1177N/A <xsl:when test="adm:one-to-zero-or-one">
1177N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
1177N/A ' * Determines whether or not the ', $ufn,' exists.&#xa;',
1177N/A ' *&#xa;',
1177N/A ' * @return Returns &lt;true&gt; if the ', $ufn,' exists.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' boolean has',
1177N/A $java-relation-name, '();&#xa;')" />
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
1177N/A ' * Gets the ', $ufn,' if it is present.&#xa;',
1177N/A ' *&#xa;',
1177N/A ' * @return Returns the ', $ufn,' if it is present.&#xa;',
1177N/A ' * @throws ConfigException&#xa;',
1177N/A ' * If the ', $ufn,' does not exist or it could not&#xa;',
1177N/A ' * be successfully decoded.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' ', $java-class-name, 'Cfg get',
1177N/A $java-relation-name, '() throws ConfigException;&#xa;')" />
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
4134N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
1177N/A ' * Registers to be notified when the ', $ufn,' is added.&#xa;',
1177N/A ' *&#xa;',
1177N/A ' * @param listener&#xa;',
1177N/A ' * The ', $ufn,' configuration add listener.&#xa;',
1177N/A ' * @throws ConfigException&#xa;',
1177N/A ' * If the add listener could not be registered.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' void add', $java-relation-name,
1177N/A 'AddListener(ConfigurationAddListener&lt;',
1177N/A $java-class-name,'Cfg&gt; listener) throws ConfigException;&#xa;')" />
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
1177N/A ' * Deregisters an existing ', $ufn,' configuration add listener.&#xa;',
1177N/A ' *&#xa;',
1177N/A ' * @param listener&#xa;',
1177N/A ' * The ', $ufn,' configuration add listener.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' void remove', $java-relation-name,
1177N/A 'AddListener(ConfigurationAddListener&lt;',
1177N/A $java-class-name,'Cfg&gt; listener);&#xa;')" />
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
1177N/A ' * Registers to be notified the ', $ufn,' is deleted.&#xa;',
1177N/A ' *&#xa;',
1177N/A ' * @param listener&#xa;',
1177N/A ' * The ', $ufn,' configuration delete listener.&#xa;',
1177N/A ' * @throws ConfigException&#xa;',
1177N/A ' * If the delete listener could not be registered.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' void add', $java-relation-name,
1177N/A 'DeleteListener(ConfigurationDeleteListener&lt;',
1177N/A $java-class-name,'Cfg&gt; listener) throws ConfigException;&#xa;')" />
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
1177N/A ' * Deregisters an existing ', $ufn,' configuration delete listener.&#xa;',
4134N/A ' *&#xa;',
1177N/A ' * @param listener&#xa;',
4134N/A ' * The ', $ufn,' configuration delete listener.&#xa;',
4134N/A ' */&#xa;')" />
4134N/A <xsl:value-of
1177N/A select="concat(' void remove', $java-relation-name,
4134N/A 'DeleteListener(ConfigurationDeleteListener&lt;',
1177N/A $java-class-name,'Cfg&gt; listener);&#xa;')" />
4134N/A </xsl:when>
4134N/A <xsl:when test="adm:one-to-many">
4134N/A <xsl:variable name="plural-name"
4134N/A select="adm:one-to-many/@plural-name" />
1177N/A <xsl:variable name="ufpn">
1177N/A <xsl:call-template name="name-to-ufn">
1177N/A <xsl:with-param name="value" select="$plural-name" />
1177N/A </xsl:call-template>
4134N/A </xsl:variable>
4134N/A <xsl:variable name="java-relation-plural-name">
1177N/A <xsl:call-template name="name-to-java">
4134N/A <xsl:with-param name="value" select="$plural-name" />
1177N/A </xsl:call-template>
1177N/A </xsl:variable>
1177N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
1177N/A ' * Lists the ', $ufpn, '.&#xa;',
1177N/A ' *&#xa;',
1177N/A ' * @return Returns an array containing the names of the&#xa;',
4134N/A ' * ', $ufpn,'.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' String[] list', $java-relation-plural-name, '();&#xa;')" />
1177N/A <xsl:text>&#xa;</xsl:text>
4134N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
1177N/A ' * Gets the named ', $ufn,'.&#xa;',
1177N/A ' *&#xa;',
1400N/A ' * @param name&#xa;',
1177N/A ' * The name of the ',$ufn,' to retrieve.&#xa;',
1177N/A ' * @return Returns the named ', $ufn,'.&#xa;',
2086N/A ' * @throws ConfigException&#xa;',
2086N/A ' * If the ', $ufn,' could not be found or it&#xa;',
2086N/A ' * could not be successfully decoded.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' ', $java-class-name, 'Cfg get',
1177N/A $java-relation-name, '(String name) throws ConfigException;&#xa;')" />
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
4134N/A <xsl:text>&#xa;</xsl:text>
4134N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
1177N/A ' * Registers to be notified when new ', $ufpn,' are added.&#xa;',
1177N/A ' *&#xa;',
1177N/A ' * @param listener&#xa;',
1177N/A ' * The ', $ufn,' configuration add listener.&#xa;',
1177N/A ' * @throws ConfigException&#xa;',
1177N/A ' * If the add listener could not be registered.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' void add', $java-relation-name,
1177N/A 'AddListener(ConfigurationAddListener&lt;',
1177N/A $java-class-name,'Cfg&gt; listener) throws ConfigException;&#xa;')" />
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
2086N/A <xsl:text>&#xa;</xsl:text>
2086N/A <xsl:value-of
4134N/A select="concat(' /**&#xa;',
2086N/A ' * Deregisters an existing ', $ufn,' configuration add listener.&#xa;',
1177N/A ' *&#xa;',
1177N/A ' * @param listener&#xa;',
1177N/A ' * The ', $ufn,' configuration add listener.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' void remove', $java-relation-name,
1177N/A 'AddListener(ConfigurationAddListener&lt;',
1177N/A $java-class-name,'Cfg&gt; listener);&#xa;')" />
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1400N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:value-of
1177N/A select="concat(' /**&#xa;',
2086N/A ' * Registers to be notified when existing ', $ufpn,' are deleted.&#xa;',
2086N/A ' *&#xa;',
2086N/A ' * @param listener&#xa;',
1177N/A ' * The ', $ufn,' configuration delete listener.&#xa;',
1177N/A ' * @throws ConfigException&#xa;',
1177N/A ' * If the delete listener could not be registered.&#xa;',
1177N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' void add', $java-relation-name,
4134N/A 'DeleteListener(ConfigurationDeleteListener&lt;',
1177N/A $java-class-name,'Cfg&gt; listener) throws ConfigException;&#xa;')" />
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:value-of
1400N/A select="concat(' /**&#xa;',
1177N/A ' * Deregisters an existing ', $ufn,' configuration delete listener.&#xa;',
1177N/A ' *&#xa;',
2086N/A ' * @param listener&#xa;',
2086N/A ' * The ', $ufn,' configuration delete listener.&#xa;',
2086N/A ' */&#xa;')" />
1177N/A <xsl:value-of
1177N/A select="concat(' void remove', $java-relation-name,
4134N/A 'DeleteListener(ConfigurationDeleteListener&lt;',
4134N/A $java-class-name,'Cfg&gt; listener);&#xa;')" />
4134N/A </xsl:when>
4134N/A <xsl:otherwise>
4134N/A <xsl:message terminate="yes">
4134N/A <xsl:value-of
4134N/A select="concat('Unknown relation type &quot;', local-name(*), '&quot; in relation &quot;', $name, '&quot;.')" />
4134N/A </xsl:message>
4134N/A </xsl:otherwise>
4134N/A </xsl:choose>
4134N/A </xsl:template>
4134N/A <!--
4134N/A Main document parsing template.
4134N/A -->
4134N/A <xsl:template match="/">
4134N/A <xsl:call-template name="copyright-notice" />
1177N/A <xsl:value-of
1177N/A select="concat('package ', $this-package, '.server;&#xa;')" />
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:call-template name="generate-import-statements">
1177N/A <xsl:with-param name="imports">
1177N/A <xsl:element name="import">
1177N/A <xsl:value-of
1177N/A select="concat($this-package, '.client.', $this-java-class, 'CfgClient')" />
1177N/A </xsl:element>
1177N/A <xsl:for-each select="$this-local-properties">
1177N/A <xsl:call-template name="get-property-java-imports" />
1177N/A </xsl:for-each>
1177N/A <xsl:if test="$this-local-properties[@multi-valued='true']">
1177N/A <import>java.util.SortedSet</import>
1177N/A </xsl:if>
1177N/A <xsl:choose>
1177N/A <xsl:when test="$this/@extends">
1177N/A <xsl:if test="$parent-package != $this-package">
1177N/A <xsl:element name="import">
1177N/A <xsl:value-of
1177N/A select="concat($parent-package, '.server.', $parent-java-class, 'Cfg')" />
1177N/A </xsl:element>
1177N/A </xsl:if>
1177N/A </xsl:when>
1177N/A <xsl:otherwise>
1177N/A <import>org.opends.server.admin.Configuration</import>
1177N/A </xsl:otherwise>
1177N/A </xsl:choose>
1177N/A <xsl:if test="not($this-is-root)">
1177N/A <import>
1177N/A org.opends.server.admin.server.ConfigurationChangeListener
1177N/A </import>
1177N/A </xsl:if>
1177N/A <xsl:if test="$this-local-relations">
1177N/A <import>org.opends.server.config.ConfigException</import>
1177N/A </xsl:if>
1177N/A <xsl:if
1177N/A test="$this-local-relations/adm:one-to-zero-or-one|$this-local-relations/adm:one-to-many">
1177N/A <import>
1177N/A org.opends.server.admin.server.ConfigurationAddListener
1177N/A </import>
1177N/A <import>
1177N/A org.opends.server.admin.server.ConfigurationDeleteListener
1177N/A </import>
1177N/A </xsl:if>
1177N/A <import>org.opends.server.admin.ManagedObjectDefinition</import>
1177N/A </xsl:with-param>
1177N/A </xsl:call-template>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:call-template name="generate-interface-declaration" />
1177N/A <xsl:text>&#xa;</xsl:text>
1177N/A <xsl:call-template name="generate-configuration-definition-getter" />
1177N/A <xsl:if test="not($this-is-root)">
1177N/A <xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:text>&#xa;</xsl:text>
<xsl:call-template name="generate-change-listener-declaration" />
</xsl:if>
<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="'server'" />
</xsl:call-template>
</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>