mx4j.tools.adaptor.http

Class HttpAdaptor

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.13 $

Constructor Summary

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

Method Summary

void
addAuthorization(String username, String password)
Adds an authorization pair as username/password
void
addCommandProcessor(String path, String processorClass)
Adds a command processor object by class
void
addCommandProcessor(String path, HttpCommandProcessor processor)
Adds a command processor object
protected void
buildCommands()
Build the commands
protected void
findUnknownElement(String path, HttpOutputStream out, HttpInputStream in)
String
getAuthenticationMethod()
Authentication Method
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()
protected HttpCommandProcessor
getProcessor(String path)
javax.management.ObjectName
getProcessorName()
long
getRequestsCount()
Requests count
Date
getStartDate()
Starting date
String
getVersion()
Gets the HttpAdaptor version
boolean
isActive()
Indicates whether the server's running
void
postDeregister()
protected void
postProcess(HttpOutputStream out, HttpInputStream in, Document document)
protected void
postProcess(HttpOutputStream out, HttpInputStream in, Exception e)
void
postRegister(Boolean registrationDone)
void
preDeregister()
protected String
preProcess(String path)
javax.management.ObjectName
preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)
Gathers some basic data
void
removeCommandProcessor(String path)
Removes a command processor object by class
void
restart()
Deprecated. as of RC 1
void
setAuthenticationMethod(String method)
Sets the Authentication Method.
void
setHost(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(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(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(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

Constructor Details

HttpAdaptor

public HttpAdaptor()
Default Constructor added so that we can have some additional constructors as well.

HttpAdaptor

public HttpAdaptor(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)
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(int port,
                   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 Details

addAuthorization

public void addAuthorization(String username,
                             String password)
Adds an authorization pair as username/password
Specified by:
addAuthorization in interface HttpAdaptorMBean

addCommandProcessor

public void addCommandProcessor(String path,
                                String processorClass)
Adds a command processor object by class
Specified by:
addCommandProcessor in interface HttpAdaptorMBean

addCommandProcessor

public void addCommandProcessor(String path,
                                HttpCommandProcessor processor)
Adds a command processor object
Specified by:
addCommandProcessor in interface HttpAdaptorMBean

buildCommands

protected void buildCommands()
Build the commands

findUnknownElement

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

getAuthenticationMethod

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

getHost

public 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

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

getProcessor

public ProcessorMBean getProcessor()
Specified by:
getProcessor in interface HttpAdaptorMBean

getProcessor

protected HttpCommandProcessor getProcessor(String path)

getProcessorName

public javax.management.ObjectName getProcessorName()
Specified by:
getProcessorName in interface HttpAdaptorMBean

getRequestsCount

public long getRequestsCount()
Requests count
Specified by:
getRequestsCount in interface HttpAdaptorMBean
Returns:
The total of requests served so far

getStartDate

public Date getStartDate()
Starting date
Specified by:
getStartDate in interface HttpAdaptorMBean
Returns:
The date when the server was started

getVersion

public String getVersion()
Gets the HttpAdaptor version
Specified by:
getVersion in interface HttpAdaptorMBean
Returns:
HttpAdaptor's version

isActive

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

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface javax.management.MBeanRegistration

postProcess

protected void postProcess(HttpOutputStream out,
                           HttpInputStream in,
                           Document document)
            throws IOException,
                   javax.management.JMException

postProcess

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

postRegister

public void postRegister(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

preProcess

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

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

removeCommandProcessor

public void removeCommandProcessor(String path)
Removes a command processor object by class
Specified by:
removeCommandProcessor in interface HttpAdaptorMBean

restart

public void restart()
            throws IOException

Deprecated. as of RC 1

Restarts the server. Useful when changing the Server parameters

setAuthenticationMethod

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

setHost

public void setHost(String host)
Sets the host name where the server will be listening
Parameters:
host - Server's host

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

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

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

setProcessorNameString

public void setProcessorNameString(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

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

start

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

stop

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

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