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 ! You can obtain a copy of the license at 0N/A ! See the License for the specific language governing permissions 0N/A ! and limitations under the License. 0N/A ! When distributing Covered Code, include this CDDL HEADER in each 0N/A ! file and include the License file at 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 ! Copyright 2007-2009 Sun Microsystems, Inc. 0N/A <
xsl:
output method="text" encoding="us-ascii" />
0N/A Template for generating the class declaration. 0N/A <
xsl:
template name="generate-meta-class-declaration">
0N/A <
xsl:
value-
of select="'/**
'" />
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('An interface for querying the ', $this-ufn, 0N/A ' managed object definition meta information.')" />
0N/A </
xsl:
call-
template>
0N/A <
xsl:
value-
of select="' * <p>
'" />
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="' */
'" />
0N/A select="concat('public final class ', 0N/A 'CfgDefn extends ')" />
0N/A <
xsl:
when test="$this-is-abstract">
0N/A select="concat('AbstractManagedObjectDefinition<', 0N/A $this-java-class, 'CfgClient, ', 0N/A $this-java-class, 'Cfg> {
')" />
0N/A select="concat('ManagedObjectDefinition<', 0N/A $this-java-class, 'CfgClient, ', 0N/A $this-java-class, 'Cfg> {
')" />
0N/A Template for generating the meta class body. 0N/A <
xsl:
template name="generate-meta-class-body">
0N/A Singleton configuration definition instance. 0N/A select="concat(' // The singleton configuration definition instance.
', 0N/A ' private static final ', 0N/A 'CfgDefn INSTANCE = new ', $this-java-class, 'CfgDefn();
')" />
0N/A Generate enumerations defined by this managed object.. 0N/A select="$this-local-properties[adm:syntax/adm:enumeration and not(adm:profile[@name='preprocessor']/adm:first-defined-in)]">
0N/A <
xsl:
sort select="@name" />
0N/A test="not(adm:profile[@name='preprocessor']/admpp:first-defined-in)">
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
call-
template name="generate-enumeration" />
0N/A Define application tags if this is the root configuration. 0N/A <
xsl:
if test="$this-is-root">
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
value-
of select="' // Define managed object tags.
'" />
0N/A <
xsl:
value-
of select="' static {
'" />
0N/A <
xsl:
sort select="@name" />
0N/A <
xsl:
value-
of select="' }
'" />
0N/A Generate declarations for properties defined or 0N/A overridden by this managed object. 0N/A <
xsl:
for-
each select="$this-local-properties">
0N/A <
xsl:
sort select="@name" />
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
call-
template name="generate-property-declaration" />
0N/A Generate declarations for relations. 0N/A <
xsl:
for-
each select="$this-local-relations">
0N/A <
xsl:
sort select="@name" />
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
call-
template name="generate-relation-declaration" />
0N/A Generate constructors for properties defined or 0N/A overridden by this managed object. 0N/A <
xsl:
for-
each select="$this-local-properties">
0N/A <
xsl:
sort select="@name" />
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
call-
template name="generate-property-constructor" />
0N/A Generate constructors for relations. 0N/A <
xsl:
for-
each select="$this-local-relations">
0N/A <
xsl:
sort select="@name" />
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
call-
template name="generate-relation-constructor" />
0N/A Register any optins associated with this managed object definition. 0N/A <
xsl:
if test="$this-is-advanced or $this-is-hidden">
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A select="' // Register the options associated with this managed object definition.
'" />
0N/A <
xsl:
value-
of select="' static {
'" />
0N/A <
xsl:
if test="$this-is-advanced">
0N/A <
xsl:
if test="$this-is-hidden">
0N/A <
xsl:
value-
of select="' }
'" />
0N/A Register any tags associated with this managed object definition. 0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A select="' // Register the tags associated with this managed object definition.
'" />
0N/A <
xsl:
value-
of select="' static {
'" />
0N/A <
xsl:
sort select="@name" />
0N/A <
xsl:
value-
of select="' }
'" />
0N/A Register any constraints associated with this managed object definition. 0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A select="' // Register the constraints associated with this managed object definition.
'" />
0N/A <
xsl:
value-
of select="' static {
'" />
0N/A <
xsl:
apply-
templates select="adm:condition/*" 0N/A mode="compile-condition" />
0N/A <
xsl:
value-
of select="'));
'" />
0N/A <
xsl:
value-
of select="' }
'" />
0N/A Configuration definition singleton getter. 0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
value-
of select="' /**
'" />
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('Get the ', $this-ufn,' configuration definition singleton.')" />
0N/A </
xsl:
call-
template>
0N/A <
xsl:
value-
of select="' *
'" />
0N/A <
xsl:
call-
template name="add-java-comment">
0N/A <
xsl:
with-
param name="indent-text" select="' *'" />
0N/A <
xsl:
with-
param name="indent-text2" select="' * '" />
0N/A <
xsl:
with-
param name="content" 0N/A select="concat('@return Returns the ', $this-ufn, 0N/A ' configuration definition singleton.')" />
0N/A </
xsl:
call-
template>
0N/A <
xsl:
value-
of select="' */
'" />
0N/A select="concat(' public static ', 0N/A 'CfgDefn getInstance() {
', 0N/A ' return INSTANCE;
', 0N/A Private constructor. 0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A select="concat(' /**
', 0N/A ' * Private constructor.
', 0N/A 'CfgDefn() {
')" />
0N/A <
xsl:
when test="boolean($this/@extends)">
0N/A select="concat(' super("', 0N/A select="concat(' super("', 0N/A <
xsl:
value-
of select="' }
'" />
0N/A Create configuration view factory methods for non-abstract definitions 0N/A <
xsl:
if test="not($this-is-abstract)">
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A Generate configuration client factory method. 0N/A select="concat(' /**
', 0N/A ' * {@inheritDoc}
', 0N/A 'CfgClient createClientConfiguration(
', 0N/A ' ManagedObject<? extends ', 0N/A 'CfgClient> impl) {
', 0N/A 'CfgClientImpl(impl);
', 0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A Generate configuration server factory method. 0N/A select="concat(' /**
', 0N/A ' * {@inheritDoc}
', 0N/A 'Cfg createServerConfiguration(
', 0N/A ' ServerManagedObject<? extends ',$this-java-class,'Cfg> impl) {
', 0N/A 'CfgServerImpl(impl);
', 0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A Generate configuration server class getter.. 0N/A select="concat(' /**
', 0N/A ' * {@inheritDoc}
', 0N/A ' public Class<', 0N/A 'Cfg> getServerConfigurationClass() {
', 0N/A Generate property definition getters for all properties. 0N/A <
xsl:
for-
each select="$this-all-properties">
0N/A <
xsl:
sort select="@name" />
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
call-
template name="generate-property-definition-getter" />
0N/A Generate relation definition getters for all relations. 0N/A <
xsl:
for-
each select="$this-all-relations">
0N/A <
xsl:
sort select="@name" />
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
call-
template name="generate-relation-definition-getter" />
0N/A Managed object class implementations. 0N/A <
xsl:
if test="not($this-is-abstract)">
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
call-
template name="generate-client-impl-class" />
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
call-
template name="generate-server-impl-class" />
0N/A Generate managed object client class implementation. 0N/A <
xsl:
template name="generate-client-impl-class">
0N/A select="concat(' /**
', 0N/A ' * Managed object client implementation.
', 0N/A ' private static class ', 0N/A 'CfgClientImpl implements
 ', 0N/A 'CfgClient {
')" />
0N/A <
xsl:
text>
</
xsl:
text>
0N/A select="concat(' // Private implementation.
', 0N/A ' private ManagedObject<? extends ', 0N/A 'CfgClient> impl;
')" />
0N/A Private constructor. 0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A select="concat(' // Private constructor.
', 0N/A 'CfgClientImpl(
', 0N/A ' ManagedObject<? extends ', 0N/A 'CfgClient> impl) {
', 0N/A <
xsl:
for-
each select="$this-all-properties">
0N/A <
xsl:
sort select="@name" />
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A name="generate-property-getter-implementation">
0N/A <
xsl:
with-
param name="interface" select="'client'" />
0N/A </
xsl:
call-
template>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
call-
template name="generate-property-setter-implementation" />
0N/A <
xsl:
for-
each select="$this-all-relations">
0N/A <
xsl:
sort select="@name" />
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
call-
template name="generate-client-relation-methods" />
0N/A Managed object definition getter. 0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A select="concat(' /**
', 0N/A ' * {@inheritDoc}
', 0N/A ' public ManagedObjectDefinition<? extends ', $this-java-class,'CfgClient, ? extends ', $this-java-class,'Cfg> definition() {
', 0N/A ' return INSTANCE;
', 0N/A Property provider view. 0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A select="concat(' /**
', 0N/A ' * {@inheritDoc}
', 0N/A ' public PropertyProvider properties() {
', 0N/A ' return impl;
', 0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A select="concat(' /**
', 0N/A ' * {@inheritDoc}
', 0N/A ' public void commit() throws ManagedObjectAlreadyExistsException,
', 0N/A ' MissingMandatoryPropertiesException, ConcurrentModificationException,
', 0N/A ' OperationRejectedException, AuthorizationException,
', 0N/A ' CommunicationException {
', 0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
value-
of select="' }
'" />
0N/A Generate managed object server class implementation. 0N/A <
xsl:
template name="generate-server-impl-class">
0N/A select="concat(' /**
', 0N/A ' * Managed object server implementation.
', 0N/A ' private static class ', 0N/A 'CfgServerImpl implements
 ', 0N/A <
xsl:
text>
</
xsl:
text>
0N/A select="concat(' // Private implementation.
', 0N/A ' private ServerManagedObject<? extends ', $this-java-class, 'Cfg> impl;
')" />
0N/A Private members for each property. 0N/A <
xsl:
for-
each select="$this-all-properties">
0N/A <
xsl:
sort select="@name" />
0N/A <
xsl:
text>
</
xsl:
text>
0N/A select="concat(' // The value of the "', @name, '" property.
')" />
0N/A <
xsl:
value-
of select="' private final '" />
0N/A <
xsl:
when test="string(@multi-valued) != 'true'">
0N/A The property is guaranteed to contain a value since there is a 0N/A well-defined default value. 0N/A name="get-property-java-primitive-type" />
0N/A <
xsl:
when test="@mandatory = 'true'">
0N/A The property is guaranteed to contain a value in the server interface. 0N/A name="get-property-java-primitive-type" />
0N/A <
xsl:
call-
template name="get-property-java-type" />
<
xsl:
value-
of select="'SortedSet<'" />
<
xsl:
call-
template name="get-property-java-type" />
<
xsl:
value-
of select="'>'" />
<
xsl:
value-
of select="' p'" />
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="@name" />
<
xsl:
value-
of select="';
'" />
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' // Private constructor.
', 'CfgServerImpl(ServerManagedObject<? extends ', $this-java-class, 'Cfg> impl) {
', <
xsl:
for-
each select="$this-all-properties">
<
xsl:
sort select="@name" />
<
xsl:
variable name="java-prop-name">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="@name" />
select="concat(' this.p', $java-prop-name, ' = ')" />
<
xsl:
when test="string(@multi-valued) != 'true'">
<
xsl:
value-
of select="' }
'" />
Generate all the change listener methods - one for each managed <
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" />
Getters 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>
name="generate-property-getter-implementation">
<
xsl:
with-
param name="interface" select="'server'" />
<
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" />
Configuration class getter. <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public Class<? extends ', $this-java-class,'Cfg> configurationClass() {
', ' return ', $this-java-class, 'Cfg.class;
', Configuration entry DN getter. <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public DN dn() {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
value-
of select="' }
'" />
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:
variable name="type">
<
xsl:
call-
template name="get-property-definition-type" />
<
xsl:
variable name="generic-type">
<
xsl:
call-
template name="get-property-definition-generic-type" />
<
xsl:
variable name="pdtype">
<
xsl:
when test="string-length($generic-type) != 0">
select="concat($type, '<', $generic-type, '>')" />
<
xsl:
value-
of select="$type" />
select="concat(' // The "', '" property definition.
', ' private static final ', $pdtype, ' PD_', $java-prop-name, ';
')" />
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:
variable name="type">
<
xsl:
call-
template name="get-property-definition-type" />
<
xsl:
variable name="generic-type">
<
xsl:
call-
template name="get-property-definition-generic-type" />
<
xsl:
variable name="value-type">
<
xsl:
call-
template name="get-property-java-type" />
select="concat(' // Build the "', @name, '" property definition.
', <
xsl:
when test="string-length($generic-type) != 0">
select="concat(' ', $type, '.Builder<', $generic-type, '> builder = ', $type, '.createBuilder(INSTANCE, "',@name, '");
')" />
select="concat(' ', $type, '.Builder builder = ', $type, '.createBuilder(INSTANCE, "',@name, '");
')" />
<
xsl:
if test="@multi-valued='true'">
<
xsl:
if test="@read-only='true'">
<
xsl:
if test="@monitoring='true'">
<
xsl:
if test="@mandatory='true'">
<
xsl:
if test="@hidden='true'">
<
xsl:
if test="@advanced='true'">
<
xsl:
variable name="action-type">
<
xsl:
when test="adm:requires-admin-action">
<
xsl:
call-
template name="name-to-java-constant">
<
xsl:
with-
param name="value" select="local-name(adm:requires-admin-action/*)" />
<
xsl:
value-
of select="'NONE'" />
select="concat(' DefaultBehaviorProvider<', $value-type,'> provider = ', 'new DefinedDefaultBehaviorProvider<', $value-type,'>(')" />
select="concat('"', normalize-space(), '"')" />
<
xsl:
if test="position() != last()">
<
xsl:
value-
of select="', '" />
<
xsl:
value-
of select="');
'" />
select="concat(' DefaultBehaviorProvider<', $value-type,'> provider = ', 'new RelativeInheritedDefaultBehaviorProvider<', $value-type,'>(')" />
<
xsl:
variable name="managed-object-name">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" <
xsl:
variable name="property-name" <
xsl:
variable name="offset" select="concat($managed-object-name, 'CfgDefn.getInstance(), "', $property-name, '", ', $offset, ');
')" />
select="concat(' DefaultBehaviorProvider<', $value-type,'> provider = ', 'new AbsoluteInheritedDefaultBehaviorProvider<', $value-type,'>(')" />
<
xsl:
variable name="property-name" <
xsl:
variable name="path" select="concat('"', $path, '", "', $property-name, '");
')" />
<
xsl:
message terminate="yes">
select="concat('Unrecognized default behavior type for property "', @name, <
xsl:
call-
template name="get-property-definition-ctor" />
<
xsl:
call-
template name="get-property-definition-post-ctor" />
<
xsl:
value-
of select="' }
'" />
Generate a relation definition declaration. <
xsl:
template name="generate-relation-declaration">
<
xsl:
variable name="relation-name">
<
xsl:
when test="adm:one-to-many">
<
xsl:
value-
of select="adm:one-to-many/@plural-name" />
<
xsl:
value-
of select="@name" />
<
xsl:
variable name="java-relation-name">
<
xsl:
call-
template name="name-to-java-constant">
<
xsl:
with-
param name="value" select="$relation-name" />
<
xsl:
variable name="java-managed-object-name">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="@managed-object-name" />
select="concat(' // The "', '" relation definition.
', ' private static final ')" />
<
xsl:
when test="adm:one-to-one">
<
xsl:
text>SingletonRelationDefinition<</
xsl:
text>
<
xsl:
when test="adm:one-to-zero-or-one">
<
xsl:
text>OptionalRelationDefinition<</
xsl:
text>
<
xsl:
when test="string(adm:one-to-many/@unique) != 'true'">
<
xsl:
text>InstantiableRelationDefinition<</
xsl:
text>
<
xsl:
when test="string(adm:one-to-many/@unique) = 'true'">
<
xsl:
text>SetRelationDefinition<</
xsl:
text>
<
xsl:
message terminate="yes">
select="concat('Unknown relation type "', local-name(*), '" in relation "', @name, '".')" />
select="concat($java-managed-object-name, 'CfgClient, ', $java-managed-object-name, 'Cfg> RD_', $java-relation-name, ';
')" />
Generate a relation definition constructor. <
xsl:
template name="generate-relation-constructor">
<
xsl:
variable name="relation-name">
<
xsl:
when test="adm:one-to-many">
<
xsl:
value-
of select="adm:one-to-many/@plural-name" />
<
xsl:
value-
of select="@name" />
<
xsl:
variable name="java-relation-name">
<
xsl:
call-
template name="name-to-java-constant">
<
xsl:
with-
param name="value" select="$relation-name" />
<
xsl:
variable name="java-managed-object-name">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="@managed-object-name" />
<
xsl:
variable name="java-relation-builder-type">
<
xsl:
when test="adm:one-to-one">
<
xsl:
text>SingletonRelationDefinition</
xsl:
text>
<
xsl:
when test="adm:one-to-zero-or-one">
<
xsl:
text>OptionalRelationDefinition</
xsl:
text>
<
xsl:
when test="string(adm:one-to-many/@unique) != 'true'">
<
xsl:
text>InstantiableRelationDefinition</
xsl:
text>
<
xsl:
when test="string(adm:one-to-many/@unique) = 'true'">
<
xsl:
text>SetRelationDefinition</
xsl:
text>
<
xsl:
message terminate="yes">
select="concat('Unknown relation type "', local-name(*), '" in relation "', @name, '".')" />
select="concat('.Builder<', $java-managed-object-name, 'CfgClient, ', $java-managed-object-name, 'Cfg>')" />
select="concat(' // Build the "', $relation-name, '" relation definition.
', ' ', $java-relation-builder-type, ' builder =
', ' new ', $java-relation-builder-type, '(INSTANCE, "', @name, '", ')" />
<
xsl:
if test="adm:one-to-many">
select="concat('"', adm:one-to-many/@plural-name, '", ')" />
<
xsl:
if test="adm:one-to-many/@naming-property">
<
xsl:
if test="string(adm:one-to-many/@unique) = 'true'">
<
xsl:
message terminate="yes">
select="concat('Naming properties found in unique one-to-many relation "', @name, '".')" />
<
xsl:
variable name="java-property-name">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="adm:one-to-many/@naming-property" />
$java-managed-object-name, $java-property-name, 'PropertyDefinition());
')" />
<
xsl:
for-
each select="*/adm:default-managed-object">
<
xsl:
variable name="dmo-java-name">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="@managed-object-name" />
<
xsl:
value-
of select="' {
'" />
$dmo-java-name, 'CfgClient, ', $dmo-java-name, 'CfgClient, ', $dmo-java-name, 'Cfg>(', <
xsl:
for-
each select="adm:property">
<
xsl:
for-
each select="adm:value">
select="concat(', "', normalize-space(), '"')" />
<
xsl:
value-
of select="');
'" />
<
xsl:
value-
of select="' }
'" />
<
xsl:
if test="@advanced='true'">
<
xsl:
if test="@hidden='true'">
<
xsl:
value-
of select="' }
'" />
Generate a property definition getter for a locally defined <
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:
variable name="java-prop-name-constant">
<
xsl:
call-
template name="name-to-java-constant">
<
xsl:
with-
param name="value" select="@name" />
<
xsl:
variable name="type">
<
xsl:
call-
template name="get-property-definition-type" />
<
xsl:
variable name="generic-type">
<
xsl:
call-
template name="get-property-definition-generic-type" />
<
xsl:
variable name="pdtype">
<
xsl:
when test="string-length($generic-type) != 0">
select="concat($type, '<', $generic-type, '>')" />
<
xsl:
value-
of select="$type" />
select="concat(' /**
', '" 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:
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" />
test="adm:profile[@name='preprocessor']/admpp:last-defined-in[@name=$this-name and @package=$this-package]">
select="concat(' *
', ' * @return Returns the "', '" property definition.
', 'PropertyDefinition() {
' , $java-prop-name-constant , select="concat(' *
', ' * @return Returns the "', '" property definition.
', 'PropertyDefinition() {
' , 'PropertyDefinition();
', Generate a relation definition getter. <
xsl:
template name="generate-relation-definition-getter">
<
xsl:
variable name="relation-name">
<
xsl:
when test="adm:one-to-many">
<
xsl:
value-
of select="adm:one-to-many/@plural-name" />
<
xsl:
value-
of select="@name" />
<
xsl:
variable name="java-relation-name">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="$relation-name" />
<
xsl:
variable name="java-relation-name-constant">
<
xsl:
call-
template name="name-to-java-constant">
<
xsl:
with-
param name="value" select="$relation-name" />
select="concat(' /**
', '" relation definition.
', ' * @return Returns the "', '" relation definition.
', <
xsl:
when test="adm:one-to-one">
<
xsl:
text>SingletonRelationDefinition<</
xsl:
text>
<
xsl:
when test="adm:one-to-zero-or-one">
<
xsl:
text>OptionalRelationDefinition<</
xsl:
text>
<
xsl:
when test="string(adm:one-to-many/@unique) != 'true'">
<
xsl:
text>InstantiableRelationDefinition<</
xsl:
text>
<
xsl:
when test="string(adm:one-to-many/@unique) = 'true'">
<
xsl:
text>SetRelationDefinition<</
xsl:
text>
<
xsl:
message terminate="yes">
select="concat('Unknown relation type "', local-name(*), '" in relation "', @name, '".')" />
<
xsl:
variable name="java-managed-object-name">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="@managed-object-name" />
test="adm:profile[@name='preprocessor']/admpp:last-defined-in[@name=$this-name and @package=$this-package]">
select="concat($java-managed-object-name, 'CfgClient,', $java-managed-object-name, 'Cfg> get', 'RelationDefinition() {
' , $java-relation-name-constant, select="concat($java-managed-object-name, 'CfgClient,', $java-managed-object-name, 'Cfg> get', 'RelationDefinition() {
' , 'RelationDefinition();
', 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:
variable name="java-class-name">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="@managed-object-name" />
<
xsl:
when test="adm:one-to-one">
select="concat(' /**
', ' public ', $java-class-name, 'CfgClient get', $java-relation-name, '()
', ' throws DefinitionDecodingException, ManagedObjectDecodingException,
', ' ManagedObjectNotFoundException, ConcurrentModificationException,
', ' AuthorizationException, CommunicationException {
', <
xsl:
when test="adm:one-to-zero-or-one">
select="concat(' /**
', ' public boolean has', $java-relation-name, '() throws ConcurrentModificationException,
', ' AuthorizationException, CommunicationException {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public ', $java-class-name, 'CfgClient get', $java-relation-name, '()
', ' throws DefinitionDecodingException, ManagedObjectDecodingException,
', ' ManagedObjectNotFoundException, ConcurrentModificationException,
', ' AuthorizationException, CommunicationException {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public <M extends ', $java-class-name, 'CfgClient> M create', $java-relation-name, '(
', ' ManagedObjectDefinition<M, ? extends ', $java-class-name,'Cfg> d, Collection<DefaultBehaviorException> exceptions) {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public void remove', $java-relation-name, '()
', ' throws ManagedObjectNotFoundException, ConcurrentModificationException,
', ' OperationRejectedException, AuthorizationException, CommunicationException {
', <
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" />
select="concat(' /**
', ' public String[] list', $java-relation-plural-name, '() throws ConcurrentModificationException,
', ' AuthorizationException, CommunicationException {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public ', $java-class-name, 'CfgClient get', $java-relation-name, '(String name)
', ' throws DefinitionDecodingException, ManagedObjectDecodingException,
', ' ManagedObjectNotFoundException, ConcurrentModificationException,
', ' AuthorizationException, CommunicationException {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
when test="string(adm:one-to-many/@unique) != 'true'">
select="concat(' /**
', ' public <M extends ', $java-class-name, 'CfgClient> M create', $java-relation-name, '(
', ' ManagedObjectDefinition<M, ? extends ', $java-class-name,'Cfg> d, String name, Collection<DefaultBehaviorException> exceptions) throws IllegalManagedObjectNameException {
', <
xsl:
when test="string(adm:one-to-many/@unique) = 'true'">
<!-- Unique one-to-many children are named implicitly by their definition --> select="concat(' /**
', ' public <M extends ', $java-class-name, 'CfgClient> M create', $java-relation-name, '(
', ' ManagedObjectDefinition<M, ? extends ', $java-class-name,'Cfg> d, Collection<DefaultBehaviorException> exceptions) {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public void remove', $java-relation-name, '(String name)
', ' throws ManagedObjectNotFoundException, ConcurrentModificationException,
', ' OperationRejectedException, AuthorizationException, CommunicationException {
', <
xsl:
message terminate="yes">
select="concat('Unknown relation type "', local-name(*), '" in relation "', $name, '".')" />
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:
variable name="java-class-name">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="@managed-object-name" />
<
xsl:
when test="adm:one-to-one">
select="concat(' /**
', ' public ', $java-class-name, 'Cfg get', $java-relation-name, '() throws ConfigException {
', <
xsl:
when test="adm:one-to-zero-or-one">
select="concat(' /**
', $java-relation-name, '() {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public ', $java-class-name, 'Cfg get', $java-relation-name, '() throws ConfigException {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public void add', $java-relation-name, 'AddListener(
', ' ConfigurationAddListener<', $java-class-name,'Cfg> listener) throws ConfigException {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public void remove', $java-relation-name, 'AddListener(
', ' ConfigurationAddListener<', $java-class-name,'Cfg> listener) {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public void add', $java-relation-name, 'DeleteListener(
', ' ConfigurationDeleteListener<', $java-class-name,'Cfg> listener) throws ConfigException {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public void remove', $java-relation-name, 'DeleteListener(
', ' ConfigurationDeleteListener<', $java-class-name,'Cfg> listener) {
', <
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" />
select="concat(' /**
', $java-relation-plural-name, '() {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public ', $java-class-name, 'Cfg get', $java-relation-name, '(String name) throws ConfigException {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public void add', $java-relation-name, 'AddListener(
', ' ConfigurationAddListener<', $java-class-name,'Cfg> listener) throws ConfigException {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public void remove', $java-relation-name, 'AddListener(
', ' ConfigurationAddListener<', $java-class-name,'Cfg> listener) {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public void add', $java-relation-name, 'DeleteListener(
', ' ConfigurationDeleteListener<', $java-class-name,'Cfg> listener) throws ConfigException {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public void remove', $java-relation-name, 'DeleteListener(
', ' ConfigurationDeleteListener<', $java-class-name,'Cfg> listener) {
', <
xsl:
message terminate="yes">
select="concat('Unknown relation type "', local-name(*), '" in relation "', $name, '".')" />
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" />
Process parent hierarchy. 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" />
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:
when test="not($top-name) or $top-name = $name">
<
xsl:
value-
of select="''" />
<
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:
variable name="java-class">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="$name" />
<
xsl:
variable name="short-java-class">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="$short-name" />
select="concat(' /**
', select="concat(' public void add', $short-java-class, 'ChangeListener(
', ' ConfigurationChangeListener<',$java-class,'Cfg> listener) {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', select="concat(' public void remove', $short-java-class, 'ChangeListener(
', ' ConfigurationChangeListener<',$java-class,'Cfg> listener) {
', Generate import statements for change-listener <
xsl:
template name="generate-change-listener-import-statements">
Process this managed object. <
xsl:
element name="import">
select="concat($this-package, '.server.', $this-java-class, 'Cfg')" />
Process parent hierarchy. 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:
element name="import">
select="concat(@package, '.server.', $java-class, 'Cfg')" />
Generate an enumeration for a locally defined enumerated property. <
xsl:
template name="generate-enumeration">
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:
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" />
select="concat(' */
', ' public static enum ')" />
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="@name" />
<
xsl:
value-
of select="' {
'" />
<
xsl:
text>
</
xsl:
text>
<
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:synopsis" />
<
xsl:
value-
of select="' */
'" />
<
xsl:
value-
of select="' '" />
<
xsl:
call-
template name="name-to-java-constant">
<
xsl:
with-
param name="value" select="@name" />
<
xsl:
value-
of select="concat('("', @name, '")')" />
<
xsl:
when test="position() != last()">
<
xsl:
value-
of select="',
'" />
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
value-
of select="';
'" />
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
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" />
select="concat('(String name) { this.name = name; }
', ' public String toString() { return name; }
')" />
<
xsl:
text>
</
xsl:
text>
<
xsl:
value-
of select="' }
'" />
Main document parsing template. <!-- Perform some initial validation. <
xsl:
for-
each select="$this-all-properties">
Check that all non-mandatory properties have a default behavior. test="not(@mandatory='true') and not(adm:default-behavior)">
<
xsl:
message terminate="yes">
select="concat('No default behavior defined for non-mandatory property "', @name, Check that all advanced properties conform to one of * is mandatory and has a defined default value(s) * is mandatory and is part of an advanced managed object * is mandatory and is part of an abstract managed object <
xsl:
when test="$this-is-advanced">
<
xsl:
when test="$this-is-abstract">
<
xsl:
when test="@advanced='true' and @mandatory='true'">
<
xsl:
message terminate="yes">
select="concat('Advanced property "', @name, '" must have defined or inherited default values.')" />
Now generate the definition. <
xsl:
call-
template name="copyright-notice" />
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="not(boolean($this/@extends))">
<
xsl:
if test="$this/adm:constraint">
test="$this-local-properties[@multi-valued='true' or <
xsl:
if test="$this-local-properties">
test="$this-local-properties[adm:default-behavior/adm:undefined or not(adm:default-behavior)]">
<
xsl:
if test="@managed-object-package != $this-package">
<
xsl:
variable name="java-class-name">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="@managed-object-name" />
<
xsl:
element name="import">
select="concat(@managed-object-package, '.meta.', $java-class-name, 'CfgDefn')" />
<
xsl:
element name="import">
select="concat($this-package, '.client.', $this-java-class, 'CfgClient')" />
<
xsl:
element name="import">
select="concat($this-package, '.server.', $this-java-class, 'Cfg')" />
<
xsl:
for-
each select="$this-inherited-properties">
<
xsl:
call-
template name="get-property-java-imports">
<
xsl:
with-
param name="interface" select="'server'" />
<
xsl:
for-
each select="$this-all-properties">
name="get-property-definition-java-imports" />
<
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:
element name="import">
select="concat(@managed-object-package, '.client.', $java-class-name, 'CfgClient')" />
<
xsl:
element name="import">
select="concat(@managed-object-package, '.server.', $java-class-name, 'Cfg')" />
test="$this-local-relations/*/adm:default-managed-object">
select="$this-local-relations/*/adm:default-managed-object">
<
xsl:
variable name="java-class-name">
<
xsl:
call-
template name="name-to-java">
<
xsl:
with-
param name="value" select="@managed-object-name" />
<
xsl:
element name="import">
select="concat(@managed-object-package, '.client.', $java-class-name, 'CfgClient')" />
<
xsl:
element name="import">
select="concat(@managed-object-package, '.server.', $java-class-name, 'Cfg')" />
<
xsl:
element name="import">
select="concat(@managed-object-package, '.meta.', $java-class-name, 'CfgDefn')" />
test="$this-local-relations[@advanced='true' or @hidden='true']">
<
xsl:
if test="$this-is-hidden or $this-is-advanced">
<
xsl:
when test="$this-is-abstract">
<
xsl:
if test="not($this-is-root)">
name="generate-change-listener-import-statements" />
<
xsl:
if test="$this-all-relations">
<
xsl:
if test="$this-all-properties[@multi-valued='true']">
<
xsl:
if test="$this-all-properties[@read-only='true']">
<
xsl:
if test="$this/@extends">
<
xsl:
if test="$parent-package != $this-package">
<
xsl:
element name="import">
select="concat($parent-package, '.meta.', $parent-java-class, 'CfgDefn')" />
<
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>