org.norther.tammi.core.startup
Class MBeanStartup

java.lang.Object
  extended by org.norther.tammi.core.base.MBeanBroker
      extended by org.norther.tammi.core.config.MBeanConfig
          extended by org.norther.tammi.core.startup.MBeanStartup
All Implemented Interfaces:
Serializable

public class MBeanStartup
extends MBeanConfig

Extends MBean config by providing startup configuration support for scripts.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.core.base.MBeanBroker
MBEAN_BROKER
 
Constructor Summary
MBeanStartup()
          Constructs a new config.
MBeanStartup(MBeanServer server)
          Constructs a new config for a specific server.
 
Method Summary
 void addProperty(int index, String key, String value)
          Inserts a multivalued property at the specified index.
 void addProperty(String key, String value)
          Adds a multivalued property.
 void clearProperties()
          Clears all properties.
 boolean containsProperty(String key)
          Checks whether a property is defined.
 Configuration getConfiguration()
          Gets the startup configuration.
 Configuration getConfiguration(String prefix)
          Gets the prefixed startup configuration.
 String[] getProperties(String key)
          Gets a multivalued property.
 String getProperty(String key)
          Gets a property.
 String getPropertyFilePath()
          Gets the property file path.
protected  Startup getStartup()
          Gets the startup.
 int indexOfProperty(String key, String value)
          Returns the index of a multivalued property value.
 Object removeProperty(String key)
          Removes a property.
 boolean removeProperty(String key, String value)
          Removes a multivalued property.
 Object setProperties(String key, String[] values)
          Sets a multivalued property.
 Object setProperty(String key, String value)
          Sets a property.
 void setPropertyFilePath(String path)
          Sets the property file path.
 void setPropertyFilePath(String path, String encoding)
          Sets the property file path with encoding.
 void storeProperties()
          Stores properties to the property file.
 
Methods inherited from class org.norther.tammi.core.config.MBeanConfig
configure, configure, configure, configure, convert, convert, copy, copy, getConfigurator, setConverter, setConverter
 
Methods inherited from class org.norther.tammi.core.base.MBeanBroker
adapt, adapt, adapt, adapt, adapt, adapt, adapt, adapt, adapt, adapt, adapt, create, create, create, create, create, create, create, create, create, find, find, find, find, findName, findName, findName, findName, findNames, findNames, findNames, findNames, findNames, findNames, get, get, get, get, getAllDomains, getBroker, getClassName, getClassName, getDefaultDomain, getDomain, getDomainName, getDomainNames, getFactory, getInfo, getInfo, getLoader, getLog, getMBeanServer, getPackage, getPackages, getSystemProperty, instantiate, instantiate, instantiate, invoke, invoke, invoke, invoke, invoke, invoke, isDefined, isInstanceOf, isInstanceOf, isRegistered, isRegistered, load, register, register, register, register, set, set, set, set, set, set, setAlias, setAlias, setFactory, setFactory, setMBeanServer, setSystemProperty, toObjectName, toPackageName, unregister, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MBeanStartup

public MBeanStartup()
Constructs a new config.


MBeanStartup

public MBeanStartup(MBeanServer server)
Constructs a new config for a specific server. Note that MBean server cannot be serialized.

Parameters:
server - the MBean server.
Method Detail

getPropertyFilePath

public String getPropertyFilePath()
Gets the property file path.

Returns:
the property file path.

setPropertyFilePath

public void setPropertyFilePath(String path)
Sets the property file path. The path may be an absolute file path, a file path relative to the specified config key folder or a URL. The properties will be loaded before the next get/set property operation.

Parameters:
path - a property file path.

setPropertyFilePath

public void setPropertyFilePath(String path,
                                String encoding)
Sets the property file path with encoding. The path may be an absolute file path, a file path relative to the specified config key folder or a URL. The properties will be loaded before the next get/set property operation.

Parameters:
path - a property file path.
encoding - the encoding to use.

containsProperty

public boolean containsProperty(String key)
Checks whether a property is defined.

Parameters:
key - the key.
Returns:
true for a defined property, false otherwise.

getProperty

public String getProperty(String key)
Gets a property.

Parameters:
key - the key.
Returns:
the value or null.

setProperty

public Object setProperty(String key,
                          String value)
Sets a property.

Parameters:
key - the key.
value - the value.
Returns:
the previous value.

getProperties

public String[] getProperties(String key)
Gets a multivalued property.

Parameters:
key - the key.
Returns:
the values or null.

setProperties

public Object setProperties(String key,
                            String[] values)
Sets a multivalued property.

Parameters:
key - the key.
values - the values.
Returns:
the previous value.

removeProperty

public Object removeProperty(String key)
Removes a property.

Parameters:
key - the key.
Returns:
the removed value or null.

indexOfProperty

public int indexOfProperty(String key,
                           String value)
Returns the index of a multivalued property value.

Parameters:
key - the key.
value - the value.
Returns:
the index of the value or -1.

addProperty

public void addProperty(String key,
                        String value)
Adds a multivalued property.

Parameters:
key - the key.
value - the property.

addProperty

public void addProperty(int index,
                        String key,
                        String value)
Inserts a multivalued property at the specified index.

Parameters:
index - the index.
key - the key.
value - the value.

removeProperty

public boolean removeProperty(String key,
                              String value)
Removes a multivalued property.

Parameters:
key - the key.
value - the value.
Returns:
true if removed, false otherwise.

clearProperties

public void clearProperties()
Clears all properties.


storeProperties

public void storeProperties()
                     throws IOException
Stores properties to the property file.

Throws:
IOException - on I/O errors.

getConfiguration

public Configuration getConfiguration()
Gets the startup configuration. Multivalued properties are presented as string arrays.

Returns:
the startup configuration.

getConfiguration

public Configuration getConfiguration(String prefix)
Gets the prefixed startup configuration. The prefix is removed from the keys of the returned configuration. Multivalued properties are presented as string arrays.

Parameters:
prefix - the prefix.
Returns:
the startup configuration.

getStartup

protected Startup getStartup()
Gets the startup.

Returns:
the resolved startup.
Throws:
IllegalStateException - if not available.


Copyright © 2004 The Norther Organization. All rights reserved.