mx4j.adaptor.http
Class HttpAdaptor

java.lang.Object
  |
  +--mx4j.adaptor.http.HttpAdaptor
All Implemented Interfaces:
HttpAdaptorMBean, MBeanRegistration

public class HttpAdaptor
extends java.lang.Object
implements HttpAdaptorMBean, MBeanRegistration

HttpAdaptor sets the basic adaptor listening for HTTP requests

Version:
$Revision: 1.3 $
Author:
Carlos Quiroz

Constructor Summary
HttpAdaptor()
           
 
Method Summary
 void addAuthorization(java.lang.String username, java.lang.String password)
          Adds an authorization
protected  void buildCommands()
          Build the commands
protected  void findUnknownElement(java.lang.String path, mx4j.adaptor.http.HttpOutputStream out, mx4j.adaptor.http.HttpInputStream in)
           
 java.lang.String getAuthenticationMethod()
          Authentication Method
 java.lang.String getHost()
          Return the host name the server will be listening to.
 int getPort()
          Returns the port where the server is running on.
 ProcessorMBean getProcessor()
          Returns the object being used as a processor
protected  mx4j.adaptor.http.HttpCommandProcessor getProcessor(java.lang.String path)
          Gets a processor for a given path
 ObjectName getProcessorName()
          Returns the ObjectName of the processor being used
 boolean isActive()
          Indicates whether the server's running
 void postDeregister()
           
protected  void postProcess(mx4j.adaptor.http.HttpOutputStream out, mx4j.adaptor.http.HttpInputStream in, org.w3c.dom.Document document)
           
protected  void postProcess(mx4j.adaptor.http.HttpOutputStream out, mx4j.adaptor.http.HttpInputStream in, java.lang.Exception e)
           
 void postRegister(java.lang.Boolean registrationDone)
           
 void preDeregister()
           
protected  java.lang.String preProcess(java.lang.String path)
           
 ObjectName preRegister(MBeanServer server, ObjectName name)
          Gathers some basic data
 void restart()
          Deprecated. as of RC 1
 void setAuthenticationMethod(java.lang.String method)
          Sets the Authentication Method.
 void setHost(java.lang.String host)
          Sets the host name where the server will be listening
 void setPort(int port)
          Sets the value of the server's port
 void setProcessor(ProcessorMBean processor)
          Sets the object which will post process the XML results.
 void setProcessorName(ObjectName processorName)
          Sets the object name which will post process the XML result.
 void setSocketFactory(AdaptorServerSocketFactory factory)
          Sets the object which create the server sockets
 void setSocketFactoryName(java.lang.String factoryName)
          Sets the ObjectName of the factory for server sockets
 void start()
          Starts the server
 void stop()
          Stops the HTTP daemon
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpAdaptor

public HttpAdaptor()
Method Detail

setPort

public void setPort(int port)
Sets the value of the server's port
Specified by:
setPort in interface HttpAdaptorMBean
Parameters:
port - the new port's value

setHost

public void setHost(java.lang.String host)
Sets the host name where the server will be listening
Specified by:
setHost in interface HttpAdaptorMBean
Parameters:
host - Server's host

getAuthenticationMethod

public java.lang.String getAuthenticationMethod()
Authentication Method
Specified by:
getAuthenticationMethod in interface HttpAdaptorMBean
Returns:
authentication method

setAuthenticationMethod

public void setAuthenticationMethod(java.lang.String method)
Sets the Authentication Method.
Specified by:
setAuthenticationMethod in interface HttpAdaptorMBean
Parameters:
method - none/basic/digest

setProcessor

public void setProcessor(ProcessorMBean processor)
Sets the object which will post process the XML results. The last value set between the setPostProcessor and setPostProcessorName will be the valid one
Specified by:
setProcessor in interface HttpAdaptorMBean
Parameters:
processor - a Post processor object

setSocketFactory

public void setSocketFactory(AdaptorServerSocketFactory factory)
Sets the object which create the server sockets
Specified by:
setSocketFactory in interface HttpAdaptorMBean
Parameters:
factory - the socket factory

