Overview of the WLab source code

Directory structure and file locations

The directory structure used in the WLab code follows the usual Maven conventions for a Java web application:

WLab/src/main/java - Java classes WLab/src/main/webapp - Web files – HTML, JSP, etc

Spring configuration

The application uses the Spring framework (http://www.springsource.org/) extensively. The Spring MVC facilities are used in particular; a Java class at the server side processes any input from the user, then builds a Spring ModelAndView (MaV) object. The MaV includes a reference to one of the JSP views, and the associated model the view will need in order to display meaningful data. The diagram below illustrates this:

springmvc

In order to hide the underlying application architecture from the user, Spring is configured to map URLs that end in HTML to the MVC model. The JSP view pages can be found in webapp/WEB-INF/jsp (the obscufated location prevents a user entering a URL ending in JSP and accessing the page directly, and bypassing the Spring MVC model).

The Spring configuration is split across two files:

WLab-servlet.xml conf/application-properties.xml

The former contains the various bean configurations for the controller classes. If you add additional controllers and/or views to WLab, you will most likely need to add a corresponding entry here. The latter file contains the beans that have user-configurable settings. If you create alternative implementations of interfaces such as DataAccess or VirtualisationAccess (discussed later) this file will need to be updated accordingly.

Find out more about how the various views and controllers work in Controller class and JSP view dependencies.

Data model

The WLab data model is implemented by the classes in the org.paulneve.wlab.data package, and is described by this diagram:

datamodel

Associations between data objects are maintained by string values that contain the ID of the object being referenced.

Classes in the org.paulneve.wlab.utilities package

ClassPurpose and explanation
DesEncrypter.javaAdapted from http://www.exampledepot.com/egs/javax.crypto/PassKey.html. Primarily used to encrypt the various parameters supplied to the VNC applet, to avoid end-users selecting “View source” in their browser and discovering details of the internal network. GeneralUtils.java General utility class. Methods contained herein are, for the most part, controller aspects that are used across more than one controller class.
MacToIP.javaConverts a MAC address to an IP address. Works by attempting to establish a network connection to every possible machine on the class C subnet configured in the appropriate properties of application-properties.xml. The ARP cache is then read to find the corresponding IP address for the desired MAC address. This is required because there is no guaranteed method of extracting an IP address from a Hyper-V virtual machine, if it is not running Microsoft’s Integration Services.
Parameters.javaUsed to create a singleton into which the values of application-properties.xml are injected.
Strings.javaUsed to create a singleton into which the values of strings.xml are injected.
VmSuspender.javaRuns resident in a thread, and monitors running VMs to determine which of them should be suspended (if, for example, a student runs beyond their allocated runtime).