What is the law server?

The law server is a small footprint HTTP server -- it merely has 9 Kbytes -- that can be used in order to publish and access LGI laws. Passing laws as text directly to the controller is possible , but passing them as URL is more convenient. Also, any HTTP webserver can be used, but the law server was found to be particularly useful during the process of law development when it is often required to publish, withdraw and change law files on short notice. It is also useful for those users that do not have access to an HTTP server.

Working with the law server

The law server has two management modes: as an interactive tool, receiving commands from the standard input, or as a background tool, that runs on a long term basis without accepting commands. The former is intended for personal use, particularly during the process of development and testing. The latter is intended for sharing laws among groups of users, and for long term usage of laws.

The law server can be accessed by any web client by making HTTP requests on its publishing port. The client access is identical for both the interactive mode or the background management mode.

Interactive mode

In order to start the law server obtain a console and issue the following command:
> java moses.LawServer

This command starts the law server with the default parameters (access port 8550, and the current directory as the default path ). The user is presented with a law server command console for typing commands. In order to publish the file targetfile that is located in directory targetdir, type in the follwing at the prompt:


New command (!h , for help): @targetdir
path is targetdir
New command (!h , for help): +targetfile
/targetdir/targetfile: lawfile published

In order to view the files published by the law server, open up a browser and access the following URL:

http://hostname:8550

Where hostname represents the hostname where the law server has been started. When targetfile is simple.java1, a window similar to the one in Figure 1) should appear:

Figure 1) Law server access page


The text of the law can be examined by clicking on the law name, or simply by accessing the absolute URL: http://hostname:8550/targetfile
Note that the files are published in a flat name space: from the web user perspective, the directory structure of the files is hidden. This scheme is simple but does not allow publishing files with the same name situated in different directories.
When publishing files, a number of commands and options are available (see !h):

  • +lawfile : to publish a lawfile;
  • -lawfile : to withdraw a lawfile already published;
  • !l : to list all the lawfiles that are published;
  • @path : to set an internal path variable as a base directory to publish files. The files still have to be published explicitly;
  • !@ : to display the path variable
  • !q : to quit

Background mode

This mode is useful when the law server is required to run in the background -- more like a daemon, or service -- without any user intervention.
In order to start the law server in the background mode, use the bg command line argument along with the files to publish:


> java moses.LawServer  bg +targetfile1 +targetfile2 ... &
 currentdir/targetfile1: lawfile published
 currentdir/targetfile2: lawfile published

>

For more details see the Moses reference manual.