From 8633e780ffe89c5cf5453d40b9b65fd3fd1ef17f Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Sat, 15 Sep 2007 20:33:33 +0000
Subject: [PATCH] Performance improvements to server-side admin framework.
---
opendj-sdk/opends/resource/admin/metaMO.xsl | 81 ++++++++++++++++++++++++--
opendj-sdk/opends/src/server/org/opends/server/admin/server/ServerManagedObject.java | 12 ++--
opendj-sdk/opends/resource/admin/property-types.xsl | 34 +++++++++--
3 files changed, 107 insertions(+), 20 deletions(-)
diff --git a/opendj-sdk/opends/resource/admin/metaMO.xsl b/opendj-sdk/opends/resource/admin/metaMO.xsl
index cb1f445..cc8d47f 100644
--- a/opendj-sdk/opends/resource/admin/metaMO.xsl
+++ b/opendj-sdk/opends/resource/admin/metaMO.xsl
@@ -86,7 +86,8 @@
<xsl:for-each
select="$this-local-properties[adm:syntax/adm:enumeration and not(adm:profile[@name='preprocessor']/adm:first-defined-in)]">
<xsl:sort select="@name" />
- <xsl:if test="not(adm:profile[@name='preprocessor']/admpp:first-defined-in)">
+ <xsl:if
+ test="not(adm:profile[@name='preprocessor']/admpp:first-defined-in)">
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
@@ -368,7 +369,8 @@
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:text>
</xsl:text>
- <xsl:call-template name="generate-property-getter-implementation">
+ <xsl:call-template
+ name="generate-property-getter-implementation">
<xsl:with-param name="interface" select="'client'" />
</xsl:call-template>
<xsl:text>
</xsl:text>
@@ -455,6 +457,50 @@
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>
+ <xsl:value-of
+ select="concat(' // The value of the "', @name, '" property.
')" />
+ <xsl:value-of select="' private final '" />
+ <xsl:choose>
+ <xsl:when test="string(@multi-valued) != 'true'">
+ <xsl:choose>
+ <xsl:when test="adm:default-behavior/adm:defined">
+ <!--
+ The property is guaranteed to contain a value since there is a
+ well-defined default value.
+ -->
+ <xsl:call-template
+ name="get-property-java-primitive-type" />
+ </xsl:when>
+ <xsl:when test="@mandatory = 'true'">
+ <!--
+ The property is guaranteed to contain a value in the server interface.
+ -->
+ <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:value-of select="' p'" />
+ <xsl:call-template name="name-to-java">
+ <xsl:with-param name="value" select="@name" />
+ </xsl:call-template>
+ <xsl:value-of select="';
'" />
+ </xsl:for-each>
+ <!--
Private constructor.
-->
<xsl:text>
</xsl:text>
@@ -465,8 +511,28 @@
' private ',
$this-java-class,
'CfgServerImpl(ServerManagedObject<? extends ', $this-java-class, 'Cfg> impl) {
',
- ' this.impl = impl;
',
- ' }
')" />
+ ' this.impl = 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" />
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of
+ select="concat(' this.p', $java-prop-name, ' = ')" />
+ <xsl:choose>
+ <xsl:when test="string(@multi-valued) != 'true'">
+ <xsl:value-of
+ select="concat('impl.getPropertyValue(INSTANCE.get', $java-prop-name , 'PropertyDefinition());
')" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
+ select="concat('impl.getPropertyValues(INSTANCE.get', $java-prop-name , 'PropertyDefinition());
')" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:value-of select="' }
'" />
<!--
Generate all the change listener methods - one for each managed
object in the hierarchy.
@@ -478,14 +544,15 @@
<xsl:call-template name="generate-change-listener" />
</xsl:if>
<!--
- Getters/Setters for all properties.
+ 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-getter-implementation">
+ <xsl:call-template
+ name="generate-property-getter-implementation">
<xsl:with-param name="interface" select="'server'" />
</xsl:call-template>
</xsl:for-each>
@@ -716,7 +783,7 @@
select="concat(' PD_', $java-prop-name, ' = builder.getInstance();
')" />
<xsl:value-of
select="concat(' INSTANCE.registerPropertyDefinition(PD_', $java-prop-name, ');
')" />
- <xsl:call-template name="get-property-definition-post-ctor"/>
+ <xsl:call-template name="get-property-definition-post-ctor" />
<xsl:value-of select="' }
'" />
</xsl:template>
<!--
diff --git a/opendj-sdk/opends/resource/admin/property-types.xsl b/opendj-sdk/opends/resource/admin/property-types.xsl
index 35cef9d..07f5a7f 100644
--- a/opendj-sdk/opends/resource/admin/property-types.xsl
+++ b/opendj-sdk/opends/resource/admin/property-types.xsl
@@ -351,10 +351,20 @@
</xsl:choose>
</xsl:when>
<xsl:otherwise>
- <xsl:value-of
- select="concat(' *
',
+ <xsl:choose>
+ <xsl:when test="$interface='server'">
+ <xsl:value-of
+ select="concat(' *
',
+ ' * @return Returns an unmodifiable set containing the values of the "', $name,'" property.
',
+ ' */
')" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of
+ select="concat(' *
',
' * @return Returns the values of the "', $name,'" property.
',
' */
')" />
+ </xsl:otherwise>
+ </xsl:choose>
<xsl:value-of select="' SortedSet<'" />
<xsl:call-template name="get-property-java-type" />
<xsl:value-of select="'>'" />
@@ -435,21 +445,31 @@
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
- <xsl:when test="string(@multi-valued) != 'true'">
+ <xsl:when test="$interface='server'">
<xsl:value-of
select="concat($java-prop-name, '() {
',
+ ' return p', $java-prop-name , ';
' ,
+ ' }
')" />
+ </xsl:when>
+ <xsl:otherwise>
+ <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, '() {
',
+ </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:otherwise>
</xsl:choose>
</xsl:template>
diff --git a/opendj-sdk/opends/src/server/org/opends/server/admin/server/ServerManagedObject.java b/opendj-sdk/opends/src/server/org/opends/server/admin/server/ServerManagedObject.java
index b17386b..89103c6 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/admin/server/ServerManagedObject.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/admin/server/ServerManagedObject.java
@@ -33,12 +33,12 @@
import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.server.util.StaticUtils.*;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
-import java.util.TreeSet;
import org.opends.messages.AdminMessages;
import org.opends.messages.Message;
@@ -411,10 +411,10 @@
* The type of the property to be retrieved.
* @param d
* The property to be retrieved.
- * @return Returns a newly allocated set containing a copy of the
- * property's effective values. An empty set indicates that
- * the property has no default values defined and any
- * default behavior is applicable.
+ * @return Returns an unmodifiable set containing the property's
+ * effective values. An empty set indicates that the
+ * property has no default values defined and any default
+ * behavior is applicable.
* @throws IllegalArgumentException
* If the property definition is not associated with this
* managed object's definition.
@@ -425,7 +425,7 @@
if (!properties.containsKey(d)) {
throw new IllegalArgumentException("Unknown property " + d.getName());
}
- return new TreeSet<T>((SortedSet<T>) properties.get(d));
+ return Collections.unmodifiableSortedSet((SortedSet<T>) properties.get(d));
}
--
Gitblit v1.10.0