Phone Modeler
Features ScreenShots Requirements Project Documentation License About
Latest News

22 Aug 2005
Cistera releases version 1.1 of Phone Modeler
02 Feb 2004
Cistera Announces Phone Modeler Open Source

Show all news


Corvero Networks Logo

Get Involved
You can get involved in this project. The project home page is phonemodeler@


Embedding LiteWebServer in PhoneModeler

LWS can be embedded within another Java application. You just need to create an instance of the server bootstrap class and start, restart and stop it as needed. If you've embedded a previous version of LWS, you must modify your code to use the new API since the internals of the server has changed dramatically in 3.0. This is an example of the code you put in your application:

import com.gefionsoftware.lws.startup.Bootstrap;
import java.util.*;
* Description of the Class
* @author greg
* @created February 22, 2004
public class MyApp implements Runnable {
private Bootstrap server;

* The main program for the MyApp class
* @param args The command line arguments
* @exception Exception Description of the Exception
public static void main(String[] args) throws Exception {
MyApp myApp = new MyApp();

* Description of the Method
public void startServer() {
// Create an instance of LWS and run in a new Thread
server = Bootstrap.getInstance();
Thread runner = new Thread(this);
// Do whatever the app is doing

// Restart LWS (in response some external event, typically)

// Stop LWS

* Main processing method for the MyApp object
public void run() {
// Start LWS. Does not return until stopped

The com.gefionsoftware.lws.startup.Bootstrap class handles creation of the LWS server instance, and starting, restarting and stopping the instance. The getInstance() method returns the single instance of the Bootstrap class. You then call the start(), restart() and stop() methods on this instance to control the server.

By default, the LWS instance is configured based on the conf/ file. If you want to configure it based on information from another source, add the properties described in the Server Configuration section to a java.util.Properties instance and call the setCustomServerProperties() method with this instance:

Properties conf = new Properties();
conf.setProperty("server.port", "7070");
conf.setProperty("server.debug", "10");

Properties set this way survive a restart of the server. If you change them and restart the server, the new properties are used.


News | Features | ScreenShots | Project | License | About | Home

© 2004 Corvero Networks Inc