Contents
If you haven't already done so, please download the SDK package, extract it and copy lib/tenduke-sdk-[version].jar library to your preferred location. The SDK package also includes a collection of third party libraries which you may need after you've got started.
Bare minimum needed to get started in developing a new Web Application
Add tenduke-sdk-[version].jar to the project classpath
Add empty configuration file to META-INF/conf/conf.xml with contents
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties version="1.0"> </properties>
Create WEB-INF/web.xml file is it doesn't exist already. Add ServletContextLifecycleManager as a listener to WEB-INF/web.xml file. The application server calls contextInitialized(...) and when the method returns the SDK is ready to accept calls from other objects. Note that if you have configured the SDK to start other services asynchronously, those may not be ready yet at the method return.
Example WEB-INF/web.xml file is
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<listener>
<description>10Duke SDK lifecycle manager for servlet context</description>
<listener-class>com.tenduke.lifecycle.webapp.ServletContextLifecycleManager</listener-class>
</listener>
</web-app>
The minimum setup gets the SDK going, but you may consider the defining the following environment entries.
10duke.configuration.main for the location of the main configuration file
10duke.logger.logentrysubscriber class for logging entries submitted from logger.
They can be defined in WEB-INF/web.xml file by adding the following lines (replace the values with your own):
<env-entry>
<env-entry-name>10duke.configuration.main</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>webapp:/META-INF/conf/conf.xml</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>10duke.logger.logentrysubscriber</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>com.tenduke.diagnostics.JavaLoggerLogWriter</env-entry-value>
</env-entry>If you are using a Tomcat server, then the recommended place to put the entries is META-INF/context.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/simplewebapp">
<Environment name="10duke.configuration.main" type="java.lang.String" value="webapp:/META-INF/conf/conf.xml"/>
<Environment name="10duke.logger.logentrysubscriber" type="java.lang.String" value="com.tenduke.diagnostics.JavaLoggerLogWriter"/>
</Context>
Bare minimum needed to get started in developing a new console application
Add tenduke-sdk-[version].jar to the project classpath
Add empty configuration file to ./conf/conf.xml with the same contents as described in the minimum setup of a Web Applcation. The dot (.) in the path refers to the location where you are running the console application from. Typically this is the project root directory.
Call LifecycleManager's beginLifecycle() method to initialize the SDK.
Before your application stops, call LifecycleManager's endLifecycle() method.
For working console application, see see samples page for simpleconsole sample.
You can use JVM system properties configure some SDK parameters. Perhaps the most important is 10duke.configuration.main which defines the location of the main configuration file. To define a property add -Dproperty=value flag to you JVM startup line. For example -D10duke.configuration.main=/usr/local/config/myconf.xml says that the main configuration file is found from the path /usr/local/config/myconf.xml.
If you're using the default console logger, you might want to configure the logging format and level by adding entries to the conf.xml file.
<entry key="logging.logwriter.template.error">[{0}] {1} ({2}) {3}
{4} {5}</entry>
<entry key="logging.logwriter.template.warning">[{0}] {1} ({2}) {3}
{4} {5}</entry>
<entry key="logging.logwriter.template.info">[{0}] {1} ({2}) {3}
{4} {5}</entry>
<entry key="logging.logwriter.debug.level">3</entry>