In this post, I show you how to add construct to your ubuntu start menu. The assumption I am making is that you have the most recent version of construct (currently 0.74) downloaded and installed.
Step 1
This step allows you to run construct without being in the construct directory.
Open the ‘construct.sh’ file and change the line:
CONSTRUCT_HOME=.
to
CONSTRUCT_HOME=YOUR CONSTRUCT DIRECTORY
For me it is: $HOME/construct
Save the file and exit.
Step 2
Create a symbolic link to the executable shell script.
This allows you to just type ‘construct’ in the terminal, much the same way you would write ‘emacs’ etc.
As the name suggests, the construct.properties file defines settings for the Construct platform. The settings cover three things: global properties for Construct, the components to be instantiated at runtime, and the individual properties of each component.
In the current release, all (bar one) of the global properties are related to logging. The other refers to the hostname of the machine running the Construct software:
Logging level
The level of log messages to be recorded
The Logging limit
The maximum number of bytes to write to any one log file
The logging file count
The number of log files to rotate
The logging file name
The base name to use for log files
The logging directory
The directory in which the log files are stored
The hostname
The hostname or IP address of the machine running the Construct software
The components that you wish to instantiate once the Construct framework is started are also contained in the properties file. Some components also contain properties which are specific to those components and must be declared as children of the components in the properties file. The structure of the properties file is explained further on. Below is an example of some Construct components. More thorough explanations can be found elsewhere on the Wiki.
Data Store Manager
Provides a single point of access to the data store
Query Service
Processes application and entity queries made in SPARQL
Data Port
Accepts RDF data provided by sensors and adds them to the data store
Registry Service
Stores information on registered services
Discovery Service
Handles requests from clients for available Construct services
Gossiping Components
Allows distribution of data store contents
Extension Components
Add-on components such as a Query Viewer
Once the start button is clicked on the Construct GUI, a Component Loader is created which reads in the contents of the properties file and instantiates any components that are specified. On instantiation, each component fetches it’s properties and caters for them.
Reading and Writing to the construct.properties File
The construct.properties file is and XML encoded file in which all properties and components must be contained within the parent node, construct (i.e. it takes the form … ). Global properties must be contained directly inside the construct tags and they are indicated by a property tag. Thus, all properties take the form,
<propertyname=“[the name here]“value=“[the value here]“/>
Components must also be defined directly inside the construct tags. The component specific properties must be declared directly inside the opening and closing tags of the component in question. Components are scripted as follows:
<componentinterface=“[the interface to the component here]“implementation=“[the implementation of the component here]“>
<property … />
</component>
where the interface specifies the path to the interface for the component and the implementation specifies the path to the concrete implementation of the component.
There is an example properties file contained in the release of Construct. To add new properties follow the structure of the document as explained above. HTML style comments (i.e. <!– [the code to comment here] –>) can be used to prevent a property or component contained in the file from being read in. Ensure to comment the property or component by adding the opening comment (<!–) before the opening tag of the component or property and adding the closing comment (–>) after the closing tag.
In part 1 of this post I described the new HTTP Port in Construct. In this part of the post I’ll explain how to write a web form and style the return values.
SPARQL Query
You can send a query to Construct with GET or POST. Here is how we do it in HTML with GET:
<textareaname=“q”cols=“64″rows=“10″>SELECT ?subject ?predicate ?object WHERE {?subject ?predicate ?object}</textarea><br/>URL of XSLT to apply (optional):<br/><inputtype=“text”name=“xsl”size=“56″value=“http://www.construct-infrastructure.org/stylesheets/default.xsl type=”submit” value=”Submit Query“>
</form>
the only thing the HTTP Port wants is the query field to be called either “q” or “query”. The returned XML will be sent back to your browser. Something like this: