org.objectweb.carol.util.configuration
Class ProtocolConfigurationImpl

java.lang.Object
  extended byorg.objectweb.carol.util.configuration.ProtocolConfigurationImpl
All Implemented Interfaces:
ProtocolConfiguration, ProtocolConfigurationImplMBean

public class ProtocolConfigurationImpl
extends java.lang.Object
implements ProtocolConfiguration, ProtocolConfigurationImplMBean

This class manage a rmi configuration used by carol.
The configuration is based on a protocol which contains required values and non modified values


Constructor Summary
ProtocolConfigurationImpl(java.lang.String name, Protocol protocol, java.util.Properties properties)
          Build a new configuration with given parameters
 
Method Summary
 void configure(java.util.Properties properties)
          Configure this configuration with a given properties object
protected  void extractJNDIProperties()
          Extract JNDI properties of properties
 java.lang.String getHost()
           
protected  java.lang.String getHostOfUrl(java.lang.String url)
          Parses the given url, and returns the hostname If not found, returns localhost
 javax.naming.Context getInitialContext(java.util.Hashtable env)
          Build an initial context with the given environment using our configuration
 java.lang.String getInitialContextFactoryClassName()
          MBean method : Gets the InitialContextFactory classname (Context.INITIAL_CONTEXT_FACTORY)
 java.util.Hashtable getJndiEnv()
           
 java.lang.String getName()
           
 java.util.List getNames()
          Gets JNDI names of the context with this configuration
 java.lang.String getobjectName()
           
 int getPort()
           
protected  int getPortOfUrl(java.lang.String url)
          Parses the given url, and returns the port number.
 java.util.Properties getProperties()
           
 Protocol getProtocol()
           
 java.lang.String getProviderURL()
          Gets the provider URL of this configuration (Context.PROVIDER_URL)
protected  java.lang.String getValue(java.lang.String key)
          Gets value of properties object
 boolean iseventProvider()
           
 boolean isstateManageable()
           
 boolean isstatisticsProvider()
           
protected  void parseURL()
          Parse URL to extract host and port
 void setobjectName(java.lang.String name)
          Sets the object name of this mbean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProtocolConfigurationImpl

public ProtocolConfigurationImpl(java.lang.String name,
                                 Protocol protocol,
                                 java.util.Properties properties)
                          throws ConfigurationException
Build a new configuration with given parameters

Parameters:
name - the name of this protocol configuration
protocol - the protocol object used by this configuration
properties - for this object
Throws:
ConfigurationException - if configuration is not correct
Method Detail

configure

public void configure(java.util.Properties properties)
               throws ConfigurationException
Configure this configuration with a given properties object

Specified by:
configure in interface ProtocolConfiguration
Parameters:
properties - given properties
Throws:
ConfigurationException - if the given config is invalid

extractJNDIProperties

protected void extractJNDIProperties()
                              throws ConfigurationException
Extract JNDI properties of properties

Throws:
ConfigurationException - if properties are missing

parseURL

protected void parseURL()
                 throws ConfigurationException
Parse URL to extract host and port

Throws:
ConfigurationException - if URL is not correct

getInitialContext

public javax.naming.Context getInitialContext(java.util.Hashtable env)
                                       throws javax.naming.NamingException
Build an initial context with the given environment using our configuration

Specified by:
getInitialContext in interface ProtocolConfiguration
Parameters:
env - parameters for the initial context
Returns:
an InitialContext
Throws:
javax.naming.NamingException - if the context is not created

getProtocol

public Protocol getProtocol()
Specified by:
getProtocol in interface ProtocolConfiguration
Returns:
the protocol used by this configuration.

getName

public java.lang.String getName()
Specified by:
getName in interface ProtocolConfiguration
Returns:
the name of this configuration

getProperties

public java.util.Properties getProperties()
Specified by:
getProperties in interface ProtocolConfiguration
Returns:
a copy of the properties of this configuration

getHost

public java.lang.String getHost()
Specified by:
getHost in interface ProtocolConfiguration
Returns:
the host.

getPort

public int getPort()
Specified by:
getPort in interface ProtocolConfiguration
Returns:
the port for this protocol name service

getProviderURL

public java.lang.String getProviderURL()
Description copied from interface: ProtocolConfigurationImplMBean
Gets the provider URL of this configuration (Context.PROVIDER_URL)

Specified by:
getProviderURL in interface ProtocolConfiguration
Returns:
the Provider URL attribute

getPortOfUrl

protected int getPortOfUrl(java.lang.String url)
                    throws ConfigurationException
Parses the given url, and returns the port number. 0 is given in error case)

Parameters:
url - given url on which extract port number
Returns:
port number of the url
Throws:
ConfigurationException - if URL is invalid

getHostOfUrl

protected java.lang.String getHostOfUrl(java.lang.String url)
                                 throws ConfigurationException
Parses the given url, and returns the hostname If not found, returns localhost

Parameters:
url - given url on which extract hostname
Returns:
hostname of the url
Throws:
ConfigurationException - if URL is invalid

getValue

protected java.lang.String getValue(java.lang.String key)
                             throws ConfigurationException
Gets value of properties object

Parameters:
key - the key of the properties
Returns:
value stored in a property object
Throws:
ConfigurationException - if properties are missing

getJndiEnv

public java.util.Hashtable getJndiEnv()
Returns:
the jndiEnv (used for InitialContext).

getInitialContextFactoryClassName

public java.lang.String getInitialContextFactoryClassName()
MBean method : Gets the InitialContextFactory classname (Context.INITIAL_CONTEXT_FACTORY)

Specified by:
getInitialContextFactoryClassName in interface ProtocolConfigurationImplMBean
Returns:
the InitialContextFactory classname

getNames

public java.util.List getNames()
                        throws javax.naming.NamingException
Gets JNDI names of the context with this configuration

Specified by:
getNames in interface ProtocolConfigurationImplMBean
Returns:
JNDI names
Throws:
javax.naming.NamingException - if the names cannot be listed

getobjectName

public java.lang.String getobjectName()
Specified by:
getobjectName in interface ProtocolConfigurationImplMBean
Returns:
Object Name

setobjectName

public void setobjectName(java.lang.String name)
Sets the object name of this mbean

Specified by:
setobjectName in interface ProtocolConfigurationImplMBean
Parameters:
name - the Object Name

iseventProvider

public boolean iseventProvider()
Specified by:
iseventProvider in interface ProtocolConfigurationImplMBean
Returns:
true if it is an event provider

isstateManageable

public boolean isstateManageable()
Specified by:
isstateManageable in interface ProtocolConfigurationImplMBean
Returns:
true if this managed object implements J2EE State Management Model

isstatisticsProvider

public boolean isstatisticsProvider()
Specified by:
isstatisticsProvider in interface ProtocolConfigurationImplMBean
Returns:
true if this managed object implements the J2EE StatisticProvider Model