Adding a server context

A context is a subarea within the HTTP server to which web applications, servlets or other elements can be added. This allows you to structure your content. The following XML fragment sets up a context.


<Call name="addContext">
<Arg>
<New class="com.ebd.hub.xml.NullClass"/>
</Arg>
<Arg>/service/*</Arg>
[context specific calls and definitions]
</Call>


The first parameter allows to designate a virtual host to which the context is assigned exclusively. If there is no restriction on a particular virtual host, then the specification of the NullClass is necessary, as can be seen in the XML code shown above.

The second parameter is the name of the context as it should appear in the URL.

URLs that address the context as defined above would have the following structure.


http://<myserver>/service/...


The calls and definitions that are possible after adding a context are very numerous. Therefore, only the most important sections for the operation of the Integration Server are described here.

Setting the resource base


If you want to use a directory different from the working directory to obtain resources within a context, you can set this with the following XML fragment.


<Set name="ResourceBase">./myotherdir</Set>


The directory can be specified relative to the working directory of the Integration Server or absolute.

Adding a resource handler to a context


A resource handler is responsible for delivering resources, i.e. HTML pages, images, etc. Without an added resource handler, it is not possible to deliver such static items.

The following XML fragment adds a resource handler to the context.

<Call name="addHandler">
<Arg>
<New class="com.ebd.hub.server.http.handler.ResourceHandler"/>
</Arg>
</Call>


Before setting a resource handler, a suitable resource base should have been defined.

Adding a servlet to a context


The following XML fragment adds a servlet to the current context.


<Call name="addServlet">
<Arg>Servletname</Arg>
<Arg>/ServletContext/*</Arg>
<Arg>com.ebd.dummy.servlet.MySpecialServlet</Arg>
</Call>


Where Servletname is the name of the servlet, such as it should appear in the information area.

ServletContext is the context in which the servlet should be offered. It will be appended to the context to which the servlet is added (here service).

The third parameter is the fully qualified class name of the servlet.

URLs that address the servlet as defined above would have the following structure.

http://<myServer>/service/ServletContext/path/info?key1=val1

Enabling a user authentication


To enable user authentication, it is necessary to have previously added a realm definition.

The following XML fragment activates the HTTP Basic Authentication for the selected context.

<Set name="realmName">Admin Realm</Set>
<Set name="authenticator">
<New class="com.ebd.hub.server.http.BasicAuthenticator"/>
</Set>
<Call name="addHandler">
<Arg>
<New class="com.ebd.hub.server.http.handler.SecurityHandler"/>
</Arg>
</Call>


The parameter specifies the name of the realm, as it was previously defined when adding.

Adding a single web application


The following XML fragment adds a single web application to the server.

<Call name="addWebApplication">
<Arg>/context</Arg>
<Arg>./webapps/webappdir</Arg>
<Set name="extractWAR">false</Set>
<Set name="defaultsDescriptor">etc/webdefault.xml</Set>
 
<Set name="virtualHosts">
<Array type="java.lang.String">
<Item/>
<Item>127.0.0.1</Item>
<Item>localhost</Item>
<Item>www.lobster.de</Item>
</Array>
</Set>
</Call>


The parameters have the following meaning.


Parameter

Description

Context

The context to use for this web application. If null is specified, the base context is used.

Webappdir

The directory where the web app files are located.

ExtractWAR

Determines whether the found WAR file should be extracted to a temporary directory or not.

DefaultsDescriptor

The XML file that configures the web service.


If the web application is to be restricted to specific virtual hosts, this can be done with the XML fragment above.

Adding a web application directory


The following XML fragment defines a base directory for adjustable web applications.

<Call name="addWebApplications">
<Arg>
<New class="com.ebd.hub.xml.NullClass"/>
</Arg>
<Arg>./webapps/</Arg>
<Arg>etc/webdefault.xml</Arg>
<Arg type="boolean">true</Arg>
</Call>


The first parameter is the possibly set virtual host for which the web application directory should be valid or the NullClass entry if the directory of the respective HTTP server is to be used.

The remaining parameters are identical to the parameters already described for adding a single web application.