## mx4j.tools.adaptor.http
Class HttpAdaptor

    java.lang.Object
      mx4j.tools.adaptor.http.HttpAdaptor

All Implemented Interfaces:
  HttpAdaptorMBean, javax.management.MBeanRegistration

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

HttpAdaptor sets the basic adaptor listening for HTTP requests

Version:
  $Revision: 1.14 $

Constructor Summary
`HttpAdaptor()` Default Constructor added so that we can have some additional constructors as well.
`HttpAdaptor(int port)` Overloaded constructor to allow the port to be set.
`HttpAdaptor(int port, java.lang.String host)` Overloaded constructor to allow the port to be set.
`HttpAdaptor(java.lang.String host)` Overloaded constructor to allow the host to be set.

Method Summary
`void` `addAuthorization(java.lang.String username, java.lang.String password)` Adds an authorization pair as username/password
`void` `addCommandProcessor(java.lang.String path, HttpCommandProcessor processor)` Adds a command processor object
`void` `addCommandProcessor(java.lang.String path, java.lang.String processorClass)` Adds a command processor object by class
`protected void` `buildCommands()` Build the commands
`protected void` `findUnknownElement(java.lang.String path, HttpOutputStream out, 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 Processor set by `setProcessor(mx4j.tools.adaptor.http.ProcessorMBean)`
`protected HttpCommandProcessor` `getProcessor(java.lang.String path)`
`javax.management.ObjectName` `getProcessorName()` Returns the ObjectName of the processor set by `setProcessorName(javax.management.ObjectName)`
`long` `getRequestsCount()` Requests count
`java.util.Date` `getStartDate()` Starting date
`java.lang.String` `getVersion()` Gets the HttpAdaptor version
`boolean` `isActive()` Indicates whether the server's running
`void` `postDeregister()`
`protected void` `postProcess(HttpOutputStream out, HttpInputStream in, org.w3c.dom.Document document)`
`protected void` `postProcess(HttpOutputStream out, HttpInputStream in, java.lang.Exception e)`
`void` `postRegister(java.lang.Boolean registrationDone)`
`void` `preDeregister()`
`protected java.lang.String` `preProcess(java.lang.String path)`
`javax.management.ObjectName` `preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)` Gathers some basic data
`void` `removeCommandProcessor(java.lang.String path)` Removes a command processor object by class
`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` `setProcessorClass(java.lang.String processorClass)` Sets the classname of the object which will post process the XML results.
`void` `setProcessorName(javax.management.ObjectName processorName)` Sets the object name which will post process the XML result.
`void` `setProcessorNameString(java.lang.String processorName)` Sets the object name of the PostProcessor MBean.
`void` `setSocketFactory(AdaptorServerSocketFactory factory)` Sets the object which create the server sockets
`void` `setSocketFactoryName(javax.management.ObjectName factoryName)` Sets the factory's object name which will create the server sockets
`void` `setSocketFactoryNameString(java.lang.String factoryName)` Sets the factory's object name which will create the 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()

  Default Constructor added so that we can have some additional constructors as well.

### HttpAdaptor

    public HttpAdaptor(int port)

  Overloaded constructor to allow the port to be set. The reason this was added was to allow the loading of this adaptor by the dynamic loading service of the MBean server and have the port set from a param in the mlet file. Example: (replaced lt & gt symbol with [])
  [mlet code="mx4j.tools.adaptor.http.HttpAdaptor"
  archive="mx4j.jar"
  name="Server:name=HttpAdaptor"]
  [arg type="int" value="12345"]
  [/mlet]

  This constructor uses the default host or the host must be set later.

Parameters:
  `port` - The port on which the HttpAdaptor should listen

### HttpAdaptor

    public HttpAdaptor(java.lang.String host)

  Overloaded constructor to allow the host to be set. The reason this was added was to allow the loading of this adaptor by the dynamic loading service of the MBean server and have the host set from a param in the mlet file. Example: (replaced lt & gt symbol with [])
  [mlet code="mx4j.tools.adaptor.http.HttpAdaptor"
  archive="mx4j.jar"
  name="Server:name=HttpAdaptor"]
  [arg type="java.lang.String" value="someserver.somehost.com"]
  [/mlet]

  This constructor uses the default port or the port must be set later.

Parameters:
  `host` - The host on which the HttpAdaptor should listen

### HttpAdaptor

    public HttpAdaptor(int port,
                       java.lang.String host)

  Overloaded constructor to allow the port to be set. The reason this was added was to allow the loading of this adaptor by the dynamic loading service of the MBean server and have the port set from a param in the mlet file. Example: (replaced lt & gt symbol with []) NOTE that the port must come before the host in the arg list of the mlet
  [mlet code="mx4j.tools.adaptor.http.HttpAdaptor"
  archive="mx4j.jar"
  name="Server:name=HttpAdaptor"]
  [arg type="int" value="12345"]
  [arg type="java.lang.String" value="someserver.somehost.com"]
  [/mlet]

Parameters:
  `port` - The port on which the HttpAdaptor should listen
  `host` - The host on which the HttpAdaptor should listen

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

### 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

### 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

### 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

### setAuthenticationMethod

    public void setAuthenticationMethod(java.lang.String method)

  Sets the Authentication Method.

  Specified by:
    `setAuthenticationMethod` in interface `HttpAdaptorMBean`
  Parameters:
    `method` - none/basic/digest

### getAuthenticationMethod

    public java.lang.String getAuthenticationMethod()

  Authentication Method

  Specified by:
    `getAuthenticationMethod` in interface `HttpAdaptorMBean`
  Returns:
    authentication method

### 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

### setProcessorClass

    public void setProcessorClass(java.lang.String processorClass)

  Sets the classname of the object which will post process the XML results. The adaptor will try to build the object and use the processor name ObjectName to register it The class name has to implements mx4j.tools.adaptor.http.ProcessorMBean and be MBean compliant

  Specified by:
    `setProcessorClass` in interface `HttpAdaptorMBean`
  Parameters:
    `processorClass` - a Post processor object

### setProcessorNameString

    public void setProcessorNameString(java.lang.String processorName)
                                throws javax.management.MalformedObjectNameException

  Sets the object name of the PostProcessor MBean. If ProcessorClass is set the processor will be created

  Specified by:
    `setProcessorNameString` in interface `HttpAdaptorMBean`
  Parameters:
    `processorName` - a Post processor object
  Throws:
    `javax.management.MalformedObjectNameException`

### setProcessorName

    public void setProcessorName(javax.management.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 Processor set by `HttpAdaptorMBean.setProcessor(mx4j.tools.adaptor.http.ProcessorMBean)`

  Specified by:
    `getProcessor` in interface `HttpAdaptorMBean`

### getProcessorName

    public javax.management.ObjectName getProcessorName()

  Description copied from interface: `HttpAdaptorMBean`
  Returns the ObjectName of the processor set by `HttpAdaptorMBean.setProcessorName(javax.management.ObjectName)`

  Specified by:
    `getProcessorName` in interface `HttpAdaptorMBean`

### 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(javax.management.ObjectName factoryName)

  Sets the factory's object name which will create the server sockets

  Specified by:
    `setSocketFactoryName` in interface `HttpAdaptorMBean`
  Parameters:
    `factoryName` - the socket factory

### setSocketFactoryNameString

    public void setSocketFactoryNameString(java.lang.String factoryName)
                                    throws javax.management.MalformedObjectNameException

  Sets the factory's object name which will create the server sockets

  Specified by:
    `setSocketFactoryNameString` in interface `HttpAdaptorMBean`
  Parameters:
    `factoryName` - the socket factory
  Throws:
    `javax.management.MalformedObjectNameException`

### isActive

    public boolean isActive()

  Indicates whether the server's running

  Specified by:
    `isActive` in interface `HttpAdaptorMBean`
  Returns:
    The active value

### getStartDate

    public java.util.Date getStartDate()

  Starting date

  Specified by:
    `getStartDate` in interface `HttpAdaptorMBean`
  Returns:
    The date when the server was started

### getRequestsCount

    public long getRequestsCount()

  Requests count

  Specified by:
    `getRequestsCount` in interface `HttpAdaptorMBean`
  Returns:
    The total of requests served so far

### getVersion

    public java.lang.String getVersion()

  Gets the HttpAdaptor version

  Specified by:
    `getVersion` in interface `HttpAdaptorMBean`
  Returns:
    HttpAdaptor's version

### addCommandProcessor

    public void addCommandProcessor(java.lang.String path,
                                    HttpCommandProcessor processor)

  Adds a command processor object

  Specified by:
    `addCommandProcessor` in interface `HttpAdaptorMBean`

### addCommandProcessor

    public void addCommandProcessor(java.lang.String path,
                                    java.lang.String processorClass)

  Adds a command processor object by class

  Specified by:
    `addCommandProcessor` in interface `HttpAdaptorMBean`

### removeCommandProcessor

    public void removeCommandProcessor(java.lang.String path)

  Removes a command processor object by class

  Specified by:
    `removeCommandProcessor` in interface `HttpAdaptorMBean`

### start

    public void start()
               throws java.io.IOException

  Starts the server

  Specified by:
    `start` in interface `HttpAdaptorMBean`
  Throws:
    `java.io.IOException`

### restart

    public void restart()
                 throws java.io.IOException

  Deprecated. as of RC 1

  Restarts the server. Useful when changing the Server parameters

  Throws:
    `java.io.IOException`

### 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)

  Adds an authorization pair as username/password

  Specified by:
    `addAuthorization` in interface `HttpAdaptorMBean`

### preRegister

    public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
                                                   javax.management.ObjectName name)
                                            throws java.lang.Exception

  Gathers some basic data

  Specified by:
    `preRegister` in interface `javax.management.MBeanRegistration`
  Throws:
    `java.lang.Exception`

### postRegister

    public void postRegister(java.lang.Boolean registrationDone)

  Specified by:
    `postRegister` in interface `javax.management.MBeanRegistration`

### preDeregister

    public void preDeregister()
                       throws java.lang.Exception

  Specified by:
    `preDeregister` in interface `javax.management.MBeanRegistration`
  Throws:
    `java.lang.Exception`

### postDeregister

    public void postDeregister()

  Specified by:
    `postDeregister` in interface `javax.management.MBeanRegistration`

### getProcessor

    protected HttpCommandProcessor getProcessor(java.lang.String path)

### buildCommands

    protected void buildCommands()

  Build the commands

### postProcess

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

  Throws:
    `java.io.IOException`
    `javax.management.JMException`

### findUnknownElement

    protected void findUnknownElement(java.lang.String path,
                                      HttpOutputStream out,
                                      HttpInputStream in)
                               throws java.io.IOException,
                                      javax.management.JMException

  Throws:
    `java.io.IOException`
    `javax.management.JMException`

### preProcess

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

  Throws:
    `java.io.IOException`
    `javax.management.JMException`

### postProcess

    protected void postProcess(HttpOutputStream out,
                               HttpInputStream in,
                               java.lang.Exception e)
                        throws java.io.IOException,
                               javax.management.JMException

  Throws:
    `java.io.IOException`
    `javax.management.JMException`

Copyright © 2001-2005 The MX4J Contributors. All Rights Reserved.