m.c.m.proxyma.context
Class ProxymaContext

java.lang.Object
  extended by m.c.m.proxyma.context.ProxymaContext

public class ProxymaContext
extends java.lang.Object

This class is the main context for an instance of Proxyma. Multiple instance of proxyma are allowed to run into a single VM. It countains the logic to access and get parameters form a required configuration logFile.

NOTE: this software is released under GPL License. See the LICENSE of this distribution for more informations.

Version:
$Id: ProxymaContext.java 170 2010-07-02 21:16:10Z marcolinuz $
Author:
Marco Casavecchia Morganti (marcolinuz) [marcolinuz-at-gmail.com]

Constructor Summary
ProxymaContext(java.lang.String contextName, java.lang.String contextBaseURI, java.lang.String configurationFile, java.lang.String logsDirectoryPath)
          Default constructor for this Class
 
Method Summary
 void addProxyFolder(ProxyFolderBean proxyFolder)
          Add a new ProxyFolder to the context.
 java.lang.String getDefaultEncoding()
          Get the default encoding charset used to encode/decode URLs and to parse html files.
 java.util.logging.Logger getLogger()
          Get the logger for this context instance.
 java.lang.String getLogLevel()
          Standard getter method to obtain the current log level.
 java.lang.String getLogsDirectoryPath()
          Returns the path of the logs directory for this context.
 java.util.Collection<java.lang.String> getMultiValueParameter(java.lang.String parameterXPath)
          Get a list of values for a parameter from the configuration
 java.lang.String getName()
          Get the name of this ccontext
 java.util.Collection<ProxyFolderBean> getProxyFolderByDestinationHost(java.lang.String proxyFolderDestinationHost)
          Get a proxy folder by folder name (if exists)
 ProxyFolderBean getProxyFolderByURLEncodedName(java.lang.String proxyFolderURLEncodedName)
          Get a proxy folder by folder name (if exists)
 java.util.Collection<ProxyFolderBean> getProxyFoldersAsCollection()
          Get a collection of all the proxy folders into the context
 int getProxyFoldersCount()
          Returns the number of proxy folders handled by the context.
 java.lang.String getProxymaContextBasePath()
          Get the contextPath for this context
 java.lang.String getProxymaVersion()
          Get the curren relese nubler of Proxyma-core library
 java.lang.String getSingleValueParameter(java.lang.String parameterXPath)
          Get a single value paramenter from the configuration
 void removeProxyFolder(ProxyFolderBean proxyFolder)
          Remove a ProxyFolder from the context
 java.lang.String setLogLevel(java.lang.String logLevel)
          Standard setter method to set the new log level to use at run time.
protected  void updateFolderDestinationIndex(java.net.URL oldDestination, ProxyFolderBean theFolder)
          Updates Context Destination Indexes.
protected  void updateFolderURLEncodedIndex(java.lang.String oldURLEncodedName, ProxyFolderBean theFolder)
          Updates Context URLEncoded Indexes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProxymaContext

public ProxymaContext(java.lang.String contextName,
                      java.lang.String contextBaseURI,
                      java.lang.String configurationFile,
                      java.lang.String logsDirectoryPath)
Default constructor for this Class

Parameters:
contextName - the name of the context to create
contextBaseURI - Base URI of the context
configurationFile - proxyma configuration file to load
logsDirectoryPath - directory where to write all the logs
Method Detail

getProxyFolderByURLEncodedName

public ProxyFolderBean getProxyFolderByURLEncodedName(java.lang.String proxyFolderURLEncodedName)
Get a proxy folder by folder name (if exists)

Parameters:
proxyFolderURLEncodedName - the wanted ProxyFolderBean
Returns:
null if the proxyFolder doesn't exists.

getProxyFolderByDestinationHost

public java.util.Collection<ProxyFolderBean> getProxyFolderByDestinationHost(java.lang.String proxyFolderDestinationHost)
Get a proxy folder by folder name (if exists)

