com.languagecomputer.server
Class WebServer

java.lang.Object
  extended by com.languagecomputer.server.WebServer

public class WebServer
extends Object

Web services container / driver. Uses the Jetty java application server with the Apache CXF web services framework to expose java classes as SOAP endpoints. Can be started from the command line or embedded into existing code.

Since:
1.0
Author:
Toby Jungen / Kirk Roberts

Field Summary
protected static Boolean loggingInitialized
           
protected  org.mortbay.jetty.Server server
           
protected  org.apache.cxf.transport.servlet.AbstractCXFServlet servlet
           
protected  SessionManager sessionManager
           
 
Constructor Summary
WebServer(int port, File configFile)
          Main constructor.
 
Method Summary
protected  SessionManager getSessionManager()
          Returns the SessionManager in use by this WebServer.
static void main(String[] args)
          Sample driver code.
 void publish(String name, Object service)
          Publishes a web service endpoint for the specified object.
 void start()
          Starts the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loggingInitialized

protected static Boolean loggingInitialized

server

protected org.mortbay.jetty.Server server

servlet

protected org.apache.cxf.transport.servlet.AbstractCXFServlet servlet

sessionManager

protected final SessionManager sessionManager
Constructor Detail

WebServer

public WebServer(int port,
                 File configFile)
Main constructor. Performs all the necessary initialization to prepare the web server for running.

Parameters:
port - The port number on which the server will run.
configFile - Configuration file for the services.
Method Detail

getSessionManager

protected SessionManager getSessionManager()
Returns the SessionManager in use by this WebServer.


publish

public void publish(String name,
                    Object service)
Publishes a web service endpoint for the specified object. This makes the specified object available for interaction via SOAP. Must be called after the server is started.

Parameters:
name - Name under which the endpoint will be published. This will determine the url of the service.
service - Object that is providing the web service interaction. The object should be annotated with WebService.

start

public void start()
Starts the server. Opens the necessary ports starts listening for incoming requests. Will fail if the port is already in use.


main

public static void main(String[] args)
                 throws Exception
Sample driver code. Can be called from command line; sets up a basic server with given services published.

Parameters:
args - Command line arguments. Expects the services config file as the first argument and a list of the services to run as remaining args.
Throws:
Exception - In the case of some sort of system failure.


Copyright © 2009. All Rights Reserved.