Tutorial: jserv–sample Quick Start - odys-z/semantic-jserv GitHub Wiki
This page is for v1.0, for newer version, see his home page
This tutorial will guid you throug steps to start a semantic-jserv server.
The environment is Eclipse IDE and Tomcat for servlet container.
semantic-jserv/jserv-sample is a maven web application. It's provided as a project template for starting new application development.
You can clone then update the maven project, the project source should be ready to be configured now.
In Eclipse, create a new server.
In Eclipse servers' configure files:
In the context.xml, configure a root key and some connection resources. The later is only required if you prefer to using a pooled JDBC connection.
<Resource name="jdbc/inforise-prjcost" global="jdbc/conn-id"
auth="Container" type="javax.sql.DataSource"
maxActive="10" maxIdle="3" maxWait="10000"
username="odysz" password="*********" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://###.###.###.###:3306/[database]?useSSL=true"
connectionProperties="useUnicode=yes;characterEncoding=utf8;autoReconnect=true;autoReconnectForPools=true" />
<Parameter name="io.oz.root-key" value="************" override="false"/>
The root key parameter is used for encrypt user's password in user's table. If you changed this value during system running, all users must reset there password. (TODO docs HOWTO here)
If you doesn't change the project name when creating Tomcat server, Eclipse will handle this automatically.
But if you'd like, you can change the url path in the docbase section.
Jserv-sample is a independent json data server. It doesn't provide any html page, that means you can access the service throw a html file in your filesystem.
In this case, web browsers will complain about cross domain header is missing.
To let the server allow cross domain, in web.xml, add:
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>`
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.exposed.headers</param-name>
<param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>`
</init-param>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
It's already has examples of a sqlite3 (JDBC driver manager style) and a mysql (pooled connection) connections. Check the file.
Now you can start the Tomcat server.
The web application should reporting like this:
Now, browsing the server's default url (index.html), will guid you to get the _Echo servlet's doGet() response.
In the WEB-INF/dataset.xml, add a dataset query define like this (modify to adapt to your DB structure):
<c>
<sk>sys.menu.vue-sample</sk>
<mysql>SELECT funcId, parentId, funcName, funcUrl href, isUsed sort, fullpath
FROM a_sys_functions f order by f.fullpath
</mysql>
<s-tree>,a_sys_functions,funcId id,parentId,funcName title,,,false</s-tree>
</c>
And if your data base has some records can be load, the "htttp://.../jserv-sample/menu.sample?sk=sys.menu.vue-sample" http GET can get something like:
All configure files locate in WEB-INF.
Jserv-sample using semantic.jserv to support user's action on db, all recorded as sql logs, in table a_logs. This semantics configure file is used to generate log ID and operator with operating time finger print.
For more information, see semantic-DA HOWTO (TODO)
TODO
Web application's configurations, e.g. session timeout, out plugins' configure path, etc.