org.jboss.varia.property
Class SystemPropertiesService

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.varia.property.SystemPropertiesService
All Implemented Interfaces:
MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Service (src) , ServiceMBean (src)

public class SystemPropertiesService
extends ServiceMBeanSupport (src)

A service to access system properties.


Nested Class Summary
protected static class SystemPropertiesService.HTMLMap (src)
          A helper to render a map as HTML on toString()
 
Field Summary
protected  java.lang.String serverHome
          The server's home dir as a string (for making urls).
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
SystemPropertiesService()
           
 
Method Summary
 void addListener(PropertyListener (src)  listener)
          Add a property listener.
 void addListener(java.lang.String typename)
          Construct and add a property listener.
 void addListeners(PropertyListener (src) [] listeners)
          Add an array of property listeners.
 boolean exists(java.lang.String name)
          Check if a system property of the given name exists.
 java.lang.String get(java.lang.String name)
          Get a system property.
 java.lang.String get(java.lang.String name, java.lang.String defaultValue)
          Get a system property.
 java.util.List getArray(java.lang.String name)
          Get an array style system property.
 java.util.List getArray(java.lang.String base, java.util.List defaultValues)
          Get an array style system property.
 PropertyGroup (src) getGroup(java.lang.String basename)
          Get a property group for under the given system property base.
 PropertyGroup (src) getGroup(java.lang.String basename, int index)
          Get a property group for under the given system property base at the given index.
 void load(java.lang.String url)
          Load some system properties from the given URL.
 void load(java.net.URL url)
          Load some system properties from the given URL.
 ObjectName (src) preRegister(MBeanServer (src)  server, ObjectName (src)  name)
          Setup our reference to the server's home directory.
 java.lang.String remove(java.lang.String name)
          Remove a system property.
 boolean removeListener(PropertyListener (src)  listener)
          Remove a property listener.
 java.lang.String set(java.lang.String name, java.lang.String value)
          Set a system property.
 void setProperties(java.util.Properties props)
          Set system properties by merging the given properties object.
 void setURLList(java.lang.String list)
          Load system properties for each of the given comma separated urls.
 java.util.Map showAll()
          Return a Map of System.getProperties() with a toString implementation that provides an html table of the key/value pairs.
 java.util.Map showGroup(java.lang.String basename)
          Return a Map of the property group for under the given system property base with a toString implementation that provides an html table of the key/value pairs.
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, createService, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, start, startService, stop, stopService
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport (src)
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serverHome

protected java.lang.String serverHome
The server's home dir as a string (for making urls).

Constructor Detail

SystemPropertiesService

public SystemPropertiesService()
Method Detail

set

public java.lang.String set(java.lang.String name,
                            java.lang.String value)
Set a system property.

Parameters:
name - The name of the property to set.
value - The value of the property.
Returns:
Previous property value or null

get

public java.lang.String get(java.lang.String name,
                            java.lang.String defaultValue)
Get a system property.

Parameters:
name - Property name
defaultValue - Default property value
Returns:
Property value or default

get

public java.lang.String get(java.lang.String name)
Get a system property.

Parameters:
name - Property name
Returns:
Property value or null

remove

public java.lang.String remove(java.lang.String name)
Remove a system property.

Parameters:
name - The name of the property to remove.
Returns:
Removed property value or null

getArray

public java.util.List getArray(java.lang.String base,
                               java.util.List defaultValues)
Get an array style system property.

Parameters:
base - Base property name
defaultValues - Default property values
Returns:
ArrayList of property values or default

getArray

public java.util.List getArray(java.lang.String name)
Get an array style system property.

Parameters:
name - Property name
Returns:
ArrayList of property values or empty array

exists

public boolean exists(java.lang.String name)
Check if a system property of the given name exists.

Parameters:
name - Property name
Returns:
True if property exists

getGroup

public PropertyGroup (src)  getGroup(java.lang.String basename)
Get a property group for under the given system property base.

Parameters:
basename - Base property name
Returns:
Property group

getGroup

public PropertyGroup (src)  getGroup(java.lang.String basename,
                              int index)
Get a property group for under the given system property base at the given index.

Parameters:
basename - Base property name
index - Array property index
Returns:
Property group

addListener

public void addListener(PropertyListener (src)  listener)
Add a property listener.

Parameters:
listener - Property listener to add

addListeners

public void addListeners(PropertyListener (src) [] listeners)
Add an array of property listeners.

Parameters:
listeners - Array of property listeners to add

removeListener

public boolean removeListener(PropertyListener (src)  listener)
Remove a property listener.

Parameters:
listener - Property listener to remove
Returns:
True if listener was removed

load

public void load(java.net.URL url)
          throws java.io.IOException
Load some system properties from the given URL.

Parameters:
url - The url to load properties from.
Throws:
java.io.IOException

load

public void load(java.lang.String url)
          throws java.io.IOException,
                 java.net.MalformedURLException
Load some system properties from the given URL.

Parameters:
url - The url to load properties from.
Throws:
java.io.IOException
java.net.MalformedURLException

addListener

public void addListener(java.lang.String typename)
                 throws java.lang.ClassNotFoundException,
                        java.lang.IllegalAccessException,
                        java.lang.InstantiationException
Construct and add a property listener.

Throws:
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException

setURLList

public void setURLList(java.lang.String list)
                throws java.net.MalformedURLException,
                       java.io.IOException
Load system properties for each of the given comma separated urls.

Parameters:
list - A list of comma separated urls.
Throws:
java.net.MalformedURLException
java.io.IOException

setProperties

public void setProperties(java.util.Properties props)
                   throws java.io.IOException
Set system properties by merging the given properties object. This will replace valid references to properties of the form ${x} in 'props' or a System property with the value of x.

Parameters:
props - Properties object to merge.
Throws:
java.io.IOException

showAll

public java.util.Map showAll()
Return a Map of System.getProperties() with a toString implementation that provides an html table of the key/value pairs.


showGroup

public java.util.Map showGroup(java.lang.String basename)
Return a Map of the property group for under the given system property base with a toString implementation that provides an html table of the key/value pairs.

Parameters:
basename - Base property name
Returns:
Property group

preRegister

public ObjectName (src)  preRegister(MBeanServer (src)  server,
                              ObjectName (src)  name)
                       throws java.lang.Exception
Setup our reference to the server's home directory. This is done here because one or more attribute setters makes use of this value.

Specified by:
preRegister in interface MBeanRegistration (src)
Overrides:
preRegister in class ServiceMBeanSupport (src)
Parameters:
server - Reference to the JMX Agent this MBean is registered on
name - Name specified by the creator of the MBean. Note that you can overwrite it when the given ObjectName is null otherwise the change is discarded (maybe a bug in JMX-RI).
Throws:
java.lang.Exception