info.sswap.ontologies.exec.api
Class ExecServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
info.sswap.api.servlet.AbstractSSWAPServlet
info.sswap.ontologies.exec.impl.ExecImpl
info.sswap.ontologies.exec.api.ExecServlet
- All Implemented Interfaces:
- Exec, HotboxPoller, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
public class ExecServlet
- extends ExecImpl
The Exec servlet allows the wrapping of legacy, non-semantic programs as
semantic web services. For default behavior, no coding is necessary: simply
map this servlet to a URL pattern in web.xml and place Resource Description
Graphs (RDG
s) in the RDGPath
directory.
For sanitizing user input--an important security measure--extend this servlet
and override getCommandLine
and optionally
getEnvironment
.
Legacy programs are wrapped using the exec
ontology at sswapmeet.sswap.info/exec.
An RDG
can be created using the exec
and other
ontologies and the HTTP API service /makeRDG. Below is a JSON
description of the UNIX program echo
ready for conversion into a
SSWAP OWL RDF/XML RDG.
{
"prefix" : {
"myExec" : "http://localhost:8080/",
"mime" : "http://sswapmeet.sswap.info/mime/",
"" : "http://sswapmeet.sswap.info/exec/"
},
"myExec:exec/echo" : {
"rdf:type" : ":ExecCmd",
"sswap:name" : "echo",
"sswap:oneLineDescription" : "write arguments to standard output",
"sswap:providedBy" : "myExec:resourceProvider",
"sswap:aboutURI" : "http://www.unix.com/man-page/POSIX/1/echo",
":command" : "/bin/echo",
":synopsis" : "echo [-n] [string ...]"
},
"mapping" : { "" : "mime:text/Plain" }
}
The conversion from JSON to RDF/XML OWL can be done automatically by dropping
the JSON description into the hotboxPath
directory as specified
in web.xml file. A directory scanner monitors the directory and converts JSON
files into RDG
s and places them in the RDGPath
directory as semantic web services.
To activate the Exec package simply map this servlet in the web.xml file;
e.g.,
<servlet>
<servlet-name>ExecServlet</servlet-name>
<servlet-class>info.sswap.ontologies.exec.api.ExecServlet</servlet-class>
<init-param>
<param-name>RDGPath</param-name>
<param-value>/public</param-value>
</init-param>
<init-param>
<param-name>hotboxPath</param-name>
<param-value>/json</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>ExecServlet</servlet-name>
<url-pattern>/exec/*</url-pattern>
</servlet-mapping>
You can execute the above program with a HTTP GET as
http://localhost:8080/exec/echo?hello world
. Note that command
line arguments are passed as the query string. This is akin to setting the args property value in
standard SSWAP GET query string parsing (e.g.,
?~args=hello world
).
The ExecServlet
will attempt to open each SSWAP Subject of the
invoking RIG
as a DataFormat
object (see the
data
package and the data
ontology at sswapmeet.sswap.info/data). On reading the
data it will pipe it to the standard input of the command with the parameters
as set by the args
property. The servlet will block on the
process (wait for the process to finish), and will map the standard output to
DataFormat
types of each SSWAP Object.
- Author:
- Damian Gessler
- See Also:
Exec.getCommandLine(String)
,
Exec.setEnvironment(java.util.Map)
,
HotboxPoller
,
Data
,
Serialized Form
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
serialVersionUID
private static final long serialVersionUID
- Default
- See Also:
- Constant Field Values
ExecServlet
public ExecServlet()
Copyright (c) 2011, iPlant Collaborative, University of Arizona, Cold Spring Harbor Laboratories, University of Texas at Austin.