1530N/A ! The contents of this file are subject to the terms of the 1530N/A ! Common Development and Distribution License, Version 1.0 only 1530N/A ! (the "License"). You may not use this file except in compliance 1530N/A ! You can obtain a copy of the license at 1530N/A ! See the License for the specific language governing permissions 1530N/A ! and limitations under the License. 1530N/A ! When distributing Covered Code, include this CDDL HEADER in each 1530N/A ! file and include the License file at 1530N/A ! add the following below this CDDL HEADER, with the fields enclosed 1530N/A ! by brackets "[]" replaced with your own identifying information: 1530N/A ! Portions Copyright [yyyy] [name of copyright owner] 3215N/A ! Portions Copyright 2007 Sun Microsystems, Inc. 1530N/A <
xsl:
output method="text" encoding="us-ascii" />
1530N/A Template for generating the class declaration. 2872N/A <
xsl:
template name="generate-meta-class-declaration">
2872N/A <
xsl:
value-
of select="'/**
'" />
2872N/A <
xsl:
call-
template name="add-java-comment">
2872N/A <
xsl:
with-
param name="indent-text" select="' *'" />
2872N/A <
xsl:
with-
param name="content" 2872N/A select="concat('An interface for querying the ', $this-ufn, 2872N/A ' managed object definition meta information.')" />
2872N/A <
xsl:
value-
of select="' * <p>
'" />
2872N/A <
xsl:
call-
template name="add-java-comment">
2872N/A <
xsl:
with-
param name="indent-text" select="' *'" />
1530N/A <
xsl:
value-
of select="' */
'" />
1530N/A select="concat('public final class ', 2995N/A <
xsl:
when test="$this-is-abstract">
2995N/A select="concat('AbstractManagedObjectDefinition<', 2995N/A $this-java-class, 'CfgClient, ', 2995N/A $this-java-class, 'Cfg> {
')" />
1530N/A select="concat('ManagedObjectDefinition<', 1530N/A $this-java-class, 'CfgClient, ', 1530N/A $this-java-class, 'Cfg> {
')" />
1530N/A Template for generating the meta class body. 1530N/A <
xsl:
template name="generate-meta-class-body">
1530N/A Singleton configuration definition instance. select="concat(' // The singleton configuration definition instance.
', ' private static final ', 'CfgDefn INSTANCE = new ', $this-java-class, 'CfgDefn();
')" />
Generate enumerations defined by this managed object.. select="$this-local-properties[adm:syntax/adm:enumeration and not(adm:profile[@name='preprocessor']/adm:first-defined-in)]">
<
xsl:
sort select="@name" />
test="not(adm:profile[@name='preprocessor']/admpp:first-defined-in)">
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
call-
template name="generate-enumeration" />
Define application tags if this is the root configuration. <
xsl:
if test="$this-is-root">
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
value-
of select="' // Define managed object tags.
'" />
<
xsl:
value-
of select="' static {
'" />
<
xsl:
for-
each select="$this/adm:tag-definition">
<
xsl:
sort select="@name" />
select="concat(' Tag.define("', @name, '");
')" />
<
xsl:
value-
of select="' }
'" />
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" />
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" />
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" />
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" />
Register any tags associated with this managed object definition. <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="' // Register the tags associated with this managed object definition.
'" />
<
xsl:
value-
of select="' static {
'" />
<
xsl:
for-
each select="$this/adm:tag">
<
xsl:
sort select="@name" />
<
xsl:
value-
of select="' }
'" />
Register any constraints associated with this managed object definition. <
xsl:
if test="$this/adm:constraint">
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="' // Register the constraints associated with this managed object definition.
'" />
<
xsl:
value-
of select="' static {
'" />
<
xsl:
for-
each select="$this/adm:constraint">
<
xsl:
apply-
templates select="adm:condition/*" mode="compile-condition" />
<
xsl:
value-
of select="'));
'" />
<
xsl:
value-
of select="' }
'" />
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:
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:
value-
of select="' */
'" />
select="concat(' public static ', 'CfgDefn getInstance() {
', ' return INSTANCE;
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' * Private constructor.
', <
xsl:
when test="boolean($this/@extends)">
select="concat(' super("', select="concat(' super("', <
xsl:
value-
of select="' }
'" />
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. select="concat(' /**
', 'CfgClient createClientConfiguration(
', ' ManagedObject<? extends ', 'CfgClient> impl) {
', 'CfgClientImpl(impl);
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
Generate configuration server factory method. select="concat(' /**
', 'Cfg createServerConfiguration(
', ' ServerManagedObject<? extends ',$this-java-class,'Cfg> impl) {
', 'CfgServerImpl(impl);
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
Generate configuration server class getter.. select="concat(' /**
', 'Cfg> getServerConfigurationClass() {
', Generate property definition 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>
<
xsl:
call-
template name="generate-property-definition-getter" />
Generate relation definition getters for all 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" />
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" />
Generate managed object client class implementation. <
xsl:
template name="generate-client-impl-class">
select="concat(' /**
', ' * Managed object client implementation.
', ' private static class ', 'CfgClientImpl implements
 ', <
xsl:
text>
</
xsl:
text>
select="concat(' // Private implementation.
', ' private ManagedObject<? extends ', 'CfgClient> impl;
')" />
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' // Private constructor.
', ' ManagedObject<? extends ', 'CfgClient> impl) {
', <
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="'client'" />
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
call-
template name="generate-property-setter-implementation" />
<
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" />
Managed object definition getter. <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public ManagedObjectDefinition<? extends ', $this-java-class,'CfgClient, ? extends ', $this-java-class,'Cfg> definition() {
', ' return INSTANCE;
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public PropertyProvider properties() {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public void commit() throws ManagedObjectAlreadyExistsException,
', ' MissingMandatoryPropertiesException, ConcurrentModificationException,
', ' OperationRejectedException, AuthorizationException,
', ' CommunicationException {
', <
xsl:
text>
</
xsl:
text>
<
xsl:
value-
of select="' }
'" />
Generate managed object server class implementation. <
xsl:
template name="generate-server-impl-class">
select="concat(' /**
', ' * Managed object server implementation.
', ' private static class ', 'CfgServerImpl implements
 ', <
xsl:
text>
</
xsl:
text>
select="concat(' // Private implementation.
', ' private ServerManagedObject<? extends ', $this-java-class, 'Cfg> impl;
')" />
Private members for each property. <
xsl:
for-
each select="$this-all-properties">
<
xsl:
sort select="@name" />
<
xsl:
text>
</
xsl:
text>
select="concat(' // The value of the "', @name, '" property.
')" />
<
xsl:
value-
of select="' private final '" />
<
xsl:
when test="string(@multi-valued) != 'true'">
The property is guaranteed to contain a value since there is a well-defined default value. name="get-property-java-primitive-type" />
<
xsl:
when test="@mandatory = 'true'">
The property is guaranteed to contain a value in the server interface. name="get-property-java-primitive-type" />
<
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 definition getter. <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public ManagedObjectDefinition<? extends ', $this-java-class,'CfgClient, ? extends ', $this-java-class,'Cfg> definition() {
', ' return INSTANCE;
', Server managed object getter. <
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
<
xsl:
text>
</
xsl:
text>
select="concat(' /**
', ' public ServerManagedObject<? extends ', $this-java-class,'Cfg> managedObject() {
', 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="adm:one-to-many">
<
xsl:
text>InstantiableRelationDefinition<</
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="adm:one-to-many">
<
xsl:
text>InstantiableRelationDefinition</
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:
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:
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="adm:one-to-many">
<
xsl:
text>InstantiableRelationDefinition<</
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>
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:
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 are non-mandatory or have a default. test="not($this-is-abstract) and @advanced='true' and @mandatory='true'">
<
xsl:
message terminate="yes">
select="concat('Property "', @name, '" is advanced and mandatory but has no 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')" />
<
xsl:
if test="$this-local-relations[@hidden='true']">
<
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>