org.jboss.bootstrap.impl.base.config
Class AbstractBasicServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

java.lang.Object
  extended by org.jboss.bootstrap.impl.base.config.AbstractBasicServerConfig<T>
All Implemented Interfaces:
org.jboss.bootstrap.spi.config.ServerConfig<T>

public abstract class AbstractBasicServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
extends Object
implements org.jboss.bootstrap.spi.config.ServerConfig<T>

BasicServerConfig Base for simple Object-backed implementations of a Server Configuration. As this is exported from the Server, this is Thread-safe.

Version:
$Revision: $
Author:
ALR

Field Summary
 
Fields inherited from interface org.jboss.bootstrap.spi.config.ServerConfig
PROP_KEY_BOOTSTRAP_HOME_URL, PROP_KEY_BOOTSTRAP_NAME, PROP_KEY_BOOTSTRAP_URL
 
Constructor Summary
AbstractBasicServerConfig(Class<T> actualClass)
          Constructor
AbstractBasicServerConfig(Class<T> actualClass, Map<String,String> overrideProperties)
          Constructor
 
Method Summary
protected  URL adjustToDirectory(URL url)
          If the specified URL denotes a directory (ie.
 T bootstrapHome(String bootstrapHome)
           
 T bootstrapHome(URL bootstrapHome)
           
 T bootstrapName(String name)
           
 T bootstrapUrl(String bootstrapUrl)
           
 T bootstrapUrl(URL bootstrapLocation)
           
protected  void checkMutable()
          Throws IllegalStateException if this configuration is frozen
protected  URL copyURL(URL url)
          Copies and returns the specified URL.
protected  T covarientReturn()
          Casts this configuration to the requisite type, using the actual implementation class.
 void freeze()
           
protected  Class<T> getActualClass()
          Returns the actual types of this configuration, used in covarient return of the mutator methods
 URL getBootstrapHome()
           
 String getBootstrapName()
           
 URL getBootstrapUrl()
           
 Map<String,String> getProperties()
           
 String getProperty(String key)
           
 boolean isFrozen()
           
 T properties(Map<String,String> properties)
           
 T properties(Properties properties)
           
 T property(String key, String value)
           
protected  void setPropertyForString(String propertyName, Boolean value)
          Sets both the configuration property and System property with the specified key and specified value
protected  void setPropertyForString(String propertyName, Integer value)
          Sets both the configuration property and System property with the specified key and specified value
protected  void setPropertyForString(String propertyName, String value)
          Sets both the configuration property and System property with the specified key and specified value
protected  void setPropertyForUrl(String propertyName, URL url)
          Sets both the configuration property and System property with the specified key and the external form of the specified URL
protected  URL urlFromString(String url)
          Constructs a URL from the specified String, throwing IllegalArgumentException to wrap the MalformedURLException if unable to do so.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBasicServerConfig

public AbstractBasicServerConfig(Class<T> actualClass)
Constructor

Parameters:
actualClass - The actual class of this Server Configuration to be used in casting for covarient return types

AbstractBasicServerConfig

public AbstractBasicServerConfig(Class<T> actualClass,
                                 Map<String,String> overrideProperties)
Constructor

Parameters:
actualClass - The actual class of this Server Configuration to be used in casting for covarient return types
overrideProperties - A Map of properties to override those found in System Properties
Method Detail

getBootstrapHome

public URL getBootstrapHome()
Specified by:
getBootstrapHome in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

getBootstrapName

public String getBootstrapName()
Specified by:
getBootstrapName in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

getBootstrapUrl

public URL getBootstrapUrl()
Specified by:
getBootstrapUrl in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

getProperties

public Map<String,String> getProperties()
Specified by:
getProperties in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

getProperty

public String getProperty(String key)
                   throws IllegalArgumentException
Specified by:
getProperty in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException

bootstrapHome

public T bootstrapHome(URL bootstrapHome)
                                                                       throws IllegalArgumentException
Specified by:
bootstrapHome in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException

bootstrapName

public T bootstrapName(String name)
                                                                       throws IllegalArgumentException
Specified by:
bootstrapName in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException

bootstrapUrl

public T bootstrapUrl(URL bootstrapLocation)
                                                                      throws IllegalArgumentException
Specified by:
bootstrapUrl in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException

property

public T property(String key,
                  String value)
                                                                  throws IllegalArgumentException
Specified by:
property in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException

properties

public T properties(Map<String,String> properties)
                                                                    throws IllegalArgumentException,
                                                                           IllegalStateException
Specified by:
properties in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException
IllegalStateException

properties

public T properties(Properties properties)
                                                                    throws IllegalArgumentException,
                                                                           IllegalStateException
Specified by:
properties in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException
IllegalStateException

freeze

public void freeze()
            throws IllegalStateException
Specified by:
freeze in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalStateException

isFrozen

public boolean isFrozen()
Specified by:
isFrozen in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>

bootstrapHome

public T bootstrapHome(String bootstrapHome)
                                                                       throws IllegalArgumentException,
                                                                              IllegalStateException
Specified by:
bootstrapHome in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException
IllegalStateException

bootstrapUrl

public T bootstrapUrl(String bootstrapUrl)
                                                                      throws IllegalArgumentException,
                                                                             IllegalStateException
Specified by:
bootstrapUrl in interface org.jboss.bootstrap.spi.config.ServerConfig<T extends org.jboss.bootstrap.spi.config.ServerConfig<T>>
Throws:
IllegalArgumentException
IllegalStateException

setPropertyForUrl

protected void setPropertyForUrl(String propertyName,
                                 URL url)
Sets both the configuration property and System property with the specified key and the external form of the specified URL


setPropertyForString

protected void setPropertyForString(String propertyName,
                                    String value)
Sets both the configuration property and System property with the specified key and specified value


setPropertyForString

protected void setPropertyForString(String propertyName,
                                    Integer value)
Sets both the configuration property and System property with the specified key and specified value


setPropertyForString

protected void setPropertyForString(String propertyName,
                                    Boolean value)
Sets both the configuration property and System property with the specified key and specified value


checkMutable

protected void checkMutable()
                     throws IllegalStateException
Throws IllegalStateException if this configuration is frozen

Throws:
IllegalStateException

adjustToDirectory

protected URL adjustToDirectory(URL url)
If the specified URL denotes a directory (ie. trailing slash), will return the argument. Nulls are ignored and returned as-is.

Parameters:
url -
Returns:

getActualClass

protected Class<T> getActualClass()
Returns the actual types of this configuration, used in covarient return of the mutator methods

Returns:

covarientReturn

protected final T covarientReturn()
                                                                                  throws ClassCastException
Casts this configuration to the requisite type, using the actual implementation class. This is in place to avoid unchecked casting (ie. (T)this)) and the resultant compiler warnings

Returns:
Throws:
ClassCastException

copyURL

protected final URL copyURL(URL url)
Copies and returns the specified URL. Used to ensure we don't export mutable URLs (thread safety)

Parameters:
url -
Returns:

urlFromString

protected final URL urlFromString(String url)
                           throws IllegalArgumentException
Constructs a URL from the specified String, throwing IllegalArgumentException to wrap the MalformedURLException if unable to do so. Null arguments will be ignored.

Parameters:
url -
Returns:
Throws:
IllegalArgumentException


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.