<!--
|
! CDDL HEADER START
|
!
|
! The contents of this file are subject to the terms of the
|
! Common Development and Distribution License, Version 1.0 only
|
! (the "License"). You may not use this file except in compliance
|
! with the License.
|
!
|
! You can obtain a copy of the license at
|
! trunk/opends/resource/legal-notices/OpenDS.LICENSE
|
! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
|
! See the License for the specific language governing permissions
|
! and limitations under the License.
|
!
|
! When distributing Covered Code, include this CDDL HEADER in each
|
! file and include the License file at
|
! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
|
! add the following below this CDDL HEADER, with the fields enclosed
|
! by brackets "[]" replaced with your own identifying information:
|
! Portions Copyright [yyyy] [name of copyright owner]
|
!
|
! CDDL HEADER END
|
!
|
!
|
! Portions Copyright 2007 Sun Microsystems, Inc.
|
! -->
|
<xsl:stylesheet version="1.0" xmlns:adm="http://www.opends.org/admin"
|
xmlns:admpp="http://www.opends.org/admin-preprocessor"
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
xmlns:exsl="http://exslt.org/common">
|
<xsl:import href="java-utilities.xsl" />
|
<xsl:import href="preprocessor.xsl" />
|
<xsl:import href="property-types.xsl" />
|
<xsl:output method="text" encoding="us-ascii" />
|
<!--
|
Template for generating the class declaration.
|
-->
|
<xsl:template name="generate-meta-class-declaration">
|
<xsl:value-of select="'/**
'" />
|
<xsl:call-template name="add-java-comment">
|
<xsl:with-param name="indent-text" select="' *'" />
|
<xsl:with-param name="content"
|
select="concat('An interface for querying the ', $this-ufn,
|
' managed object definition meta information.')" />
|
</xsl:call-template>
|
<xsl:value-of select="' * <p>
'" />
|
<xsl:call-template name="add-java-comment">
|
<xsl:with-param name="indent-text" select="' *'" />
|
<xsl:with-param name="content" select="$this/adm:synopsis" />
|
</xsl:call-template>
|
<xsl:value-of select="' */
'" />
|
<xsl:value-of
|
select="concat('public final class ',
|
$this-java-class,
|
'CfgDefn extends ')" />
|
<xsl:choose>
|
<xsl:when test="$this-is-abstract">
|
<xsl:value-of
|
select="concat('AbstractManagedObjectDefinition<',
|
$this-java-class, 'CfgClient, ',
|
$this-java-class, 'Cfg> {
')" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of
|
select="concat('ManagedObjectDefinition<',
|
$this-java-class, 'CfgClient, ',
|
$this-java-class, 'Cfg> {
')" />
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:template>
|
<!--
|
Template for generating the meta class body.
|
-->
|
<xsl:template name="generate-meta-class-body">
|
<!--
|
Singleton configuration definition instance.
|
-->
|
<xsl:value-of
|
select="concat(' // The singleton configuration definition instance.
',
|
' private static final ',
|
$this-java-class ,
|
'CfgDefn INSTANCE = new ', $this-java-class, 'CfgDefn();
')" />
|
<!--
|
Generate enumerations defined by this managed object..
|
-->
|
<xsl:for-each
|
select="$this-local-properties[adm:syntax/adm:enumeration]">
|
<xsl:sort select="@name" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-enumeration" />
|
</xsl:for-each>
|
<!--
|
Generate declarations for properties defined or
|
overridden by this managed object.
|
-->
|
<xsl:for-each select="$this-local-properties">
|
<xsl:sort select="@name" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-property-declaration" />
|
</xsl:for-each>
|
<!--
|
Generate declarations for relations.
|
-->
|
<xsl:for-each select="$this-local-relations">
|
<xsl:sort select="@name" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-relation-declaration" />
|
</xsl:for-each>
|
<!--
|
Generate constructors for properties defined or
|
overridden by this managed object.
|
-->
|
<xsl:for-each select="$this-local-properties">
|
<xsl:sort select="@name" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-property-constructor" />
|
</xsl:for-each>
|
<!--
|
Generate constructors for relations.
|
-->
|
<xsl:for-each select="$this-local-relations">
|
<xsl:sort select="@name" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-relation-constructor" />
|
</xsl:for-each>
|
<!--
|
Configuration definition singleton getter.
|
-->
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of select="' /**
'" />
|
<xsl:call-template name="add-java-comment">
|
<xsl:with-param name="indent-text" select="' *'" />
|
<xsl:with-param name="content"
|
select="concat('Get the ', $this-ufn,' configuration definition singleton.')" />
|
</xsl:call-template>
|
<xsl:value-of select="' *
'" />
|
<xsl:call-template name="add-java-comment">
|
<xsl:with-param name="indent-text" select="' *'" />
|
<xsl:with-param name="indent-text2" select="' * '" />
|
<xsl:with-param name="content"
|
select="concat('@return Returns the ', $this-ufn,
|
' configuration definition singleton.')" />
|
</xsl:call-template>
|
<xsl:value-of select="' */
'" />
|
<xsl:value-of
|
select="concat(' public static ',
|
$this-java-class ,
|
'CfgDefn getInstance() {
',
|
' return INSTANCE;
',
|
' }
')" />
|
<!--
|
Private constructor.
|
-->
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * Private constructor.
',
|
' */
',
|
' private ',
|
$this-java-class ,
|
'CfgDefn() {
')" />
|
<xsl:choose>
|
<xsl:when test="boolean($this/@extends)">
|
<xsl:value-of
|
select="concat(' super("',
|
$this/@name,
|
'", ',
|
$parent-java-class,
|
'CfgDefn.getInstance());
')" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of
|
select="concat(' super("',
|
$this/@name,
|
'", null);
')" />
|
</xsl:otherwise>
|
</xsl:choose>
|
<xsl:value-of select="concat(' }
')" />
|
<!--
|
Create configuration view factory methods for non-abstract definitions
|
-->
|
<xsl:if test="not($this-is-abstract)">
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<!--
|
Generate configuration client factory method.
|
-->
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public ',
|
$this-java-class,
|
'CfgClient createClientConfiguration(
',
|
' ManagedObject<? extends ',
|
$this-java-class,
|
'CfgClient> impl) {
',
|
' return new ',
|
$this-java-class ,
|
'CfgClientImpl(impl);
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<!--
|
Generate configuration server factory method.
|
-->
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public ',
|
$this-java-class,
|
'Cfg createServerConfiguration(
',
|
' ServerManagedObject<? extends ',$this-java-class,'Cfg> impl) {
',
|
' return new ',
|
$this-java-class ,
|
'CfgServerImpl(impl);
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<!--
|
Generate configuration server class getter..
|
-->
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public Class<',
|
$this-java-class,
|
'Cfg> getServerConfigurationClass() {
',
|
' return ',
|
$this-java-class ,
|
'Cfg.class;
',
|
' }
')" />
|
</xsl:if>
|
<!--
|
Generate property definition getters for local properties.
|
-->
|
<xsl:for-each select="$this-all-properties">
|
<xsl:sort select="@name" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-property-definition-getter" />
|
</xsl:for-each>
|
<!--
|
Generate relation definition getters for local relations.
|
-->
|
<xsl:for-each select="$this-all-relations">
|
<xsl:sort select="@name" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-relation-definition-getter" />
|
</xsl:for-each>
|
<!--
|
Managed object class implementations.
|
-->
|
<xsl:if test="not($this-is-abstract)">
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-client-impl-class" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-server-impl-class" />
|
</xsl:if>
|
</xsl:template>
|
<!--
|
Generate managed object client class implementation.
|
-->
|
<xsl:template name="generate-client-impl-class">
|
<!--
|
Declaration.
|
-->
|
<xsl:value-of
|
select="concat(' /**
',
|
' * Managed object client implementation.
',
|
' */
',
|
' private static class ',
|
$this-java-class ,
|
'CfgClientImpl implements
 ',
