# HG changeset patch # User ymh # Date 1269964416 -7200 # Node ID 41b17723d6c8097e4237549734b82c50b91651fa # Parent 3a1bcc02b5a617d2fe696456342a76cb3a95b5c1 add info page diff -r 3a1bcc02b5a6 -r 41b17723d6c8 WebContent/WEB-INF/lib/freemarker.jar Binary file WebContent/WEB-INF/lib/freemarker.jar has changed diff -r 3a1bcc02b5a6 -r 41b17723d6c8 WebContent/WEB-INF/lib/log4j-1.2.15.jar Binary file WebContent/WEB-INF/lib/log4j-1.2.15.jar has changed diff -r 3a1bcc02b5a6 -r 41b17723d6c8 WebContent/WEB-INF/log4j.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebContent/WEB-INF/log4j.properties Tue Mar 30 17:53:36 2010 +0200 @@ -0,0 +1,7 @@ +# This sets the global logging level and specifies the appenders +log4j.rootLogger=INFO, consoleAppender + +# settings for the console appender +log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender +log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout +log4j.appender.consoleAppender.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n \ No newline at end of file diff -r 3a1bcc02b5a6 -r 41b17723d6c8 WebContent/WEB-INF/templates/info.ftl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebContent/WEB-INF/templates/info.ftl Tue Mar 30 17:53:36 2010 +0200 @@ -0,0 +1,32 @@ + + + Info on + + +

Informations

+ + + + + + + + + + + + + + + + + + + + + + + +
TextValue
DATABASE PATH${dbpath}
Segments${segments_nb}
Segments in db${segments_db_nb}
Tags${tags_nb}
+ + \ No newline at end of file diff -r 3a1bcc02b5a6 -r 41b17723d6c8 WebContent/WEB-INF/web.xml --- a/WebContent/WEB-INF/web.xml Wed Mar 24 12:41:26 2010 +0100 +++ b/WebContent/WEB-INF/web.xml Tue Mar 30 17:53:36 2010 +0200 @@ -15,8 +15,12 @@ fr.iri.thd.sonyengine.web.ServletContainer - initDatabasePath - c:/tmp/db + com.sun.jersey.config.property.packages + fr.iri.thd.sonyengine.web + + + log4j-properties-location + /WEB-INF/log4j.properties 1 @@ -24,4 +28,10 @@ sonyengine /* + + + \ No newline at end of file diff -r 3a1bcc02b5a6 -r 41b17723d6c8 src/HelloResource.java --- a/src/HelloResource.java Wed Mar 24 12:41:26 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; - -@Path ("helloworld") -public class HelloResource { - - @GET - @Produces ("text/plain") - public String sayHello() { - return "Hello World"; - } -} diff -r 3a1bcc02b5a6 -r 41b17723d6c8 src/fr/iri/thd/sonyengine/web/FreemarkerViewProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fr/iri/thd/sonyengine/web/FreemarkerViewProcessor.java Tue Mar 30 17:53:36 2010 +0200 @@ -0,0 +1,266 @@ +package fr.iri.thd.sonyengine.web; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintStream; +import java.net.MalformedURLException; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.ServletContext; +import javax.ws.rs.core.Context; +import javax.ws.rs.ext.Provider; + +import org.apache.log4j.Logger; + +import com.sun.jersey.api.view.Viewable; +import com.sun.jersey.spi.template.ViewProcessor; + +import freemarker.cache.WebappTemplateLoader; +import freemarker.template.Configuration; +import freemarker.template.Template; + +/** +* Match a Viewable-named view with a Freemarker template. +* +*

You can configure the location of your templates with the +* context param 'freemarker.template.path'. If not assigned +* we'll use a default of WEB-INF/templates. Note that this uses +* Freemarker's {@link freemarker.cache.WebappTemplateLoader} to +* load/cache the templates, so check its docs (or crank up the logging +* under the 'freemarker.cache' package) if your templates +* aren't getting loaded.

+* +*

This will put your Viewable's model object in the template +* variable "it", unless the model is a Map. If so, the values +* will be assigned to the template assuming the map is of +* type Map<String,Object>.

+* +* Example of configuring the template path: +* +*
+* <web-app ...
+* <display-name>Awesomeo 2000</display-name>
+* <context-param>
+* <param-name>freemarker.template.path</param-name>
+* <param-value>/WEB-INF/views</param-value>
+* </context-param>
+* ...
+*
+* +*

You'll also need to tell Jersey the package where this provider +* is stored. Typically this is through the servlet's init params -- for instance, +* in the below configuration we could store this in com.myco.jersey and +* my resources in com.myco.jersey.resource

+* +*
+* <servlet>
+* <servlet-name>My REST App</servlet-name>
+* <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+* <init-param>
+* <param-name>com.sun.jersey.config.property.packages</param-name>
+* <param-value>com.myco.jersey;com.myco.jersey.resource</param-value>
+* </init-param>
+* </servlet>
+* 
+* +*

There are a number of methods you can override to change the behavior, such as +* handling processing exceptions, changing the default template extension, or +* adding variables to be assigned to every template context. +* +* @author Chris Winters +* @version $Revision: #5 $ (Last update: $DateTime: 2009/04/03 20:12:26 $ $Author: cwinters $) +*/ +@Provider +public class FreemarkerViewProcessor implements ViewProcessor