Looking for the latest version? Download tinyREST-1.0.16.jar (640.9 kB)
Home
Name Modified Size Downloads / Week Status
Totals: 3 Items   160.2 kB 2
tinyREST 2012-06-18 22 weekly downloads
README 2014-11-04 3.7 kB 11 weekly downloads
Rel_1 2012-12-10 156.4 kB 11 weekly downloads
=============================================================================== === BUILDING =============================================================================== In order to compile and use tinyREST application, you need the following open source libraries: Apache Commons IO: http://commons.apache.org/proper/commons-io/download_io.cgi (referred to as lib/commons-io-1.1.jar in manifest class path) Apache Commons FileUpload: http://commons.apache.org/proper/commons-fileupload/download_fileupload.cgi (referred to as lib/commons-fileupload.jar in manifest class path) Apache Log4J: https://logging.apache.org/log4j/1.2/download.html (referred to as lib/log4j-1.2.14.jar in manifest class path) Javax-Servlet: http://www.java2s.com/Code/Jar/j/javax.servlet.htm (referred to as lib/javax.servlet.jar in manifest class path) =============================================================================== === RUNNING =============================================================================== To use the REST server without writing your own service class, simply create a configuration XML file and start the service using the latest jar file (tinyREST-1.0.15.jar or later). The jar will attempt to automatically detect a configuration file, but you can force it to use a specific configuration file like this: java -jar tinyREST-1.0.15.jar -cfg myConfig.xml The configuration file should have this format: <?xml version="1.0" encoding="UTF-8"?> <Configuration> <Service context="service" class="example.GreetHandler2" message="Wow - check this out!"> <addQuestion question="How high is a mountain?" answer="Very high"/> <addQuestion question="What color is the sky?" answer="Light blue"/> </Service> <Service class="example.GreetHandler2" message="Wow - check this out again!"> <addQuestion question="How high is a mountain?" answer="Very, very high"/> <addQuestion question="What color is the sky?" answer="Clear blue"/> </Service> </Configuration> Explanation: <Configuration> - Root element must be <Configuration> <Service> - Each REST service must be defined in a <Service> element. The important attributes are: context - Root context of service e.g. context="root" will require a URL like this: http://ip-address/root/... class - The name of the class which implements your REST service You can add more attributes - the parser will map them to parameter annotations in your constructor. In the example, the constructor takes a parameter called "message" like this: public Greeter2(@Param("message") @Default("Hallo") String message) {} Elements inside <Service> represent method calls in the service class. In the example, the REST service class contains a public method called "addQuestion". The definition typically looks like this: public void addMessage(@Param("question") String question, @Param("answer") @Default("test") String answer) {} The annotations used for constructors and methods in a class (as seen in the configuration above) is used from the package za.co.softco.reflect and is typically used for accessing constructors and methods using reflection. REST services can also be defined using annotations, but be sure to use annotations from the package za.co.softco.rest.model (for example @Parameter("question") for HTTP query parameters). The Greeter2 example uses annotations and is very easy to understand.
Source: README, updated 2014-11-04