m.c.m.proxyma
Class ProxymaFacade

java.lang.Object
  extended by m.c.m.proxyma.ProxymaFacade

public class ProxymaFacade
extends java.lang.Object

This class is the main interface (Facade) to intercact with Proxyma.

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

Version:
$Id: ProxymaFacade.java 164 2010-06-29 10:59:58Z marcolinuz $
Author:
Marco Casavecchia Morganti (marcolinuz) [marcolinuz-at-gmail.com]

Constructor Summary
ProxymaFacade()
          the default constructor for this class.
 
Method Summary
 ProxymaContext createNewContext(java.lang.String contextName, java.lang.String contextBaseURI, java.lang.String configFilePath, java.lang.String logsDirectoryPath)
          Register a new Proxyma Context into the Application Environment.
 ProxyEngine createNewProxyEngine(ProxymaContext context)
          This method creates a new instance of the Proxyma Proxy-Engine, the core of this project.
 ProxyFolderBean createNewProxyFolder(java.lang.String FolderName, java.lang.String destination, ProxymaContext context)
          Builds a new default ProxyFolder to the specified destination setting.
 ProxymaResource createNewResource(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ProxymaContext context)
          This method creates a complete instance of ProxymaResource form a servlet request, a servlet response and a proxyma context.
 void destroyContext(ProxymaContext context)
          Remove an existin Proxyma Context form the Application Environment.
 void disableProxyFolder(ProxyFolderBean theFolder)
          Diable the passed proxyFolder
 void enableProxyFolder(ProxyFolderBean theFolder)
          Enable the passed proxyFolder
 ProxymaContext getContextByName(java.lang.String contextName)
          Obtain an existing context using its unique name.
 java.util.Collection<ProxyFolderBean> getContextProxyFolders(ProxymaContext context)
          Returns all the proxyFolders form the passed context.
 ProxyFolderBean getProxyFolderByURLEncodedName(java.lang.String urlEncodedName, ProxymaContext context)
          Get from the passed context an existing proxyFolder searching it by its URL encoded name
 java.util.Enumeration<java.lang.String> getRegisteredContextNames()
          Returns an Enumeration of all the registered context names
 void removeProxyFolder(ProxyFolderBean theFolder, ProxymaContext context)
          Remove from the passed context an existing proxyFolder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProxymaFacade

public ProxymaFacade()
the default constructor for this class.

Method Detail

createNewContext

public ProxymaContext createNewContext(java.lang.String contextName,
                                       java.lang.String contextBaseURI,
                                       java.lang.String configFilePath,
                                       java.lang.String logsDirectoryPath)
                                throws java.lang.IllegalArgumentException
Register a new Proxyma Context into the Application Environment. You need a context to make any operation with proxyma.

Parameters:
contextName - The unique name for the context to create. You will use it from now to operate with the context.
contextBaseURI - The base URI for this context. In other words, the URI to prepend to the "ProxyFolders".
configFilePath - An xml configuration file for the context.
Returns:
a newly generated ProxymaContext
Throws:
java.lang.IllegalArgumentException - if the context already exists
See Also:
ProxymaContext

destroyContext

public void destroyContext(ProxymaContext context)
                    throws org.apache.commons.lang.NullArgumentException,
                           java.lang.IllegalArgumentException,
                           java.lang.IllegalStateException
Remove an existin Proxyma Context form the Application Environment. NOTE: This method requires that the context is empty. In other words, The context is removed only if it doesn't contain any ProxyFolderBean into itself.

Parameters:
the - context to unregister
Throws:
java.lang.IllegalArgumentException - if the doesn't exists
org.apache.commons.lang.NullArgumentException - if a null argument is passed to this method
java.lang.IllegalStateException - if the context is not empty

getContextByName

public ProxymaContext getContextByName(java.lang.String contextName)
Obtain an existing context using its unique name.

Parameters:
contextName - the name of the context to retrive.
Returns:
the requested context (or Null if the context doesn't exists)

getRegisteredContextNames

public java.util.Enumeration<java.lang.String> getRegisteredContextNames()
Returns an Enumeration of all the registered context names

Returns:
the registered context names

createNewProxyFolder

public ProxyFolderBean createNewProxyFolder(java.lang.String FolderName,
                                            java.lang.String destination,
                                            ProxymaContext context)
                                     throws org.apache.commons.lang.NullArgumentException,
                                            java.lang.IllegalArgumentException,
                                            java.io.UnsupportedEncodingException
Builds a new default ProxyFolder to the specified destination setting.
The proxy folder will be disabled and attached to the provided context.

Parameters:
FolderName - the path (and name) of the proxy folder.
destination - the destination URI to masquerade
context - the proxyma context where to take default settings.
Throws:
org.apache.commons.lang.NullArgumentException - if some parameter is null
java.lang.IllegalArgumentException - if the folder name or the destination parameter are invalid or malformed
java.io.UnsupportedEncodingException - if the default encoding charset specified on the configuration is not supported.

getProxyFolderByURLEncodedName

public ProxyFolderBean getProxyFolderByURLEncodedName(java.lang.String urlEncodedName,
                                                      ProxymaContext context)
Get from the passed context an existing proxyFolder searching it by its URL encoded name

Parameters:
FolderName - the folder to retrive
context - the context to inspect
Returns:
the requested ProxyFolderBean (or null if it's not found)

removeProxyFolder

public void removeProxyFolder(ProxyFolderBean theFolder,
                              ProxymaContext context)
                       throws java.lang.IllegalArgumentException,
                              org.apache.commons.lang.NullArgumentException
Remove from the passed context an existing proxyFolder

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

enableProxyFolder

public void enableProxyFolder(ProxyFolderBean theFolder)
                       throws org.apache.commons.lang.NullArgumentException
Enable the passed proxyFolder

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

disableProxyFolder

public void disableProxyFolder(ProxyFolderBean theFolder)
                        throws org.apache.commons.lang.NullArgumentException
Diable the passed proxyFolder

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

getContextProxyFolders

public java.util.Collection<ProxyFolderBean> getContextProxyFolders(ProxymaContext context)
Returns all the proxyFolders form the passed context.

Parameters:
context - the context to inspect for folders
Returns:
a Collection of proxy folders

createNewResource

public ProxymaResource createNewResource(javax.servlet.http.HttpServletRequest request,
                                         javax.servlet.http.HttpServletResponse response,
                                         ProxymaContext context)
                                  throws org.apache.commons.lang.NullArgumentException
This method creates a complete instance of ProxymaResource form a servlet request, a servlet response and a proxyma context. The produced resource can be handled by the reverse proxy engine and by any of its registered plugins.

Parameters:
request - the servlet container request.
response - the servlet container response
context - the proxyma context where the resource will live.
Returns:
an resource that can be directly handled by the ProxyEngine.
Throws:
org.apache.commons.lang.NullArgumentException - if any of the passed parameters is null

createNewProxyEngine

public ProxyEngine createNewProxyEngine(ProxymaContext context)
                                 throws java.lang.IllegalAccessException
This method creates a new instance of the Proxyma Proxy-Engine, the core of this project.

Parameters:
context - the context where the proxy will work
Returns:
a new instance of proxy
Throws:
java.lang.IllegalAccessException - if there are some troubles with the plugins loading.


Copyright © 2010. All Rights Reserved.