setSocketFactoryName

public void setSocketFactoryName(java.lang.String factoryName)
Description copied from interface: HttpAdaptorMBean
Sets the ObjectName of the factory for server sockets
Specified by:
setSocketFactoryName in interface HttpAdaptorMBean
Following copied from interface: mx4j.adaptor.http.HttpAdaptorMBean
Parameters:
factoryName - the ObjectName of the ServerSocket factory

setProcessorName

public void setProcessorName(ObjectName processorName)
Sets the object name which will post process the XML result. The last value set between the setPostProcessor and setPostProcessorName will be the valid one. The MBean will be verified to be of instance HttpPostProcessor
Specified by:
setProcessorName in interface HttpAdaptorMBean
Parameters:
processorName - The new processorName value

getProcessor

public ProcessorMBean getProcessor()
Description copied from interface: HttpAdaptorMBean
Returns the object being used as a processor
Specified by:
getProcessor in interface HttpAdaptorMBean
Following copied from interface: mx4j.adaptor.http.HttpAdaptorMBean
Returns:
the processor object

getProcessorName

public ObjectName getProcessorName()
Description copied from interface: HttpAdaptorMBean
Returns the ObjectName of the processor being used
Specified by:
getProcessorName in interface HttpAdaptorMBean
Following copied from interface: mx4j.adaptor.http.HttpAdaptorMBean
Returns:
processor objectname

getPort

public int getPort()
Returns the port where the server is running on. Default is 8080
Specified by:
getPort in interface HttpAdaptorMBean
Returns:
HTTPServer's port

getHost

public java.lang.String getHost()
Return the host name the server will be listening to. If null the server listen at the localhost
Specified by:
getHost in interface HttpAdaptorMBean
Returns:
the current hostname

isActive

public boolean isActive()
Indicates whether the server's running
Specified by:
isActive in interface HttpAdaptorMBean
Returns:
The active value

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws java.lang.Exception
Gathers some basic data
Specified by:
preRegister in interface MBeanRegistration

postRegister

public void postRegister(java.lang.Boolean registrationDone)
Specified by:
postRegister in interface MBeanRegistration

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Specified by:
preDeregister in interface MBeanRegistration

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface MBeanRegistration

start

public void start()
           throws java.io.IOException
Starts the server
Specified by:
start in interface HttpAdaptorMBean

restart

public void restart()
             throws java.io.IOException
Deprecated. as of RC 1

Restarts the server. Useful when changing the Server parameters
Specified by:
restart in interface HttpAdaptorMBean

stop

public void stop()
Stops the HTTP daemon
Specified by:
stop in interface HttpAdaptorMBean

addAuthorization

public void addAuthorization(java.lang.String username,
                             java.lang.String password)
Description copied from interface: HttpAdaptorMBean
Adds an authorization
Specified by:
addAuthorization in interface HttpAdaptorMBean
Following copied from interface: mx4j.adaptor.http.HttpAdaptorMBean
Parameters:
username - authorized username
username - authorized password

getProcessor

protected mx4j.adaptor.http.HttpCommandProcessor getProcessor(java.lang.String path)
Gets a processor for a given path

buildCommands

protected void buildCommands()
Build the commands

postProcess

protected void postProcess(mx4j.adaptor.http.HttpOutputStream out,
                           mx4j.adaptor.http.HttpInputStream in,
                           org.w3c.dom.Document document)
                    throws java.io.IOException,
                           JMException

findUnknownElement

protected void findUnknownElement(java.lang.String path,
                                  mx4j.adaptor.http.HttpOutputStream out,
                                  mx4j.adaptor.http.HttpInputStream in)
                           throws java.io.IOException,
                                  JMException

preProcess

protected java.lang.String preProcess(java.lang.String path)
                               throws java.io.IOException,
                                      JMException

postProcess

protected void postProcess(mx4j.adaptor.http.HttpOutputStream out,
                           mx4j.adaptor.http.HttpInputStream in,
                           java.lang.Exception e)
                    throws java.io.IOException,
                           JMException