|
$this-java-class ,
|
'CfgClient {
')" />
|
<xsl:text>
</xsl:text>
|
<!--
|
Private instance.
|
-->
|
<xsl:value-of
|
select="concat(' // Private implementation.
',
|
' private ManagedObject<? extends ',
|
$this-java-class,
|
'CfgClient> impl;
')" />
|
<!--
|
Private constructor.
|
-->
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' // Private constructor.
',
|
' private ',
|
$this-java-class,
|
'CfgClientImpl(
',
|
' ManagedObject<? extends ',
|
$this-java-class,
|
'CfgClient> impl) {
',
|
' this.impl = impl;
',
|
' }
')" />
|
<!--
|
Getters/Setters for all properties.
|
-->
|
<xsl:for-each select="$this-all-properties">
|
<xsl:sort select="@name" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-property-getter">
|
<xsl:with-param name="interface" select="'client'" />
|
</xsl:call-template>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-property-setter" />
|
</xsl:for-each>
|
<!--
|
Relation methods.
|
-->
|
<xsl:for-each select="$this-all-relations">
|
<xsl:sort select="@name" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-client-relation-methods" />
|
</xsl:for-each>
|
<!--
|
Managed object definition getter.
|
-->
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public ManagedObjectDefinition<? extends ', $this-java-class,'CfgClient, ? extends ', $this-java-class,'Cfg> definition() {
',
|
' return INSTANCE;
',
|
' }
')" />
|
<!--
|
Property provider view.
|
-->
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public PropertyProvider properties() {
',
|
' return impl;
',
|
' }
')" />
|
<!--
|
Commit method.
|
-->
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public void commit() throws OperationsException {
',
|
' impl.commit();
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:value-of select="' }
'" />
|
</xsl:template>
|
<!--
|
Generate managed object server class implementation.
|
-->
|
<xsl:template name="generate-server-impl-class">
|
<!--
|
Declaration.
|
-->
|
<xsl:value-of
|
select="concat(' /**
',
|
' * Managed object server implementation.
',
|
' */
',
|
' private static class ',
|
$this-java-class ,
|
'CfgServerImpl implements
 ',
|
$this-java-class ,
|
'Cfg {
')" />
|
<xsl:text>
</xsl:text>
|
<!--
|
Private instance.
|
-->
|
<xsl:value-of
|
select="concat(' // Private implementation.
',
|
' private ServerManagedObject<? extends ', $this-java-class, 'Cfg> impl;
')" />
|
<!--
|
Private constructor.
|
-->
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' // Private constructor.
',
|
' private ',
|
$this-java-class,
|
'CfgServerImpl(ServerManagedObject<? extends ', $this-java-class, 'Cfg> impl) {
',
|
' this.impl = impl;
',
|
' }
')" />
|
<!--
|
Generate all the change listener methods - one for each managed
|
object in the hierarchy.
|
-->
|
<xsl:if test="not($this-is-root)">
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-change-listener" />
|
</xsl:if>
|
<!--
|
Getters/Setters for all properties.
|
-->
|
<xsl:for-each select="$this-all-properties">
|
<xsl:sort select="@name" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-property-getter">
|
<xsl:with-param name="interface" select="'server'" />
|
</xsl:call-template>
|
</xsl:for-each>
|
<!--
|
Relation methods.
|
-->
|
<xsl:for-each select="$this-all-relations">
|
<xsl:sort select="@name" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-server-relation-methods" />
|
</xsl:for-each>
|
<!--
|
Configuration definition getter.
|
-->
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public ManagedObjectDefinition<? extends ', $this-java-class,'CfgClient, ? extends ', $this-java-class,'Cfg> definition() {
',
|
' return INSTANCE;
',
|
' }
')" />
|
<!--
|
Property provider view.
|
-->
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public PropertyProvider properties() {
',
|
' return impl;
',
|
' }
')" />
|
<!--
|
Configuration entry DN getter.
|
-->
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public DN dn() {
',
|
' return impl.getDN();
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:value-of select="' }
'" />
|
</xsl:template>
|
<!--
|
Generate a property definition constructor.
|
-->
|
<xsl:template name="generate-property-declaration">
|
<xsl:variable name="java-prop-name">
|
<xsl:call-template name="name-to-java-constant">
|
<xsl:with-param name="value" select="@name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:variable name="type">
|
<xsl:call-template name="get-property-definition-type" />
|
</xsl:variable>
|
<xsl:variable name="generic-type">
|
<xsl:call-template name="get-property-definition-generic-type" />
|
</xsl:variable>
|
<xsl:variable name="pdtype">
|
<xsl:choose>
|
<xsl:when test="string-length($generic-type) != 0">
|
<xsl:value-of
|
select="concat($type, '<', $generic-type, '>')" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of select="$type" />
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:variable>
|
<xsl:value-of
|
select="concat(' // The "',
|
@name,
|
'" property definition.
',
|
' private static final ', $pdtype, ' PD_', $java-prop-name, ';
')" />
|
</xsl:template>
|
<!--
|
Generate a property definition constructor.
|
-->
|
<xsl:template name="generate-property-constructor">
|
<xsl:variable name="java-prop-name">
|
<xsl:call-template name="name-to-java-constant">
|
<xsl:with-param name="value" select="@name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:variable name="type">
|
<xsl:call-template name="get-property-definition-type" />
|
</xsl:variable>
|
<xsl:variable name="generic-type">
|
<xsl:call-template name="get-property-definition-generic-type" />
|
</xsl:variable>
|
<xsl:variable name="value-type">
|
<xsl:call-template name="get-property-java-type" />
|
</xsl:variable>
|
<xsl:value-of
|
select="concat(' // Build the "', @name, '" property definition.
',
|
' static {
')" />
|
<xsl:choose>
|
<xsl:when test="string-length($generic-type) != 0">
|
<xsl:value-of
|
select="concat(' ', $type, '.Builder<', $generic-type, '> builder = ', $type, '.createBuilder(INSTANCE, "',@name, '");
')" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of
|
select="concat(' ', $type, '.Builder builder = ', $type, '.createBuilder(INSTANCE, "',@name, '");
')" />
|
</xsl:otherwise>
|
</xsl:choose>
|
<xsl:if test="string(@multi-valued) = 'true'">
|
<xsl:value-of
|
select="' builder.setOption(PropertyOption.MULTI_VALUED);
'" />
|
</xsl:if>
|
<xsl:if test="string(@read-only) = 'true'">
|
<xsl:value-of
|
select="' builder.setOption(PropertyOption.READ_ONLY);
'" />
|
</xsl:if>
|
<xsl:if
|
test="adm:requires-admin-action/adm:server-restart|adm:requires-admin-action/adm:component-restart|adm:requires-admin-action/adm:other">
|
<xsl:value-of
|
select="' builder.setOption(PropertyOption.REQUIRES_ADMIN_ACTION);
'" />
|
</xsl:if>
|
<xsl:if test="string(@mandatory) = 'true'">
|
<xsl:value-of
|
select="' builder.setOption(PropertyOption.MANDATORY);
'" />
|
</xsl:if>
|
<xsl:if test="string(@hidden) = 'true'">
|
<xsl:value-of
|
select="' builder.setOption(PropertyOption.HIDDEN);
'" />
|
</xsl:if>
|
<xsl:choose>
|
<xsl:when test="string(@mandatory) = 'true'">
|
<xsl:value-of
|
select="concat(' builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<', $value-type,'>());
')" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:if test="not(adm:default-behavior)">
|
<xsl:message terminate="yes">
|
<xsl:value-of
|
select="concat('No default behavior defined for non-mandatory property "', @name,
|
'".')" />
|
</xsl:message>
|
</xsl:if>
|
<xsl:choose>
|
<xsl:when test="adm:default-behavior/adm:undefined">
|
<xsl:value-of
|
select="concat(' builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<', $value-type,'>());
')" />
|
</xsl:when>
|
<xsl:when test="adm:default-behavior/adm:alias">
|
<xsl:value-of
|
select="concat(' builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<', $value-type,'>(INSTANCE, "', @name, '"));
')" />
|
</xsl:when>
|
<xsl:when test="adm:default-behavior/adm:defined">
|
<xsl:value-of
|
select="concat(' DefaultBehaviorProvider<', $value-type,'> provider = ',
|
'new DefinedDefaultBehaviorProvider<', $value-type,'>(')" />
|
<xsl:for-each
|
select="adm:default-behavior/adm:defined/adm:value">
|
<xsl:value-of
|
select="concat('"', normalize-space(), '"')" />
|
<xsl:if test="position() != last()">
|
<xsl:value-of select="', '" />
|
</xsl:if>
|
</xsl:for-each>
|
<xsl:value-of select="');
'" />
|
<xsl:value-of
|
select="' builder.setDefaultBehaviorProvider(provider);
'" />
|
</xsl:when>
|
<xsl:when
|
test="adm:default-behavior/adm:inherited/adm:relative">
|
<xsl:message terminate="yes">
|
<xsl:value-of
|
select="concat('Relative inherited property defaults not yet implemented (property "', @name,
|
'").')" />
|
</xsl:message>
|
</xsl:when>
|
<xsl:when
|
test="adm:default-behavior/adm:inherited/adm:absolute">
|
<xsl:message terminate="yes">
|
<xsl:value-of
|
select="concat('Absolute inherited property defaults not yet implemented (property "', @name,
|
'").')" />
|
</xsl:message>
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:message terminate="yes">
|
<xsl:value-of
|
select="concat('Unrecognized default behavior type for property "', @name,
|
'".')" />
|
</xsl:message>
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:otherwise>
|
</xsl:choose>
|
<xsl:call-template name="get-property-definition-ctor" />
|
<xsl:value-of
|
select="concat(' PD_', $java-prop-name, ' = builder.getInstance();
')" />
|
<xsl:value-of
|
select="concat(' INSTANCE.registerPropertyDefinition(PD_', $java-prop-name, ');
')" />
|
<xsl:value-of select="' }
'" />
|
</xsl:template>
|
<!--
|
Generate a relation definition declaration.
|
-->
|
<xsl:template name="generate-relation-declaration">
|
<xsl:variable name="relation-name">
|
<xsl:choose>
|
<xsl:when test="adm:one-to-many">
|
<xsl:value-of select="adm:one-to-many/@plural-name" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of select="@name" />
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:variable>
|
<xsl:variable name="java-relation-name">
|
<xsl:call-template name="name-to-java-constant">
|
<xsl:with-param name="value" select="$relation-name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:variable name="java-managed-object-name">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="@managed-object-name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:value-of
|
select="concat(' // The "',
|
$relation-name,
|
'" relation definition.
',
|
' private static final ')" />
|
<xsl:choose>
|
<xsl:when test="adm:one-to-one">
|
<xsl:text>SingletonRelationDefinition<</xsl:text>
|
</xsl:when>
|
<xsl:when test="adm:one-to-zero-or-one">
|
<xsl:text>OptionalRelationDefinition<</xsl:text>
|
</xsl:when>
|
<xsl:when test="adm:one-to-many">
|
<xsl:text>InstantiableRelationDefinition<</xsl:text>
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:message terminate="yes">
|
<xsl:value-of
|
select="concat('Unknown relation type "', local-name(*), '" in relation "', @name, '".')" />
|
</xsl:message>
|
</xsl:otherwise>
|
</xsl:choose>
|
<xsl:value-of
|
select="concat($java-managed-object-name, 'CfgClient, ', $java-managed-object-name, 'Cfg> RD_', $java-relation-name, ';
')" />
|
</xsl:template>
|
<!--
|
Generate a relation definition constructor.
|
-->
|
<xsl:template name="generate-relation-constructor">
|
<xsl:variable name="relation-name">
|
<xsl:choose>
|
<xsl:when test="adm:one-to-many">
|
<xsl:value-of select="adm:one-to-many/@plural-name" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of select="@name" />
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:variable>
|
<xsl:variable name="java-relation-name">
|
<xsl:call-template name="name-to-java-constant">
|
<xsl:with-param name="value" select="$relation-name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:variable name="java-managed-object-name">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="@managed-object-name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:value-of
|
select="concat(' // Build the "', $relation-name, '" relation definition.
',
|
' static {
',
|
' RD_', $java-relation-name, ' = new ')" />
|
<xsl:choose>
|
<xsl:when test="adm:one-to-one">
|
<xsl:text>SingletonRelationDefinition<</xsl:text>
|
</xsl:when>
|
<xsl:when test="adm:one-to-zero-or-one">
|
<xsl:text>OptionalRelationDefinition<</xsl:text>
|
</xsl:when>
|
<xsl:when test="adm:one-to-many">
|
<xsl:text>InstantiableRelationDefinition<</xsl:text>
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:message terminate="yes">
|
<xsl:value-of
|
select="concat('Unknown relation type "', local-name(*), '" in relation "', @name, '".')" />
|
</xsl:message>
|
</xsl:otherwise>
|
</xsl:choose>
|
<xsl:value-of
|
select="concat($java-managed-object-name, 'CfgClient, ', $java-managed-object-name, 'Cfg>(
',
|
' INSTANCE, "', @name, '", ')" />
|
<xsl:if test="adm:one-to-many">
|
<xsl:value-of
|
select="concat('"', adm:one-to-many/@plural-name, '", ')" />
|
</xsl:if>
|
<xsl:value-of
|
select="concat($java-managed-object-name, 'CfgDefn.getInstance());
')" />
|
<xsl:value-of
|
select="concat(' INSTANCE.registerRelationDefinition(RD_', $java-relation-name,');
')" />
|
<xsl:value-of select="' }
'" />
|
</xsl:template>
|
<!--
|
Generate a property definition getter for a locally defined
|
or overriden property.
|
-->
|
<xsl:template name="generate-property-definition-getter">
|
<xsl:variable name="java-prop-name">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="@name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:variable name="java-prop-name-constant">
|
<xsl:call-template name="name-to-java-constant">
|
<xsl:with-param name="value" select="@name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:variable name="type">
|
<xsl:call-template name="get-property-definition-type" />
|
</xsl:variable>
|
<xsl:variable name="generic-type">
|
<xsl:call-template name="get-property-definition-generic-type" />
|
</xsl:variable>
|
<xsl:variable name="pdtype">
|
<xsl:choose>
|
<xsl:when test="string-length($generic-type) != 0">
|
<xsl:value-of
|
select="concat($type, '<', $generic-type, '>')" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of select="$type" />
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:variable>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * Get the "',
|
@name,
|
'" property definition.
')" />
|
<xsl:if test="adm:synopsis">
|
<xsl:value-of select="' * <p>
'" />
|
<xsl:call-template name="add-java-comment">
|
<xsl:with-param name="indent-text" select="' *'" />
|
<xsl:with-param name="content" select="adm:synopsis" />
|
</xsl:call-template>
|
</xsl:if>
|
<xsl:if test="adm:description">
|
<xsl:value-of select="' * <p>
'" />
|
<xsl:call-template name="add-java-comment">
|
<xsl:with-param name="indent-text" select="' *'" />
|
<xsl:with-param name="content" select="adm:description" />
|
</xsl:call-template>
|
</xsl:if>
|
<xsl:choose>
|
<xsl:when
|
test="adm:profile[@name='preprocessor']/admpp:managed-object[@name=$this-name and @package=$this-package]">
|
<xsl:value-of
|
select="concat(' *
',
|
' * @return Returns the "',
|
@name,
|
'" property definition.
',
|
' */
',
|
' public ',
|
$pdtype,
|
' get',
|
$java-prop-name,
|
'PropertyDefinition() {
' ,
|
' return PD_',
|
$java-prop-name-constant ,
|
';
' ,
|
' }
')" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of
|
select="concat(' *
',
|
' * @return Returns the "',
|
@name,
|
'" property definition.
',
|
' */
',
|
' public ',
|
$pdtype,
|
' get',
|
$java-prop-name,
|
'PropertyDefinition() {
' ,
|
' return ',
|
$parent-java-class, 'CfgDefn.getInstance().get',
|
$java-prop-name,
|
'PropertyDefinition();
',
|
' }
')" />
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:template>
|
<!--
|
Generate a relation definition getter.
|
-->
|
<xsl:template name="generate-relation-definition-getter">
|
<xsl:variable name="relation-name">
|
<xsl:choose>
|
<xsl:when test="adm:one-to-many">
|
<xsl:value-of select="adm:one-to-many/@plural-name" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of select="@name" />
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:variable>
|
<xsl:variable name="java-relation-name">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="$relation-name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:variable name="java-relation-name-constant">
|
<xsl:call-template name="name-to-java-constant">
|
<xsl:with-param name="value" select="$relation-name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * Get the "',
|
$relation-name,
|
'" relation definition.
',
|
' *
',
|
' * @return Returns the "',
|
$relation-name,
|
'" relation definition.
',
|
' */
',
|
' public ')" />
|
<xsl:choose>
|
<xsl:when test="adm:one-to-one">
|
<xsl:text>SingletonRelationDefinition<</xsl:text>
|
</xsl:when>
|
<xsl:when test="adm:one-to-zero-or-one">
|
<xsl:text>OptionalRelationDefinition<</xsl:text>
|
</xsl:when>
|
<xsl:when test="adm:one-to-many">
|
<xsl:text>InstantiableRelationDefinition<</xsl:text>
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:message terminate="yes">
|
<xsl:value-of
|
select="concat('Unknown relation type "', local-name(*), '" in relation "', @name, '".')" />
|
</xsl:message>
|
</xsl:otherwise>
|
</xsl:choose>
|
<xsl:variable name="java-managed-object-name">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="@managed-object-name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:choose>
|
<xsl:when
|
test="adm:profile[@name='preprocessor']/admpp:managed-object[@name=$this-name and @package=$this-package]">
|
<xsl:value-of
|
select="concat($java-managed-object-name, 'CfgClient,',
|
$java-managed-object-name, 'Cfg> get',
|
$java-relation-name,
|
'RelationDefinition() {
' ,
|
' return RD_',
|
$java-relation-name-constant,
|
';
' ,
|
' }
')" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of
|
select="concat($java-managed-object-name, 'CfgClient,',
|
$java-managed-object-name, 'Cfg> get',
|
$java-relation-name,
|
'RelationDefinition() {
' ,
|
' return ',
|
$parent-java-class, 'CfgDefn.getInstance().get',
|
$java-relation-name,
|
'RelationDefinition();
',
|
' }
')" />
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:template>
|
<!--
|
Generate a property value getter.
|
-->
|
<xsl:template name="generate-property-getter">
|
<xsl:param name="interface" select="/.." />
|
<xsl:variable name="java-prop-name">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="@name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public ')" />
|
<xsl:choose>
|
<xsl:when test="string(@multi-valued) != 'true'">
|
<xsl:choose>
|
<xsl:when test="adm:default-behavior/adm:defined">
|
<!--
|
The method is guaranteed to return a value since there is a
|
well-defined default value.
|
-->
|
<xsl:call-template name="get-property-java-primitive-type" />
|
</xsl:when>
|
<xsl:when
|
test="$interface = 'server' and @mandatory = 'true'">
|
<!--
|
The method is guaranteed to return a value in the server interface, but
|
not necessarily in the client, since the mandatory property might not
|
have been created yet.
|
-->
|
<xsl:call-template name="get-property-java-primitive-type" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:call-template name="get-property-java-type" />
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of select="'SortedSet<'" />
|
<xsl:call-template name="get-property-java-type" />
|
<xsl:value-of select="'>'" />
|
</xsl:otherwise>
|
</xsl:choose>
|
<xsl:choose>
|
<xsl:when test="adm:syntax/adm:boolean">
|
<xsl:value-of select="' is'" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of select="' get'" />
|
</xsl:otherwise>
|
</xsl:choose>
|
<xsl:choose>
|
<xsl:when test="string(@multi-valued) != 'true'">
|
<xsl:value-of
|
select="concat($java-prop-name, '() {
',
|
' return impl.getPropertyValue',
|
'(INSTANCE.get', $java-prop-name ,
|
'PropertyDefinition());
' ,
|
' }
')" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of
|
select="concat($java-prop-name, '() {
',
|
' return impl.getPropertyValues',
|
'(INSTANCE.get', $java-prop-name ,
|
'PropertyDefinition());
' ,
|
' }
')" />
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:template>
|
<!--
|
Generate a property value setter.
|
-->
|
<xsl:template name="generate-property-setter">
|
<xsl:if test="string(@read-only) != 'true'">
|
<xsl:variable name="java-prop-name">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="@name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public void set',
|
$java-prop-name ,
|
'(')" />
|
<xsl:choose>
|
<xsl:when test="string(@multi-valued) != 'true'">
|
<xsl:choose>
|
<xsl:when test="@mandatory = 'true'">
|
<xsl:call-template
|
name="get-property-java-primitive-type" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:call-template name="get-property-java-type" />
|
</xsl:otherwise>
|
</xsl:choose>
|
<xsl:value-of
|
select="concat(' value) {
' ,
|
' impl.setPropertyValue(INSTANCE.get',
|
$java-prop-name ,
|
'PropertyDefinition(), value);
',
|
' }
')" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of select="'Collection<'" />
|
<xsl:call-template name="get-property-java-type" />
|
<xsl:value-of
|
select="concat('> values) {
' ,
|
' impl.setPropertyValues(INSTANCE.get',
|
$java-prop-name ,
|
'PropertyDefinition(), values);
',
|
' }
')" />
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:if>
|
</xsl:template>
|
<!--
|
Generate client relation methods.
|
-->
|
<xsl:template name="generate-client-relation-methods">
|
<xsl:variable name="name" select="@name" />
|
<xsl:variable name="java-relation-name">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="$name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:variable name="java-class-name">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="@managed-object-name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:choose>
|
<xsl:when test="adm:one-to-one">
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public ', $java-class-name, 'CfgClient get',
|
$java-relation-name, '() throws OperationsException {
',
|
' return impl.getChild(INSTANCE.get', $java-relation-name,'RelationDefinition()).getConfiguration();
',
|
' }
')" />
|
</xsl:when>
|
<xsl:when test="adm:one-to-zero-or-one">
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public boolean has',
|
$java-relation-name, '() throws OperationsException {
',
|
' return impl.hasChild(INSTANCE.get', $java-relation-name,'RelationDefinition());
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public ', $java-class-name, 'CfgClient get',
|
$java-relation-name, '() throws OperationsException {
',
|
' return impl.getChild(INSTANCE.get', $java-relation-name,'RelationDefinition()).getConfiguration();
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public <M extends ', $java-class-name, 'CfgClient> M create',
|
$java-relation-name, '(ManagedObjectDefinition<M, ?> d, PropertyProvider p) throws OperationsException {
',
|
' return impl.createChild(INSTANCE.get', $java-relation-name,'RelationDefinition(), d, p).getConfiguration();
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public void remove',
|
$java-relation-name, '() throws OperationsException {
',
|
' impl.removeChild(INSTANCE.get', $java-relation-name,'RelationDefinition());
',
|
' }
')" />
|
</xsl:when>
|
<xsl:when test="adm:one-to-many">
|
<xsl:variable name="plural-name"
|
select="adm:one-to-many/@plural-name" />
|
<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(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public String[] list',
|
$java-relation-plural-name, '() throws OperationsException {
',
|
' return impl.listChildren(INSTANCE.get', $java-relation-plural-name,'RelationDefinition());
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public ', $java-class-name, 'CfgClient get',
|
$java-relation-name, '(String name) throws OperationsException {
',
|
' return impl.getChild(INSTANCE.get', $java-relation-plural-name,'RelationDefinition(), name).getConfiguration();
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public <M extends ', $java-class-name, 'CfgClient> M create',
|
$java-relation-name, '(ManagedObjectDefinition<M, ?> d, String name, PropertyProvider p) throws OperationsException {
',
|
' return impl.createChild(INSTANCE.get', $java-relation-plural-name,'RelationDefinition(), d, name, p).getConfiguration();
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public void remove',
|
$java-relation-name, '(String name) throws OperationsException {
',
|
' impl.removeChild(INSTANCE.get', $java-relation-plural-name,'RelationDefinition(), name);
',
|
' }
')" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:message terminate="yes">
|
<xsl:value-of
|
select="concat('Unknown relation type "', local-name(*), '" in relation "', $name, '".')" />
|
</xsl:message>
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:template>
|
<!--
|
Generate server relation methods.
|
-->
|
<xsl:template name="generate-server-relation-methods">
|
<xsl:variable name="name" select="@name" />
|
<xsl:variable name="java-relation-name">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="$name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:variable name="java-class-name">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="@managed-object-name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:choose>
|
<xsl:when test="adm:one-to-one">
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public ', $java-class-name, 'Cfg get',
|
$java-relation-name, '() throws ConfigException {
',
|
' return impl.getChild(INSTANCE.get', $java-relation-name, 'RelationDefinition()).getConfiguration();
',
|
' }
')" />
|
</xsl:when>
|
<xsl:when test="adm:one-to-zero-or-one">
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public boolean has',
|
$java-relation-name, '() {
',
|
' return impl.hasChild(INSTANCE.get', $java-relation-name, 'RelationDefinition());
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public ', $java-class-name, 'Cfg get',
|
$java-relation-name, '() throws ConfigException {
',
|
' return impl.getChild(INSTANCE.get', $java-relation-name, 'RelationDefinition()).getConfiguration();
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public void add', $java-relation-name, 'AddListener(
',
|
' ConfigurationAddListener<', $java-class-name,'Cfg> listener) throws ConfigException {
',
|
' impl.registerAddListener(INSTANCE.get', $java-relation-name, 'RelationDefinition(), listener);
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public void remove', $java-relation-name, 'AddListener(
',
|
' ConfigurationAddListener<', $java-class-name,'Cfg> listener) {
',
|
' impl.deregisterAddListener(INSTANCE.get', $java-relation-name, 'RelationDefinition(), listener);
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public void add', $java-relation-name, 'DeleteListener(
',
|
' ConfigurationDeleteListener<', $java-class-name,'Cfg> listener) throws ConfigException {
',
|
' impl.registerDeleteListener(INSTANCE.get', $java-relation-name, 'RelationDefinition(), listener);
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public void remove', $java-relation-name, 'DeleteListener(
',
|
' ConfigurationDeleteListener<', $java-class-name,'Cfg> listener) {
',
|
' impl.deregisterDeleteListener(INSTANCE.get', $java-relation-name, 'RelationDefinition(), listener);
',
|
' }
')" />
|
</xsl:when>
|
<xsl:when test="adm:one-to-many">
|
<xsl:variable name="plural-name"
|
select="adm:one-to-many/@plural-name" />
|
<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(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public String[] list',
|
$java-relation-plural-name, '() {
',
|
' return impl.listChildren(INSTANCE.get', $java-relation-plural-name,'RelationDefinition());
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public ', $java-class-name, 'Cfg get',
|
$java-relation-name, '(String name) throws ConfigException {
',
|
' return impl.getChild(INSTANCE.get', $java-relation-plural-name, 'RelationDefinition(), name).getConfiguration();
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public void add', $java-relation-name, 'AddListener(
',
|
' ConfigurationAddListener<', $java-class-name,'Cfg> listener) throws ConfigException {
',
|
' impl.registerAddListener(INSTANCE.get', $java-relation-plural-name, 'RelationDefinition(), listener);
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public void remove', $java-relation-name, 'AddListener(
',
|
' ConfigurationAddListener<', $java-class-name,'Cfg> listener) {
',
|
' impl.deregisterAddListener(INSTANCE.get', $java-relation-plural-name, 'RelationDefinition(), listener);
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public void add', $java-relation-name, 'DeleteListener(
',
|
' ConfigurationDeleteListener<', $java-class-name,'Cfg> listener) throws ConfigException {
',
|
' impl.registerDeleteListener(INSTANCE.get', $java-relation-plural-name, 'RelationDefinition(), listener);
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public void remove', $java-relation-name, 'DeleteListener(
',
|
' ConfigurationDeleteListener<', $java-class-name,'Cfg> listener) {
',
|
' impl.deregisterDeleteListener(INSTANCE.get', $java-relation-plural-name, 'RelationDefinition(), listener);
',
|
' }
')" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:message terminate="yes">
|
<xsl:value-of
|
select="concat('Unknown relation type "', local-name(*), '" in relation "', $name, '".')" />
|
</xsl:message>
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:template>
|
<!--
|
Generate change listener registration methods.
|
-->
|
<xsl:template name="generate-change-listener">
|
<!--
|
Process this managed object.
|
-->
|
<xsl:variable name="top-name"
|
select="$this/adm:profile[@name='preprocessor']/admpp:parent-managed-object[last()]/@name" />
|
<xsl:call-template name="generate-change-listener-help">
|
<xsl:with-param name="top-name" select="$top-name" />
|
<xsl:with-param name="name" select="$this-name" />
|
</xsl:call-template>
|
<!--
|
Process parent hierarchy.
|
-->
|
<xsl:for-each
|
select="$this/adm:profile[@name='preprocessor']/admpp:parent-managed-object">
|
<xsl:call-template name="generate-change-listener-help">
|
<xsl:with-param name="top-name" select="$top-name" />
|
<xsl:with-param name="name" select="@name" />
|
</xsl:call-template>
|
</xsl:for-each>
|
</xsl:template>
|
<!--
|
Generate a single set of change listener registration methods.
|
-->
|
<xsl:template name="generate-change-listener-help">
|
<xsl:param name="top-name" select="/.." />
|
<xsl:param name="name" select="/.." />
|
<xsl:variable name="short-name">
|
<xsl:choose>
|
<xsl:when test="not($top-name) or $top-name = $name">
|
<xsl:value-of select="''" />
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:variable name="top-length"
|
select="string-length($top-name)" />
|
<xsl:variable name="length" select="string-length($name)" />
|
<xsl:variable name="diff" select="$length - $top-length" />
|
<xsl:value-of select="substring($name, 1, $diff - 1)" />
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:variable>
|
<xsl:variable name="java-class">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="$name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:variable name="short-java-class">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="$short-name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
')" />
|
<xsl:value-of
|
select="concat(' public void add', $short-java-class, 'ChangeListener(
',
|
' ConfigurationChangeListener<',$java-class,'Cfg> listener) {
',
|
' impl.registerChangeListener(listener);
',
|
' }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="concat(' /**
',
|
' * {@inheritDoc}
',
|
' */
')" />
|
<xsl:value-of
|
select="concat(' public void remove', $short-java-class, 'ChangeListener(
',
|
' ConfigurationChangeListener<',$java-class,'Cfg> listener) {
',
|
' impl.deregisterChangeListener(listener);
',
|
' }
')" />
|
</xsl:template>
|
<!--
|
Generate import statements for change-listener
|
-->
|
<xsl:template name="generate-change-listener-import-statements">
|
<!--
|
Process this managed object.
|
-->
|
<xsl:element name="import">
|
<xsl:value-of
|
select="concat($this-package, '.server.', $this-java-class, 'Cfg')" />
|
</xsl:element>
|
<!--
|
Process parent hierarchy.
|
-->
|
<xsl:for-each
|
select="$this/adm:profile[@name='preprocessor']/admpp:parent-managed-object">
|
<xsl:variable name="java-class">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="@name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:element name="import">
|
<xsl:value-of
|
select="concat(@package, '.server.', $java-class, 'Cfg')" />
|
</xsl:element>
|
</xsl:for-each>
|
</xsl:template>
|
<!--
|
Generate an enumeration for a locally defined enumerated property.
|
-->
|
<xsl:template name="generate-enumeration">
|
<xsl:value-of
|
select="concat(' /**
',
|
' * Defines the set of permissable values for the "', @name, '" property.
')" />
|
<xsl:if test="adm:synopsis">
|
<xsl:value-of select="' * <p>
'" />
|
<xsl:call-template name="add-java-comment">
|
<xsl:with-param name="indent-text" select="' *'" />
|
<xsl:with-param name="content" select="adm:synopsis" />
|
</xsl:call-template>
|
</xsl:if>
|
<xsl:if test="adm:description">
|
<xsl:value-of select="' * <p>
'" />
|
<xsl:call-template name="add-java-comment">
|
<xsl:with-param name="indent-text" select="' *'" />
|
<xsl:with-param name="content" select="adm:description" />
|
</xsl:call-template>
|
</xsl:if>
|
<xsl:value-of
|
select="concat(' */
',
|
' public static enum ')" />
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="@name" />
|
</xsl:call-template>
|
<xsl:value-of select="' {
'" />
|
<xsl:text>
</xsl:text>
|
<xsl:for-each select="adm:syntax/adm:enumeration/adm:value">
|
<xsl:sort select="@name" />
|
<xsl:value-of select="' /**
'" />
|
<xsl:call-template name="add-java-comment">
|
<xsl:with-param name="indent-text" select="' *'" />
|
<xsl:with-param name="content" select="adm:description" />
|
</xsl:call-template>
|
<xsl:value-of select="' */
'" />
|
<xsl:value-of select="' '" />
|
<xsl:call-template name="name-to-java-constant">
|
<xsl:with-param name="value" select="@name" />
|
</xsl:call-template>
|
<xsl:value-of select="concat('("', @name, '")')" />
|
<xsl:choose>
|
<xsl:when test="position() != last()">
|
<xsl:value-of select="',
'" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
</xsl:when>
|
<xsl:otherwise>
|
<xsl:value-of select="';
'" />
|
</xsl:otherwise>
|
</xsl:choose>
|
</xsl:for-each>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of
|
select="' // String representation of the value.
'" />
|
<xsl:value-of select="' private final String name;
'" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:value-of select="' // Private constructor.
'" />
|
<xsl:value-of select="' private '" />
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value" select="@name" />
|
</xsl:call-template>
|
<xsl:value-of
|
select="concat('(String name) { this.name = name; }
',
|
'
',
|
'
',
|
'
',
|
' /**
',
|
' * {@inheritDoc}
',
|
' */
',
|
' public String toString() { return name; }
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:value-of select="' }
'" />
|
</xsl:template>
|
<!--
|
Main document parsing template.
|
-->
|
<xsl:template match="/">
|
<xsl:call-template name="copyright-notice" />
|
<xsl:value-of
|
select="concat('package ', $this-package, '.meta;
')" />
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-import-statements">
|
<xsl:with-param name="imports">
|
<xsl:if
|
test="$this-local-properties[@multi-valued='true' or
|
@read-only='true' or
|
@hidden='true' or
|
@mandatory='true']">
|
<import>org.opends.server.admin.PropertyOption</import>
|
</xsl:if>
|
<xsl:if
|
test="$this-local-properties/adm:default-behavior/adm:undefined
|
| $this-local-properties[@mandatory='true']">
|
<import>
|
org.opends.server.admin.UndefinedDefaultBehaviorProvider
|
</import>
|
</xsl:if>
|
<xsl:if
|
test="$this-local-properties/adm:default-behavior/adm:alias">
|
<import>
|
org.opends.server.admin.AliasDefaultBehaviorProvider
|
</import>
|
</xsl:if>
|
<xsl:if
|
test="$this-local-properties/adm:default-behavior/adm:defined">
|
<import>
|
org.opends.server.admin.DefinedDefaultBehaviorProvider
|
</import>
|
<import>
|
org.opends.server.admin.DefaultBehaviorProvider
|
</import>
|
</xsl:if>
|
<xsl:element name="import">
|
<xsl:value-of
|
select="concat($this-package, '.client.', $this-java-class, 'CfgClient')" />
|
</xsl:element>
|
<xsl:element name="import">
|
<xsl:value-of
|
select="concat($this-package, '.server.', $this-java-class, 'Cfg')" />
|
</xsl:element>
|
<xsl:for-each select="$this-inherited-properties">
|
<xsl:call-template name="get-property-java-imports" />
|
</xsl:for-each>
|
<xsl:for-each select="$this-all-properties">
|
<xsl:call-template
|
name="get-property-definition-java-imports" />
|
</xsl:for-each>
|
<xsl:for-each select="$this-all-relations">
|
<xsl:variable name="java-class-name">
|
<xsl:call-template name="name-to-java">
|
<xsl:with-param name="value"
|
select="@managed-object-name" />
|
</xsl:call-template>
|
</xsl:variable>
|
<xsl:element name="import">
|
<xsl:value-of
|
select="concat(@managed-object-package, '.client.', $java-class-name, 'CfgClient')" />
|
</xsl:element>
|
<xsl:element name="import">
|
<xsl:value-of
|
select="concat(@managed-object-package, '.server.', $java-class-name, 'Cfg')" />
|
</xsl:element>
|
</xsl:for-each>
|
<xsl:choose>
|
<xsl:when test="$this-is-abstract">
|
<import>
|
org.opends.server.admin.AbstractManagedObjectDefinition
|
</import>
|
</xsl:when>
|
<xsl:otherwise>
|
<import>
|
org.opends.server.admin.ManagedObjectDefinition
|
</import>
|
<import>org.opends.server.admin.PropertyProvider</import>
|
<import>org.opends.server.admin.OperationsException</import>
|
<import>
|
org.opends.server.admin.client.ManagedObject
|
</import>
|
<import>
|
org.opends.server.admin.server.ServerManagedObject
|
</import>
|
<xsl:if test="not($this-is-root)">
|
<import>
|
org.opends.server.admin.server.ConfigurationChangeListener
|
</import>
|
<xsl:call-template
|
name="generate-change-listener-import-statements" />
|
</xsl:if>
|
<import>org.opends.server.types.DN</import>
|
<xsl:if test="$this-all-relations/adm:one-to-many">
|
<import>
|
org.opends.server.admin.InstantiableRelationDefinition
|
</import>
|
<import>
|
org.opends.server.admin.server.ConfigurationAddListener
|
</import>
|
<import>
|
org.opends.server.admin.server.ConfigurationDeleteListener
|
</import>
|
<import>org.opends.server.config.ConfigException</import>
|
</xsl:if>
|
<xsl:if test="$this-all-relations/adm:one-to-zero-or-one">
|
<import>
|
org.opends.server.admin.OptionalRelationDefinition
|
</import>
|
<import>
|
org.opends.server.admin.server.ConfigurationAddListener
|
</import>
|
<import>
|
org.opends.server.admin.server.ConfigurationDeleteListener
|
</import>
|
<import>org.opends.server.config.ConfigException</import>
|
</xsl:if>
|
<xsl:if test="$this-all-relations/adm:one-to-one">
|
<import>
|
org.opends.server.admin.SingletonRelationDefinition
|
</import>
|
<import>org.opends.server.config.ConfigException</import>
|
</xsl:if>
|
<xsl:if test="$this-all-properties[@multi-valued='true']">
|
<import>java.util.SortedSet</import>
|
<import>java.util.Collection</import>
|
</xsl:if>
|
</xsl:otherwise>
|
</xsl:choose>
|
<xsl:if test="$this/@extends">
|
<xsl:if test="$parent-package != $this-package">
|
<xsl:element name="import">
|
<xsl:value-of
|
select="concat($parent-package, '.meta.', $parent-java-class, 'CfgDefn')" />
|
</xsl:element>
|
</xsl:if>
|
</xsl:if>
|
</xsl:with-param>
|
</xsl:call-template>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-meta-class-declaration" />
|
<xsl:text>
</xsl:text>
|
<xsl:call-template name="generate-meta-class-body" />
|
<xsl:text>}
</xsl:text>
|
</xsl:template>
|
</xsl:stylesheet>
|