Parameters:
proxyFolderURLEncodedName - the wanted ProxyFolderBean
Returns:
null if the proxyFolder doesn't exists.

addProxyFolder

public void addProxyFolder(ProxyFolderBean proxyFolder)
                    throws java.lang.IllegalArgumentException,
                           org.apache.commons.lang.NullArgumentException
Add a new ProxyFolder to the context.

Parameters:
proxyFolder - the ProxyFolderBean to add
Throws:
java.lang.IllegalArgumentException - if the context is already registered
org.apache.commons.lang.NullArgumentException - if the argument is null

removeProxyFolder

public void removeProxyFolder(ProxyFolderBean proxyFolder)
                       throws java.lang.IllegalArgumentException,
                              org.apache.commons.lang.NullArgumentException
Remove a ProxyFolder from the context

Parameters:
proxyFolder - the proxyFolder to remove.
Throws:
java.lang.IllegalArgumentException - if the context doesn't exist
org.apache.commons.lang.NullArgumentException - if the argument is null

updateFolderURLEncodedIndex

protected void updateFolderURLEncodedIndex(java.lang.String oldURLEncodedName,
                                           ProxyFolderBean theFolder)
Updates Context URLEncoded Indexes.
This method is invoked from a proxy folder that has changed its name in order to update the internal index of the registered proxy folders.

Parameters:
theFolder - the folder that has jus been updated

updateFolderDestinationIndex

protected void updateFolderDestinationIndex(java.net.URL oldDestination,
                                            ProxyFolderBean theFolder)
Updates Context Destination Indexes.
This method is invoked from a proxy folder that has changed its destination in order to keep aligned the internal index of the registered proxy folders.

Parameters:
theFolder - the folder that has jus been updated

getProxyFoldersAsCollection

public java.util.Collection<ProxyFolderBean> getProxyFoldersAsCollection()
Get a collection of all the proxy folders into the context

Returns:
a Collection of ProxyFolders

getProxyFoldersCount

public int getProxyFoldersCount()
Returns the number of proxy folders handled by the context.

Returns:
the number of proxy folders into the context.

getSingleValueParameter

public java.lang.String getSingleValueParameter(java.lang.String parameterXPath)
Get a single value paramenter from the configuration

Parameters:
parameterName - the parameter name
Returns:
the parameter value
See Also:
ParameterTags

getMultiValueParameter

public java.util.Collection<java.lang.String> getMultiValueParameter(java.lang.String parameterXPath)
Get a list of values for a parameter from the configuration

Parameters:
parameterName - the parameter name
Returns:
the parameter value
Throws:
java.lang.IllegalArgumentException - if the parameter is not a single value parameter.
See Also:
ParameterTags

getLogLevel

public java.lang.String getLogLevel()
Standard getter method to obtain the current log level.

Returns:
the log level as defined into the java standard Logger. Possible values are: SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL

setLogLevel

public java.lang.String setLogLevel(java.lang.String logLevel)
Standard setter method to set the new log level to use at run time.

Parameters:
the - new log level as defined into the java standard Logger. Possible values are: SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL

getLogger

public java.util.logging.Logger getLogger()
Get the logger for this context instance. This function provides a simple way to allow any plugin to attach its own logs to the proxyma main log logFile.

Returns:
the context logger

getName

public java.lang.String getName()
Get the name of this ccontext

Returns:
the context name as String

getDefaultEncoding

public java.lang.String getDefaultEncoding()
Get the default encoding charset used to encode/decode URLs and to parse html files.

Returns:
the default encoding

getProxymaVersion

public java.lang.String getProxymaVersion()
Get the curren relese nubler of Proxyma-core library

Returns:
the default encoding

getProxymaContextBasePath

public java.lang.String getProxymaContextBasePath()
Get the contextPath for this context

Returns:
the contextURI as String

getLogsDirectoryPath

public java.lang.String getLogsDirectoryPath()
Returns the path of the logs directory for this context.

Returns:
the directory of the logs.


Copyright © 2010. All Rights Reserved.