mx4j.tools.adaptor.http

Class HttpAdaptor

public class HttpAdaptor extends Object implements HttpAdaptorMBean, 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(int port)
Overloaded constructor to allow the port to be set.
HttpAdaptor(String host)
Overloaded constructor to allow the host to be set.
HttpAdaptor(int port, String host)
Overloaded constructor to allow the port to be set.
Method Summary
voidaddAuthorization(String username, String password)
Adds an authorization pair as username/password
voidaddCommandProcessor(String path, HttpCommandProcessor processor)
Adds a command processor object
voidaddCommandProcessor(String path, String processorClass)
Adds a command processor object by class
protected voidbuildCommands()
Build the commands
protected voidfindUnknownElement(String path, HttpOutputStream out, HttpInputStream in)
StringgetAuthenticationMethod()
Authentication Method
StringgetHost()
Return the host name the server will be listening to.
intgetPort()
Returns the port where the server is running on.
ProcessorMBeangetProcessor()
protected HttpCommandProcessorgetProcessor(String path)
ObjectNamegetProcessorName()
longgetRequestsCount()
Requests count
DategetStartDate()
Starting date
StringgetVersion()
Gets the HttpAdaptor version
booleanisActive()
Indicates whether the server's running
voidpostDeregister()
protected voidpostProcess(HttpOutputStream out, HttpInputStream in, Document document)
protected voidpostProcess(HttpOutputStream out, HttpInputStream in, Exception e)
voidpostRegister(Boolean registrationDone)
voidpreDeregister()
protected StringpreProcess(String path)
ObjectNamepreRegister(MBeanServer server, ObjectName name)
Gathers some basic data
voidremoveCommandProcessor(String path)
Removes a command processor object by class
voidrestart()
Restarts the server.
voidsetAuthenticationMethod(String method)
Sets the Authentication Method.
voidsetHost(String host)
Sets the host name where the server will be listening
voidsetPort(int port)
Sets the value of the server's port
voidsetProcessor(ProcessorMBean processor)
Sets the object which will post process the XML results.
voidsetProcessorClass(String processorClass)
Sets the classname of the object which will post process the XML results.
voidsetProcessorName(ObjectName processorName)
Sets the object name which will post process the XML result.
voidsetProcessorNameString(String processorName)
Sets the object name of the PostProcessor MBean.
voidsetSocketFactory(AdaptorServerSocketFactory factory)
Sets the object which create the server sockets
voidsetSocketFactoryName(ObjectName factoryName)
Sets the factory's object name which will create the server sockets
voidsetSocketFactoryNameString(String factoryName)
Sets the factory's object name which will create the server sockets
voidstart()
Starts the server
voidstop()
Stops the HTTP daemon

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

addAuthorization

public void addAuthorization(String username, String password)
Adds an authorization pair as username/password

addCommandProcessor

public void addCommandProcessor(String path, HttpCommandProcessor processor)
Adds a command processor object

addCommandProcessor

public void addCommandProcessor(String path, String processorClass)
Adds a command processor object by class

buildCommands

protected void buildCommands()
Build the commands

findUnknownElement

protected void findUnknownElement(String path, HttpOutputStream out, HttpInputStream in)

getAuthenticationMethod

public String getAuthenticationMethod()
Authentication Method

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

Returns: the current hostname

getPort

public int getPort()
Returns the port where the server is running on. Default is 8080

Returns: HTTPServer's port

getProcessor

public ProcessorMBean getProcessor()

getProcessor

protected HttpCommandProcessor getProcessor(String path)

getProcessorName

public ObjectName getProcessorName()

getRequestsCount

public long getRequestsCount()
Requests count

Returns: The total of requests served so far

getStartDate

public Date getStartDate()
Starting date

Returns: The date when the server was started

getVersion

public String getVersion()
Gets the HttpAdaptor version

Returns: HttpAdaptor's version

isActive

public boolean isActive()
Indicates whether the server's running

Returns: The active value

postDeregister

public void postDeregister()

postProcess

protected void postProcess(HttpOutputStream out, HttpInputStream in, Document document)

postProcess

protected void postProcess(HttpOutputStream out, HttpInputStream in, Exception e)

postRegister

public void postRegister(Boolean registrationDone)

preDeregister

public void preDeregister()

preProcess

protected String preProcess(String path)

preRegister

public ObjectName preRegister(MBeanServer server, ObjectName name)
Gathers some basic data

removeCommandProcessor

public void removeCommandProcessor(String path)
Removes a command processor object by class

restart

public void restart()

Deprecated: as of RC 1

Restarts the server. Useful when changing the Server parameters

setAuthenticationMethod

public void setAuthenticationMethod(String method)
Sets the Authentication Method.

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

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

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

Parameters: processorClass a Post processor object

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

Parameters: processorName The new processorName value

setProcessorNameString

public void setProcessorNameString(String processorName)
Sets the object name of the PostProcessor MBean. If ProcessorClass is set the processor will be created

Parameters: processorName a Post processor object

setSocketFactory

public void setSocketFactory(AdaptorServerSocketFactory factory)
Sets the object which create the server sockets

Parameters: factory the socket factory

setSocketFactoryName

public void setSocketFactoryName(ObjectName factoryName)
Sets the factory's object name which will create the server sockets

Parameters: factoryName the socket factory

setSocketFactoryNameString

public void setSocketFactoryNameString(String factoryName)
Sets the factory's object name which will create the server sockets

Parameters: factoryName the socket factory

start

public void start()
Starts the server

stop

public void stop()
Stops the HTTP daemon
Copyright © 2001-2005 The MX4J Contributors. All Rights Reserved.