[jboss-cvs] JBossAS SVN: r87756 - in projects/bootstrap/trunk: impl-base/src/main/java/org/jboss/bootstrap/impl/base/config and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Apr 24 00:35:59 EDT 2009
Author: ALRubinger
Date: 2009-04-24 00:35:59 -0400 (Fri, 24 Apr 2009)
New Revision: 87756
Modified:
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java
projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicServerConfig.java
Log:
[JBBOOT-31] Thread safety for AS Config and related improvements for Abstract Base config
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java 2009-04-24 04:22:08 UTC (rev 87755)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java 2009-04-24 04:35:59 UTC (rev 87756)
@@ -34,7 +34,9 @@
/**
* BasicJBossASServerConfig
*
- * Basic object-backed implementation of the {@link JBossASServerConfig}
+ * Basic object-backed implementation of the {@link JBossASServerConfig}.
+ * As this is exported from the Server, this implementation
+ * is Thread-safe.
*
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
@@ -55,67 +57,91 @@
//-------------------------------------------------------------------------------||
/**
- * Bind address for the server
+ * Bind address for the server. Synchronized on
+ * "this".
*/
private String bindAddress;
/**
* $JBOSS_HOME, root of the AS installation
+ * Synchronized on "this". Must
+ * not be exported (so copy on return).
*/
private URL jbossHome;
/**
- * The server configuration name
+ * The server configuration name. Synchronized on
+ * "this".
*/
private String serverName;
/**
* The AS Boot Library Location
+ * Synchronized on "this". Must
+ * not be exported (so copy on return).
*/
private URL bootLibraryLocation;
/**
- * The Location frmo which server homes, by default, decend
+ * The Location from which server homes, by default, decend
+ * Synchronized on "this". Must
+ * not be exported (so copy on return).
*/
private URL serverBaseLocation;
/**
* The location of the server home
+ * Synchronized on "this". Must
+ * not be exported (so copy on return).
*/
private URL serverHomeLocation;
/**
* The location of the common base
+ * Synchronized on "this". Must
+ * not be exported (so copy on return).
*/
private URL commonBaseLocation;
/**
* The location of the common lib
+ * Synchronized on "this". Must
+ * not be exported (so copy on return).
*/
private URL commonLibLocation;
/**
* Location in which the server logs reside
+ * Synchronized on "this". Must
+ * not be exported (so copy on return).
*/
private URL serverLogLocation;
/**
* Location in which the server configuration resides
+ * Synchronized on "this". Must
+ * not be exported (so copy on return).
*/
- private URL serverConfigLocation;
+ private URL serverConfLocation;
/**
* Location in which the server libraries reside
+ * Synchronized on "this". Must
+ * not be exported (so copy on return).
*/
private URL serverLibLocation;
/**
* Location in which the server persistent data resides
+ * Synchronized on "this". Must
+ * not be exported (so copy on return).
*/
private URL serverDataLocation;
/**
* Location in which the server temp data resides
+ * Synchronized on "this". Must
+ * not be exported (so copy on return).
*/
private URL serverTempLocation;
@@ -135,7 +161,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#bindAddress(java.lang.String)
*/
- public JBossASServerConfig bindAddress(final String bindAddress) throws IllegalArgumentException
+ public synchronized JBossASServerConfig bindAddress(final String bindAddress) throws IllegalArgumentException
{
// Set
this.bindAddress = bindAddress;
@@ -150,7 +176,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getBindAddress()
*/
- public String getBindAddress()
+ public synchronized String getBindAddress()
{
return this.bindAddress;
}
@@ -158,7 +184,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getServerName()
*/
- public String getServerName()
+ public synchronized String getServerName()
{
return this.serverName;
}
@@ -193,7 +219,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#jbossHome(java.net.URL)
*/
- public JBossASServerConfig jbossHome(final URL jbossHome)
+ public synchronized JBossASServerConfig jbossHome(final URL jbossHome)
{
// Set
this.jbossHome = jbossHome;
@@ -209,7 +235,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverName(java.lang.String)
*/
- public JBossASServerConfig serverName(final String serverName)
+ public synchronized JBossASServerConfig serverName(final String serverName)
{
// Set
this.serverName = serverName;
@@ -226,7 +252,12 @@
*/
public URL getJBossHome()
{
- return this.jbossHome;
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.jbossHome;
+ }
+ return this.copyURL(url);
}
/* (non-Javadoc)
@@ -259,7 +290,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#bootLibraryLocation(java.net.URL)
*/
- public JBossASServerConfig bootLibraryLocation(final URL bootLibraryLocation)
+ public synchronized JBossASServerConfig bootLibraryLocation(final URL bootLibraryLocation)
{
// Set
this.bootLibraryLocation = bootLibraryLocation;
@@ -276,7 +307,12 @@
*/
public URL getBootLibraryLocation()
{
- return this.bootLibraryLocation;
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.bootLibraryLocation;
+ }
+ return this.copyURL(url);
}
/* (non-Javadoc)
@@ -284,7 +320,12 @@
*/
public URL getServerBaseLocation()
{
- return this.serverBaseLocation;
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.serverBaseLocation;
+ }
+ return this.copyURL(url);
}
/* (non-Javadoc)
@@ -317,7 +358,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverBaseLocation(java.net.URL)
*/
- public JBossASServerConfig serverBaseLocation(final URL serverBaseLocation)
+ public synchronized JBossASServerConfig serverBaseLocation(final URL serverBaseLocation)
{
// Set
this.serverBaseLocation = serverBaseLocation;
@@ -335,7 +376,12 @@
*/
public URL getServerHomeLocation()
{
- return this.serverHomeLocation;
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.serverHomeLocation;
+ }
+ return this.copyURL(url);
}
/* (non-Javadoc)
@@ -368,7 +414,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverHomeLocation(java.net.URL)
*/
- public JBossASServerConfig serverHomeLocation(final URL serverHomeLocation)
+ public synchronized JBossASServerConfig serverHomeLocation(final URL serverHomeLocation)
{
// Set
this.serverHomeLocation = serverHomeLocation;
@@ -411,7 +457,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#commonBaseLocation(java.net.URL)
*/
- public JBossASServerConfig commonBaseLocation(final URL commonBaseLocation)
+ public synchronized JBossASServerConfig commonBaseLocation(final URL commonBaseLocation)
{
// Set
this.commonBaseLocation = commonBaseLocation;
@@ -428,13 +474,18 @@
*/
public URL getCommonBaseLocation()
{
- return this.commonBaseLocation;
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.commonBaseLocation;
+ }
+ return this.copyURL(url);
}
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#commonLibLocation(java.lang.String)
*/
- public JBossASServerConfig commonLibLocation(String commonLibLocation) throws IllegalArgumentException
+ public JBossASServerConfig commonLibLocation(final String commonLibLocation) throws IllegalArgumentException
{
// If null, just pass along
if (commonLibLocation == null)
@@ -461,7 +512,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#commonLibLocation(java.net.URL)
*/
- public JBossASServerConfig commonLibLocation(URL commonLibLocation)
+ public synchronized JBossASServerConfig commonLibLocation(final URL commonLibLocation)
{
// Set
this.commonLibLocation = commonLibLocation;
@@ -478,7 +529,12 @@
*/
public URL getCommonLibLocation()
{
- return this.commonLibLocation;
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.commonLibLocation;
+ }
+ return this.copyURL(url);
}
/* (non-Javadoc)
@@ -486,7 +542,12 @@
*/
public URL getServerLogLocation()
{
- return this.serverLogLocation;
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.serverLogLocation;
+ }
+ return this.copyURL(url);
}
/* (non-Javadoc)
@@ -519,7 +580,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverLogLocation(java.net.URL)
*/
- public JBossASServerConfig serverLogLocation(final URL serverLogLocation)
+ public synchronized JBossASServerConfig serverLogLocation(final URL serverLogLocation)
{
// Set
this.serverLogLocation = serverLogLocation;
@@ -553,7 +614,12 @@
*/
public URL getServerConfLocation()
{
- return this.serverConfigLocation;
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.serverConfLocation;
+ }
+ return this.copyURL(url);
}
/* (non-Javadoc)
@@ -586,10 +652,10 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverConfigLocation(java.net.URL)
*/
- public JBossASServerConfig serverConfLocation(final URL serverConfigLocation)
+ public synchronized JBossASServerConfig serverConfLocation(final URL serverConfigLocation)
{
// Set
- this.serverConfigLocation = serverConfigLocation;
+ this.serverConfLocation = serverConfigLocation;
// Set properties
this.setPropertyForUrl(PROP_KEY_JBOSSAS_SERVER_CONF_URL, serverConfigLocation);
@@ -603,13 +669,18 @@
*/
public URL getServerLibLocation()
{
- return this.serverLibLocation;
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.serverLibLocation;
+ }
+ return this.copyURL(url);
}
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverLibLocation(java.lang.String)
*/
- public JBossASServerConfig serverLibLocation(String serverLibLocation) throws IllegalArgumentException
+ public JBossASServerConfig serverLibLocation(final String serverLibLocation) throws IllegalArgumentException
{
// If null, just pass along
if (serverLibLocation == null)
@@ -636,7 +707,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverLibLocation(java.net.URL)
*/
- public JBossASServerConfig serverLibLocation(URL serverLibLocation)
+ public synchronized JBossASServerConfig serverLibLocation(final URL serverLibLocation)
{
// Set
this.serverLibLocation = serverLibLocation;
@@ -653,13 +724,18 @@
*/
public URL getServerDataLocation()
{
- return this.serverDataLocation;
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.serverDataLocation;
+ }
+ return this.copyURL(url);
}
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverDataLocation(java.lang.String)
*/
- public JBossASServerConfig serverDataLocation(String serverDataLocation) throws IllegalArgumentException
+ public JBossASServerConfig serverDataLocation(final String serverDataLocation) throws IllegalArgumentException
{
// If null, just pass along
if (serverDataLocation == null)
@@ -686,7 +762,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverDataLocation(java.net.URL)
*/
- public JBossASServerConfig serverDataLocation(URL serverDataLocation)
+ public synchronized JBossASServerConfig serverDataLocation(final URL serverDataLocation)
{
// Set
this.serverDataLocation = serverDataLocation;
@@ -720,13 +796,18 @@
*/
public URL getServerTempLocation()
{
- return this.serverTempLocation;
+ URL url = null;
+ synchronized (this)
+ {
+ url = this.serverTempLocation;
+ }
+ return this.copyURL(url);
}
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverTempLocation(java.lang.String)
*/
- public JBossASServerConfig serverTempLocation(String serverTempLocation) throws IllegalArgumentException
+ public JBossASServerConfig serverTempLocation(final String serverTempLocation) throws IllegalArgumentException
{
// If null, just pass along
if (serverTempLocation == null)
@@ -753,7 +834,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverTempLocation(java.net.URL)
*/
- public JBossASServerConfig serverTempLocation(URL serverTempLocation)
+ public synchronized JBossASServerConfig serverTempLocation(final URL serverTempLocation)
{
// Set
this.serverTempLocation = serverTempLocation;
Modified: projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicServerConfig.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicServerConfig.java 2009-04-24 04:22:08 UTC (rev 87755)
+++ projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/config/AbstractBasicServerConfig.java 2009-04-24 04:35:59 UTC (rev 87756)
@@ -30,12 +30,10 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicBoolean;
import org.jboss.bootstrap.spi.config.ServerConfig;
import org.jboss.logging.Logger;
-
/**
* BasicServerConfig
*
@@ -63,9 +61,9 @@
/**
* Actual class used in casting for covarient return in
- * method chaining. Synchronized on "this".
+ * method chaining.
*/
- private Class<T> actualClass;
+ private volatile Class<T> actualClass;
/**
* URL of the bootstrap to run. Synchronized on
@@ -90,8 +88,7 @@
private URL bootstrapHome;
/**
- * Name of the bootstrap file. Synchronized on
- * "this".
+ * Name of the bootstrap file. Synchronized on "this".
*/
private String bootstrapName;
@@ -104,7 +101,7 @@
/**
* Whether or not this configuration is frozen
*/
- private AtomicBoolean frozen;
+ private volatile boolean frozen;
//-------------------------------------------------------------------------------------||
// Constructor ------------------------------------------------------------------------||
@@ -158,11 +155,8 @@
* Set properties
*/
this.properties = properties;
- synchronized (this)
- {
- this.actualClass = actualClass;
- }
- this.frozen = new AtomicBoolean(false);
+ this.actualClass = actualClass;
+ this.frozen = false;
}
//-------------------------------------------------------------------------------------||
@@ -322,7 +316,7 @@
*/
public void freeze() throws IllegalStateException
{
- this.frozen.set(true);
+ this.frozen = true;
}
/* (non-Javadoc)
@@ -330,7 +324,7 @@
*/
public boolean isFrozen()
{
- return this.frozen.get();
+ return this.frozen;
}
/* (non-Javadoc)
More information about the jboss-cvs-commits
mailing list