From 41388e8178bd91411face44bba066a5b1e6b34c0 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 29 Oct 2008 07:26:36 +0000
Subject: [PATCH] Modify some code to create unmodifiable collections only once in the life cycle of the descriptor objects.
---
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java | 71 +++++++------
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java | 69 +++++++++++--
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromFile.java | 58 ++++++-----
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/BackendDescriptor.java | 27 ++---
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigReader.java | 32 +++---
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java | 15 +-
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/VLVIndexDescriptor.java | 7
8 files changed, 165 insertions(+), 116 deletions(-)
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/BackendDescriptor.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/BackendDescriptor.java
index 29fc70a..25aa7da 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/BackendDescriptor.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/BackendDescriptor.java
@@ -28,9 +28,7 @@
package org.opends.guitools.controlpanel.datamodel;
import java.util.Collections;
-import java.util.Set;
import java.util.SortedSet;
-import java.util.TreeSet;
import org.opends.admin.ads.ADSContext;
@@ -41,10 +39,9 @@
public class BackendDescriptor
{
private String backendID;
- private SortedSet<BaseDNDescriptor> baseDns = new TreeSet<BaseDNDescriptor>();
- private SortedSet<IndexDescriptor> indexes = new TreeSet<IndexDescriptor>();
- private SortedSet<VLVIndexDescriptor> vlvIndexes =
- new TreeSet<VLVIndexDescriptor>();
+ private SortedSet<BaseDNDescriptor> baseDns;
+ private SortedSet<IndexDescriptor> indexes;
+ private SortedSet<VLVIndexDescriptor> vlvIndexes;
private int entries;
private boolean isConfigBackend;
private boolean isEnabled;
@@ -97,15 +94,15 @@
* @param type the type of the backend.
*/
public BackendDescriptor(String backendID,
- Set<BaseDNDescriptor> baseDns,
- Set<IndexDescriptor> indexes,
- Set<VLVIndexDescriptor> vlvIndexes,
+ SortedSet<BaseDNDescriptor> baseDns,
+ SortedSet<IndexDescriptor> indexes,
+ SortedSet<VLVIndexDescriptor> vlvIndexes,
int entries, boolean isEnabled, Type type)
{
this.backendID = backendID;
- this.baseDns.addAll(baseDns);
- this.indexes.addAll(indexes);
- this.vlvIndexes.addAll(vlvIndexes);
+ this.baseDns = Collections.unmodifiableSortedSet(baseDns);
+ this.indexes = Collections.unmodifiableSortedSet(indexes);
+ this.vlvIndexes = Collections.unmodifiableSortedSet(vlvIndexes);
this.entries = entries;
isConfigBackend = isConfigBackend(backendID);
this.type = type;
@@ -129,7 +126,7 @@
*/
public SortedSet<BaseDNDescriptor> getBaseDns()
{
- return Collections.unmodifiableSortedSet(baseDns);
+ return baseDns;
}
/**
@@ -138,7 +135,7 @@
*/
public SortedSet<VLVIndexDescriptor> getVLVIndexes()
{
- return Collections.unmodifiableSortedSet(vlvIndexes);
+ return vlvIndexes;
}
@@ -148,7 +145,7 @@
*/
public SortedSet<IndexDescriptor> getIndexes()
{
- return Collections.unmodifiableSortedSet(indexes);
+ return indexes;
}
/**
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
index 7c1e8f4..b395fe4 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -110,7 +110,11 @@
private static ControlPanelInfo instance;
- private ControlPanelInfo()
+ /**
+ * Default constructor.
+ *
+ */
+ protected ControlPanelInfo()
{
}
@@ -370,12 +374,55 @@
}
/**
+ * Returns an empty new server descriptor instance.
+ * @return an empty new server descriptor instance.
+ */
+ protected ServerDescriptor createNewServerDescriptorInstance()
+ {
+ return new ServerDescriptor();
+ }
+
+ /**
+ * Returns a reader that will read the configuration from a file.
+ * @return a reader that will read the configuration from a file.
+ */
+ protected ConfigFromFile createNewConfigFromFileReader()
+ {
+ return new ConfigFromFile();
+ }
+
+ /**
+ * Returns a reader that will read the configuration from a dir context.
+ * @return a reader that will read the configuration from a dir context.
+ */
+ protected ConfigFromDirContext createNewConfigFromDirContextReader()
+ {
+ return new ConfigFromDirContext();
+ }
+
+ /**
+ * Updates the contents of the server descriptor with the provider reader.
+ * @param reader the configuration reader.
+ * @param desc the server descriptor.
+ */
+ protected void updateServerDescriptor(ConfigReader reader,
+ ServerDescriptor desc)
+ {
+ desc.setExceptions(reader.getExceptions());
+ desc.setAdministrativeUsers(reader.getAdministrativeUsers());
+ desc.setBackends(reader.getBackends());
+ desc.setConnectionHandlers(reader.getConnectionHandlers());
+ desc.setAdminConnector(reader.getAdminConnector());
+ desc.setSchema(reader.getSchema());
+ desc.setSchemaEnabled(reader.isSchemaEnabled());
+ }
+ /**
* Regenerates the last found ServerDescriptor object.
*
*/
public synchronized void regenerateDescriptor()
{
- ServerDescriptor desc = new ServerDescriptor();
+ ServerDescriptor desc = createNewServerDescriptorInstance();
InitialLdapContext ctx = getDirContext();
desc.setInstallPath(Utilities.getServerRootDirectory());
boolean windowsServiceEnabled = false;
@@ -442,7 +489,7 @@
userDataCtx = null;
}
}
- reader = new ConfigFromFile();
+ reader = createNewConfigFromFileReader();
((ConfigFromFile)reader).readConfiguration();
desc.setAuthenticated(false);
}
@@ -453,12 +500,12 @@
desc.setStatus(ServerDescriptor.ServerStatus.STARTED);
if (ctx == null)
{
- reader = new ConfigFromFile();
+ reader = createNewConfigFromFileReader();
((ConfigFromFile)reader).readConfiguration();
}
else
{
- reader = new ConfigFromDirContext();
+ reader = createNewConfigFromDirContextReader();
((ConfigFromDirContext)reader).readConfiguration(ctx);
if (reader.getExceptions().size() > 0)
{
@@ -479,7 +526,7 @@
if (!connectionWorks)
{
// Try with offline info
- reader = new ConfigFromFile();
+ reader = createNewConfigFromFileReader();
((ConfigFromFile)reader).readConfiguration();
try
{
@@ -518,16 +565,10 @@
{
desc.setStatus(ServerDescriptor.ServerStatus.STOPPED);
desc.setAuthenticated(false);
- reader = new ConfigFromFile();
+ reader = createNewConfigFromFileReader();
((ConfigFromFile)reader).readConfiguration();
}
- desc.setExceptions(reader.getExceptions());
- desc.setAdministrativeUsers(reader.getAdministrativeUsers());
- desc.setBackends(reader.getBackends());
- desc.setConnectionHandlers(reader.getConnectionHandlers());
- desc.setAdminConnector(reader.getAdminConnector());
- desc.setSchema(reader.getSchema());
- desc.setSchemaEnabled(reader.isSchemaEnabled());
+ updateServerDescriptor(reader, desc);
if ((serverDesc == null) || !serverDesc.equals(desc))
{
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
index 3d70f1e..3beec85 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
@@ -119,7 +119,7 @@
*/
public Set<DN> getAdministrativeUsers()
{
- return Collections.unmodifiableSet(administrativeUsers);
+ return administrativeUsers;
}
/**
@@ -128,8 +128,7 @@
*/
public void setAdministrativeUsers(Set<DN> administrativeUsers)
{
- this.administrativeUsers.clear();
- this.administrativeUsers.addAll(administrativeUsers);
+ this.administrativeUsers = Collections.unmodifiableSet(administrativeUsers);
}
/**
@@ -377,7 +376,7 @@
*/
public Set<BackendDescriptor> getBackends()
{
- return Collections.unmodifiableSet(backends);
+ return backends;
}
/**
@@ -386,8 +385,7 @@
*/
public void setBackends(Set<BackendDescriptor> backends)
{
- this.backends.clear();
- this.backends.addAll(backends);
+ this.backends = Collections.unmodifiableSet(backends);
}
/**
@@ -396,7 +394,7 @@
*/
public Set<ConnectionHandlerDescriptor> getConnectionHandlers()
{
- return Collections.unmodifiableSet(listeners);
+ return listeners;
}
/**
@@ -405,8 +403,7 @@
*/
public void setConnectionHandlers(Set<ConnectionHandlerDescriptor> listeners)
{
- this.listeners.clear();
- this.listeners.addAll(listeners);
+ this.listeners = Collections.unmodifiableSet(listeners);
}
/**
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/VLVIndexDescriptor.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/VLVIndexDescriptor.java
index 1a71623..7ba73b1 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/VLVIndexDescriptor.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/VLVIndexDescriptor.java
@@ -27,7 +27,6 @@
package org.opends.guitools.controlpanel.datamodel;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -43,7 +42,7 @@
private DN baseDN;
private Scope scope;
private String filter;
- private List<VLVSortOrder> sortOrder = new ArrayList<VLVSortOrder>();
+ private List<VLVSortOrder> sortOrder = Collections.emptyList();
private int maxBlockSize;
private int hashCode;
@@ -65,7 +64,7 @@
this.baseDN = baseDN;
this.scope = scope;
this.filter = filter;
- this.sortOrder.addAll(sortOrder);
+ this.sortOrder = Collections.unmodifiableList(sortOrder);
this.maxBlockSize = maxBlockSize;
recalculateHashCode();
@@ -126,7 +125,7 @@
*/
public List<VLVSortOrder> getSortOrder()
{
- return Collections.unmodifiableList(sortOrder);
+ return sortOrder;
}
/**
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
index 5be1c2d..0e4bcda 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
@@ -1846,7 +1846,7 @@
* @return the login dialog that is displayed when the method authenticate
* is called.
*/
- GenericDialog getLoginDialog()
+ protected GenericDialog getLoginDialog()
{
if (loginDialog == null)
{
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
index 3b00d79..6ecae6c 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
@@ -30,6 +30,8 @@
import static org.opends.messages.AdminToolMessages.*;
import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -79,7 +81,11 @@
*/
public void readConfiguration(InitialLdapContext ctx)
{
- exceptions.clear();
+ List<OpenDsException> ex = new ArrayList<OpenDsException>();
+ Set<ConnectionHandlerDescriptor> ls =
+ new HashSet<ConnectionHandlerDescriptor>();
+ Set<BackendDescriptor> bs = new HashSet<BackendDescriptor>();
+ Set<DN> as = new HashSet<DN>();
try
{
@@ -88,7 +94,6 @@
JNDIDirContextAdaptor.adapt(ctx));
RootCfgClient root = mCtx.getRootConfiguration();
- listeners.clear();
try
{
AdministrationConnectorCfgClient adminConnector =
@@ -97,7 +102,7 @@
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
String[] connectionHandlers = root.listConnectionHandlers();
for (int i=0; i<connectionHandlers.length; i++)
@@ -106,17 +111,16 @@
{
ConnectionHandlerCfgClient connectionHandler =
root.getConnectionHandler(connectionHandlers[i]);
- listeners.add(getConnectionHandler(connectionHandler,
+ ls.add(getConnectionHandler(connectionHandler,
connectionHandlers[i]));
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
}
isSchemaEnabled = root.getGlobalConfiguration().isCheckSchema();
- backends.clear();
String[] backendNames = root.listBackends();
for (int i=0; i<backendNames.length; i++)
{
@@ -152,7 +156,7 @@
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
indexes.add(
new IndexDescriptor("dn2id", null, null,
@@ -180,7 +184,7 @@
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
}
else if (backend instanceof LDIFBackendCfgClient)
@@ -221,11 +225,11 @@
{
baseDN.setBackend(desc);
}
- backends.add(desc);
+ bs.add(desc);
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
}
@@ -237,7 +241,7 @@
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
@@ -274,7 +278,7 @@
protocol,
ConnectionHandlerDescriptor.State.ENABLED,
"Multimaster Synchronization");
- listeners.add(connHandler);
+ ls.add(connHandler);
}
}
String[] domains = sync.listReplicationDomains();
@@ -285,7 +289,7 @@
ReplicationDomainCfgClient domain =
sync.getReplicationDomain(domains[i]);
DN dn = domain.getBaseDN();
- for (BackendDescriptor backend : backends)
+ for (BackendDescriptor backend : bs)
{
for (BaseDNDescriptor baseDN : backend.getBaseDns())
{
@@ -301,7 +305,7 @@
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
}
@@ -310,22 +314,21 @@
{
RootDNCfgClient rootDN = root.getRootDN();
String[] rootUsers = rootDN.listRootDNUsers();
- administrativeUsers.clear();
if (rootUsers != null)
{
for (int i=0; i < rootUsers.length; i++)
{
RootDNUserCfgClient rootUser = rootDN.getRootDNUser(rootUsers[i]);
- administrativeUsers.addAll(rootUser.getAlternateBindDN());
+ as.addAll(rootUser.getAlternateBindDN());
}
}
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
- updateMonitorInformation(ctx);
+ updateMonitorInformation(ctx, bs, ex);
try
{
@@ -333,18 +336,28 @@
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
}
catch (final Throwable t)
{
- OnlineUpdateException ex = new OnlineUpdateException(
+ OnlineUpdateException oupe = new OnlineUpdateException(
ERR_READING_CONFIG_LDAP.get(t.toString()), t);
- exceptions.add(ex);
+ ex.add(oupe);
}
+ for (OpenDsException oe : ex)
+ {
+ LOG.log(Level.WARNING, "Error reading configuration: "+oe, oe);
+ }
+ exceptions = Collections.unmodifiableList(ex);
+ administrativeUsers = Collections.unmodifiableSet(as);
+ listeners = Collections.unmodifiableSet(ls);
+ backends = Collections.unmodifiableSet(bs);
}
- private void updateMonitorInformation(InitialLdapContext ctx)
+ private void updateMonitorInformation(InitialLdapContext ctx,
+ Set<BackendDescriptor> bs,
+ List<OpenDsException> ex)
{
// Read monitoring information: since it is computed, it is faster
// to get everything in just one request.
@@ -391,7 +404,7 @@
if ((dn != null) && (replicaId != null))
{
- for (BackendDescriptor backend : backends)
+ for (BackendDescriptor backend : bs)
{
for (BaseDNDescriptor baseDN : backend.getBaseDns())
{
@@ -430,7 +443,7 @@
if ((backendID != null) && ((entryCount != null) ||
(baseDnEntries != null)))
{
- for (BackendDescriptor backend : backends)
+ for (BackendDescriptor backend : bs)
{
if (backend.getBackendID().equalsIgnoreCase(backendID))
{
@@ -475,15 +488,9 @@
}
catch (NamingException ne)
{
- OnlineUpdateException ex = new OnlineUpdateException(
+ OnlineUpdateException oue = new OnlineUpdateException(
ERR_READING_CONFIG_LDAP.get(ne.getMessage().toString()), ne);
- exceptions.add(ex);
- }
-
-
- for (OpenDsException oe : exceptions)
- {
- LOG.log(Level.WARNING, "Error reading configuration: "+oe, oe);
+ ex.add(oue);
}
}
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromFile.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromFile.java
index 9bedbcf..d97afaa 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromFile.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromFile.java
@@ -30,8 +30,11 @@
import static org.opends.messages.AdminToolMessages.*;
import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.logging.Level;
@@ -98,15 +101,17 @@
*/
public void readConfiguration()
{
- exceptions.clear();
-
+ List<OpenDsException> ex = new ArrayList<OpenDsException>();
+ Set<ConnectionHandlerDescriptor> ls =
+ new HashSet<ConnectionHandlerDescriptor>();
+ Set<BackendDescriptor> bs = new HashSet<BackendDescriptor>();
+ Set<DN> as = new HashSet<DN>();
try
{
DirectoryServer.getInstance().initializeConfiguration();
// Get the Directory Server configuration handler and use it.ad
RootCfg root =
ServerManagementContext.getInstance().getRootConfiguration();
- listeners.clear();
try
{
AdministrationConnectorCfg adminConnector =
@@ -115,7 +120,7 @@
}
catch (ConfigException ce)
{
- exceptions.add(ce);
+ ex.add(ce);
}
String[] connectionHandlers = root.listConnectionHandlers();
for (int i=0; i<connectionHandlers.length; i++)
@@ -124,17 +129,16 @@
{
ConnectionHandlerCfg connectionHandler =
root.getConnectionHandler(connectionHandlers[i]);
- listeners.add(getConnectionHandler(connectionHandler,
+ ls.add(getConnectionHandler(connectionHandler,
connectionHandlers[i]));
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
}
isSchemaEnabled = root.getGlobalConfiguration().isCheckSchema();
- backends.clear();
String[] backendNames = root.listBackends();
for (int i=0; i<backendNames.length; i++)
{
@@ -170,7 +174,7 @@
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
indexes.add(new IndexDescriptor("dn2id", null, null,
new TreeSet<IndexType>(), -1));
@@ -195,7 +199,7 @@
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
}
else if (backend instanceof LDIFBackendCfg)
@@ -234,11 +238,11 @@
index.setBackend(desc);
}
- backends.add(desc);
+ bs.add(desc);
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
}
@@ -250,7 +254,7 @@
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
@@ -287,7 +291,7 @@
protocol,
ConnectionHandlerDescriptor.State.ENABLED,
"Multimaster Synchronization");
- listeners.add(connHandler);
+ ls.add(connHandler);
}
}
String[] domains = sync.listReplicationDomains();
@@ -298,7 +302,7 @@
ReplicationDomainCfg domain =
sync.getReplicationDomain(domains[i]);
DN dn = domain.getBaseDN();
- for (BackendDescriptor backend : backends)
+ for (BackendDescriptor backend : bs)
{
for (BaseDNDescriptor baseDN : backend.getBaseDns())
{
@@ -313,7 +317,7 @@
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
}
@@ -322,19 +326,19 @@
{
RootDNCfg rootDN = root.getRootDN();
String[] rootUsers = rootDN.listRootDNUsers();
- administrativeUsers.clear();
+ as.clear();
if (rootUsers != null)
{
for (int i=0; i < rootUsers.length; i++)
{
RootDNUserCfg rootUser = rootDN.getRootDNUser(rootUsers[i]);
- administrativeUsers.addAll(rootUser.getAlternateBindDN());
+ as.addAll(rootUser.getAlternateBindDN());
}
}
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
try
@@ -343,33 +347,37 @@
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
}
catch (OpenDsException oe)
{
- exceptions.add(oe);
+ ex.add(oe);
}
catch (final Throwable t)
{
LOG.log(Level.WARNING, "Error reading configuration: "+t, t);
- OfflineUpdateException ex = new OfflineUpdateException(
+ OfflineUpdateException oue = new OfflineUpdateException(
ERR_READING_CONFIG_LDAP.get(t.getMessage().toString()), t);
- exceptions.add(ex);
+ ex.add(oue);
}
- if (exceptions.size() > 0)
+ if (ex.size() > 0)
{
if (environmentSettingException != null)
{
- exceptions.add(0, environmentSettingException);
+ ex.add(0, environmentSettingException);
}
}
- for (OpenDsException oe : exceptions)
+ for (OpenDsException oe : ex)
{
LOG.log(Level.WARNING, "Error reading configuration: "+oe, oe);
}
+ exceptions = Collections.unmodifiableList(ex);
+ administrativeUsers = Collections.unmodifiableSet(as);
+ listeners = Collections.unmodifiableSet(ls);
+ backends = Collections.unmodifiableSet(bs);
}
private ConnectionHandlerDescriptor getConnectionHandler(
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigReader.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigReader.java
index 341a480..f50a8ac 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigReader.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigReader.java
@@ -32,7 +32,6 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -102,8 +101,7 @@
/**
* The exceptions that occurred reading the configuration.
*/
- protected ArrayList<OpenDsException> exceptions =
- new ArrayList<OpenDsException>();
+ protected List<OpenDsException> exceptions = Collections.emptyList();
/**
* Whether the configuration has already been read or not.
@@ -113,8 +111,7 @@
/**
* The set of connection listeners.
*/
- protected HashSet<ConnectionHandlerDescriptor> listeners =
- new HashSet<ConnectionHandlerDescriptor>();
+ protected Set<ConnectionHandlerDescriptor> listeners = Collections.emptySet();
/**
* The administration connector.
@@ -124,13 +121,12 @@
/**
* The set of backend descriptors.
*/
- protected HashSet<BackendDescriptor> backends =
- new HashSet<BackendDescriptor>();
+ protected Set<BackendDescriptor> backends = Collections.emptySet();
/**
* The set of administrative users.
*/
- protected HashSet<DN> administrativeUsers = new HashSet<DN>();
+ protected Set<DN> administrativeUsers = Collections.emptySet();
/**
* The replication serve port (-1 if the replication server port is not
@@ -159,30 +155,33 @@
protected Schema schema;
/**
- * Returns the Administrative User DNs found in the config.ldif.
+ * Returns the Administrative User DNs found in the config.ldif. The set
+ * must be unmodifiable (the inheriting classes must take care of this).
* @return the Administrative User DNs found in the config.ldif.
*/
public Set<DN> getAdministrativeUsers()
{
- return Collections.unmodifiableSet(administrativeUsers);
+ return administrativeUsers;
}
/**
- * Returns the backend descriptors found in the config.ldif.
+ * Returns the backend descriptors found in the config.ldif. The set
+ * must be unmodifiable (the inheriting classes must take care of this).
* @return the backend descriptors found in the config.ldif.
*/
public Set<BackendDescriptor> getBackends()
{
- return Collections.unmodifiableSet(backends);
+ return backends;
}
/**
- * Returns the listener descriptors found in the config.ldif.
+ * Returns the listener descriptors found in the config.ldif. The set
+ * must be unmodifiable (the inheriting classes must take care of this).
* @return the listeners descriptors found in the config.ldif.
*/
public Set<ConnectionHandlerDescriptor> getConnectionHandlers()
{
- return Collections.unmodifiableSet(listeners);
+ return listeners;
}
/**
@@ -196,13 +195,14 @@
/**
* Returns the list of exceptions that were encountered reading the
- * configuration.
+ * configuration. The list must be unmodifiable (the inheriting classes must
+ * take care of this).
* @return the list of exceptions that were encountered reading the
* configuration.
*/
public List<OpenDsException> getExceptions()
{
- return Collections.unmodifiableList(exceptions);
+ return exceptions;
}
/**
--
Gitblit v1.10.0