incubator-wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ngalla...@apache.org
Subject svn commit: r787552 [2/5] - in /incubator/wink/contrib/ibm-jaxrs/samples: ./ addressBook/ addressBook/build/ addressBook/build/classes/ addressBook/build/classes/server/ addressBook/build/classes/server/com/ addressBook/build/classes/server/com/ibm/ ad...
Date Tue, 23 Jun 2009 05:33:38 GMT
Added: incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/ServletHost.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/ServletHost.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/ServletHost.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/ServletHost.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package build.defaults.samples;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+import com.ibm.ws.jaxrs.web.RESTServlet;
+
+/**
+ * Integration with Jetty
+ *
+ */
+public class ServletHost {
+
+    private Class<?>[] resourceClasses;
+
+    private int port;
+
+    private Server server;
+
+    private String applicationClassName;
+
+    public ServletHost(int port, Class<?>... resourceClasses) {
+        this.port = port;
+        this.resourceClasses = resourceClasses;
+        this.applicationClassName = null;
+    }
+
+    public ServletHost(int port, String applicationClassName) {
+        this.port = port;
+        this.resourceClasses = null;
+        this.applicationClassName = applicationClassName;
+    }
+
+    public void init() throws Exception {
+        SelectChannelConnector connector = new SelectChannelConnector();
+        connector.setPort(port);
+        server = new Server();
+        server.setConnectors(new Connector[] { connector });
+        Context root = new Context(server, "/", Context.SESSIONS);
+        Map<String, String> initParams = new HashMap<String, String>();
+        if (applicationClassName != null) {
+            ServletHolder holder = new ServletHolder(new RESTServlet());
+            holder.setInitParameter("javax.ws.rs.Application",
+                    applicationClassName);
+            initParams.put("javax.ws.rs.Application", applicationClassName);
+            root.addServlet(holder, "/*");
+        } else {
+            root.addServlet(
+                    new ServletHolder(new RESTServlet(resourceClasses)), "/*");
+        }
+        root.setInitParams(initParams);
+        server.addHandler(root);
+        server.start();
+    }
+
+    public void shutdown() throws Exception {
+        server.stop();
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/monitor/Monitor.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/monitor/Monitor.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/monitor/Monitor.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/monitor/Monitor.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package build.defaults.samples.monitor;
+
+/**
+ * Monitors are intended to abstract away the need for different output checking
+ * code per container.
+ */
+public interface Monitor {
+
+    public void resetMonitor();
+
+    /**
+     * Returns the different client input and output.
+     *
+     * @return the client input/output
+     */
+    public String getClientOutput();
+
+    /**
+     * Returns the server side output.
+     *
+     * @return the server side output
+     */
+    public String getServerOutput();
+
+    /**
+     * Returns the server side error.
+     *
+     * @return the server side error
+     */
+    public String getServerError();
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/monitor/StandaloneMonitor.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/monitor/StandaloneMonitor.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/monitor/StandaloneMonitor.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/monitor/StandaloneMonitor.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,251 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package build.defaults.samples.monitor;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.text.MessageFormat;
+import java.util.Locale;
+
+public class StandaloneMonitor implements Monitor {
+    private PrintStreamDelegate psDelegate;
+
+    public StandaloneMonitor() {
+        /* do nothing */
+        //LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
+        // "org.apache.commons.logging.impl.Jdk14Logger");
+        // handler.setLevel(Level.FINEST);
+        // Logger.getLogger("httpclient.wire").addHandler(handler);
+        // Logger.getLogger("httpclient.wire").setLevel(Level.FINEST);
+        psDelegate = new PrintStreamDelegate(System.err);
+        System.setErr(psDelegate);
+    }
+
+    public static class PrintStreamDelegate extends PrintStream {
+        private PrintStream ps;
+
+        private StringBuffer sb = new StringBuffer();
+
+        final private static String lineSep = System
+                .getProperty("line.separator");
+
+        public PrintStreamDelegate(PrintStream out) {
+            super(out);
+            this.ps = out;
+        }
+
+        public PrintStream append(char c) {
+            sb.append(c);
+            return ps.append(c);
+        }
+
+        public PrintStream append(CharSequence csq, int start, int end) {
+            sb.append(csq, start, end);
+            return ps.append(csq, start, end);
+        }
+
+        public PrintStream append(CharSequence csq) {
+            sb.append(csq);
+            return ps.append(csq);
+        }
+
+        public boolean checkError() {
+            return ps.checkError();
+        }
+
+        public void close() {
+            ps.close();
+        }
+
+        public boolean equals(Object o) {
+            return ps.equals(o);
+        }
+
+        public void flush() {
+            ps.flush();
+        }
+
+        public PrintStream format(Locale l, String format, Object... args) {
+            /* XXX doesn't use locale */
+            sb.append(MessageFormat.format(format, args));
+            return ps.format(l, format, args);
+        }
+
+        public PrintStream format(String format, Object... args) {
+            sb.append(MessageFormat.format(format, args));
+            return ps.format(format, args);
+        }
+
+        public int hashCode() {
+            return ps.hashCode();
+        }
+
+        public void print(boolean b) {
+            sb.append(b);
+            ps.print(b);
+        }
+
+        public void print(char c) {
+            sb.append(c);
+            ps.print(c);
+        }
+
+        public void print(char[] s) {
+            sb.append(s);
+            ps.print(s);
+        }
+
+        public void print(double d) {
+            sb.append(d);
+            ps.print(d);
+        }
+
+        public void print(float f) {
+            sb.append(f);
+            ps.print(f);
+        }
+
+        public void print(int i) {
+            sb.append(i);
+            ps.print(i);
+        }
+
+        public void print(long l) {
+            sb.append(l);
+            ps.print(l);
+        }
+
+        public void print(Object obj) {
+            sb.append(obj);
+            ps.print(obj);
+        }
+
+        public void print(String s) {
+            sb.append(s);
+            ps.print(s);
+        }
+
+        public PrintStream printf(Locale l, String format, Object... args) {
+            /* XXX doesn't use locale */
+            sb.append(MessageFormat.format(format, args));
+            return ps.printf(l, format, args);
+        }
+
+        public PrintStream printf(String format, Object... args) {
+            sb.append(MessageFormat.format(format, args));
+            return ps.printf(format, args);
+        }
+
+        public void println() {
+            sb.append(lineSep);
+            ps.println();
+        }
+
+        public void println(boolean x) {
+            sb.append(x + lineSep);
+            ps.println(x);
+        }
+
+        public void println(char x) {
+            sb.append(x + lineSep);
+            ps.println(x);
+        }
+
+        public void println(char[] x) {
+            sb.append(x);
+            sb.append(lineSep);
+            ps.println(x);
+        }
+
+        public void println(double x) {
+            sb.append(x + lineSep);
+            ps.println(x);
+        }
+
+        public void println(float x) {
+            sb.append(x + lineSep);
+            ps.println(x);
+        }
+
+        public void println(int x) {
+            sb.append(x + lineSep);
+            ps.println(x);
+        }
+
+        public void println(long x) {
+            sb.append(x + lineSep);
+            ps.println(x);
+        }
+
+        public void println(Object x) {
+            sb.append(x + lineSep);
+            ps.println(x);
+        }
+
+        public void println(String x) {
+            sb.append(x + lineSep);
+            ps.println(x);
+        }
+
+        public String toString() {
+            return ps.toString();
+        }
+
+        public void write(byte[] buf, int off, int len) {
+            sb.append(new String(buf, off, len));
+            ps.write(buf, off, len);
+        }
+
+        public void write(byte[] b) throws IOException {
+            sb.append(b);
+            ps.write(b);
+        }
+
+        public void write(int b) {
+            sb.append(b);
+            ps.write(b);
+        }
+
+        public String getOutput() {
+            return sb.toString();
+        }
+
+        public void reset() {
+            sb.delete(0, sb.length());
+        }
+    }
+
+    public String getClientOutput() {
+        return "";
+    }
+
+    public void resetMonitor() {
+        // handler.reset();
+        psDelegate.reset();
+    }
+
+    public String getServerError() {
+        return psDelegate.getOutput();
+    }
+
+    public String getServerOutput() {
+        return psDelegate.getOutput();
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/monitor/WASMonitor.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/monitor/WASMonitor.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/monitor/WASMonitor.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/common/src/build/defaults/samples/monitor/WASMonitor.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package build.defaults.samples.monitor;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.CharBuffer;
+
+public class WASMonitor implements Monitor {
+    /*
+     * TODO: There is a defect here where the system out log could wrap, be
+     * erased, etc. Need to fix eventually but assume clean WAS install for now.
+     */
+
+    private long startLength;
+
+    private File f = new File(System.getProperty("fvt.websphere.base.dir",
+            "c:/WebSphere/AppServer")
+            + "/profiles/"
+            + System.getProperty("fvt.websphere.profile", "AppSrv01")
+            + "/logs/server1/SystemOut.log");
+
+    public WASMonitor() {
+        if (!f.exists()) {
+            throw new RuntimeException(f.getAbsolutePath());
+        }
+        startLength = f.length();
+    }
+
+    public String getClientOutput() {
+        return "";
+    }
+
+    public void resetMonitor() {
+        startLength = f.length();
+    }
+
+    public String getServerError() {
+        return "";
+    }
+
+    public String getServerOutput() {
+        long totalSize = f.length() - startLength;
+        int capacity = (totalSize > Integer.MAX_VALUE) ? Integer.MAX_VALUE
+                : (int) totalSize;
+        CharBuffer charBuffer = CharBuffer.allocate(capacity);
+        try {
+            FileInputStream fis = new FileInputStream(f);
+            fis.skip(startLength);
+            InputStreamReader isr = new InputStreamReader(fis);
+            int charsAlreadyRead = 0;
+            int temp = -1;
+            while ((temp = isr.read(charBuffer)) > -1
+                    && charsAlreadyRead < capacity) {
+                charsAlreadyRead += temp;
+            }
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        charBuffer.rewind();
+        return charBuffer.toString();
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/build.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/build.xml?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/build.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/build.xml Tue Jun 23 05:33:31 2009
@@ -0,0 +1,171 @@
+<project name="addressBook" default="all">
+
+	<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+	<dirname file="${ant.file.addressBook}" property="sample.base.dir" />
+	<property name="sample.build.dir" location="${sample.base.dir}/build" />
+	<property name="sample.compile.dir" location="${sample.build.dir}/classes" />
+	<property name="sample.work.dir" location="${sample.build.dir}/work" />
+	<property name="sample.dist.dir" location="${sample.base.dir}/dist" />
+
+	<property name="sample.runtime.dir" location="${sample.base.dir}/runtime" />
+	<available file="${sample.runtime.dir}" type="dir" property="sample.runtime.dir.exists" />
+
+	<property name="sample.server.src.dir" location="${sample.base.dir}/server/src" />
+	<property name="sample.server.build.dir" location="${sample.compile.dir}/server/" />
+	<property name="sample.server.static.dir" location="${sample.base.dir}/server/static" />
+
+	<!-- Get the current directory name.  This is needed to label
+	     the sample WAR, JAR, etc.  -->
+	<basename property="archiveName" file="${sample.base.dir}" />
+
+	<!-- Classpath to compile with -->
+	<path id="sample.compile.classpath">
+		<path refid="${samples.compile.classpathref}" />
+		<pathelement path="${classpath}" />
+	</path>
+
+	<target name="init">
+	</target>
+
+	<target name="clean" description="Cleans all built artifacts." depends="init">
+		<delete dir="${sample.build.dir}" includeemptydirs="true" failonerror="false" />
+		<mkdir dir="${sample.build.dir}" />
+		<mkdir dir="${sample.compile.dir}" />
+		<mkdir dir="${sample.work.dir}" />
+
+		<delete dir="${sample.dist.dir}" includeemptydirs="true" failonerror="false" />
+		<mkdir dir="${sample.dist.dir}" />
+	</target>
+
+	<!-- Just does the compile of sample src.  -->
+	<target name="compileServer" depends="init, clean">
+		<echo>-------------------------------------------</echo>
+		<echo>Compiling Server Side Sample - ${archiveName}</echo>
+		<echo>-------------------------------------------</echo>
+
+		<mkdir dir="${sample.server.build.dir}" />
+		<javac srcdir="${sample.server.src.dir}" destdir="${sample.server.build.dir}" debug="on">
+			<classpath refid="${samples.compile.classpathref}" />
+		</javac>
+	</target>
+
+	<target name="compile" description="Compiles all source code.">
+		<antcall target="compileServer">
+		</antcall>
+	</target>
+
+	<target name="distServer">
+		<war destfile="${sample.dist.dir}/${archiveName}_server.war" webxml="${sample.base.dir}/server/WEB-INF/web.xml">
+			<fileset dir="." includes="server/src/**" />
+			<classes dir="${sample.server.build.dir}" />
+			<lib refid="${samples.filesetref}" />
+			<lib refid="${samples.runtime.filesetref}" />
+			<zipfileset src="${sample.server.static.dir}/content.zip" />
+			<zipfileset dir="${sample.server.static.dir}">
+				<exclude name="*.zip" />
+			</zipfileset>
+		</war>
+	</target>
+
+	<target name="dist" description="Packages the sample for distribution.">
+		<antcall target="distServer">
+		</antcall>
+	</target>
+
+	<target name="all" depends="clean, compile, dist">
+	</target>
+
+	<!-- Magic -->
+	<condition property="samples.compile.classpathref" value="samples.compile.classpath.packaged" else="samples.compile.classpath.dist.runtime">
+		<isset property="sample.runtime.dir.exists" />
+	</condition>
+
+	<condition property="samples.filesetref" value="samples.classpath.packaged.fileset" else="samples.classpath.dist.fileset">
+		<isset property="sample.runtime.dir.exists" />
+	</condition>
+
+	<condition property="samples.runtime.filesetref" value="samples.runtime.packaged.fileset" else="samples.runtime.dist.fileset">
+		<isset property="sample.runtime.dir.exists" />
+	</condition>
+
+	<path id="samples.compile.classpath.packaged">
+		<!-- If this is a sample by itself, expect the JARs to be in a subdirectory. -->
+		<fileset refid="${samples.filesetref}" />
+		<fileset refid="${samples.runtime.filesetref}" />
+	</path>
+
+	<path id="samples.compile.classpath.dist.runtime">
+		<fileset refid="${samples.filesetref}" />
+		<fileset refid="${samples.runtime.filesetref}" />
+	</path>
+
+	<fileset dir="${sample.base.dir}/lib" id="samples.runtime.packaged.fileset">
+		<include name="ibmjaxrs*.jar" />
+	</fileset>
+
+	<fileset dir="${sample.base.dir}/../../build" id="samples.runtime.dist.fileset">
+		<include name="ibmjaxrs*.jar" />
+	</fileset>
+
+	<fileset dir="${sample.runtime.dir}/lib" id="samples.classpath.packaged.fileset">
+		<include name="asm-all-3.1.jar" />
+		<include name="serp-1.13.1.jar" />
+
+		<include name="commons-logging-1.1.1.jar" />
+
+		<include name="abdera-0.4.0-incubating.jar" />
+		<include name="abdera-core-0.4.0-incubating.jar" />
+		<include name="axiom-api-1.2.5.jar" />
+		<include name="axiom-impl-1.2.5.jar" />
+		<include name="commons-codec-1.3.jar" />
+		<include name="jaxen-1.1.1.jar" />
+
+		<include name="xmlbeans-2.3.0.jar" />
+
+		<include name="jsr311-api-0.11.jar" />
+	</fileset>
+
+	<fileset dir="${sample.base.dir}/../../lib" id="samples.classpath.dist.fileset">
+		<include name="asm-all-3.1.jar" />
+		<include name="serp-1.13.1.jar" />
+
+		<include name="commons-logging-1.1.1.jar" />
+
+		<include name="abdera-0.4.0-incubating.jar" />
+		<include name="abdera-core-0.4.0-incubating.jar" />
+		<include name="axiom-api-1.2.5.jar" />
+		<include name="axiom-impl-1.2.5.jar" />
+		<include name="commons-codec-1.3.jar" />
+		<include name="jaxen-1.1.1.jar" />
+
+		<include name="xmlbeans-2.3.0.jar" />
+
+		<include name="jsr311-api-0.11.jar" />
+	</fileset>
+
+	<target name="packageSampleOnly">
+		<mkdir dir="${sample.runtime.dir}/lib" />
+		<copy todir="${sample.runtime.dir}/lib">
+			<fileset refid="samples.classpath.dist.fileset">
+			</fileset>
+		</copy>
+	</target>
+</project>

Added: incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/WEB-INF/web.xml?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/WEB-INF/web.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/WEB-INF/web.xml Tue Jun 23 05:33:31 2009
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<web-app id="WebApp_ID" version="2.4"
+	xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+	<servlet>
+		<servlet-name>Scoreboard</servlet-name>
+		<servlet-class> com.ibm.ws.jaxrs.web.RESTServlet </servlet-class>
+		<init-param>
+			<param-name>javax.ws.rs.Application</param-name>
+			<param-value>com.ibm.jaxrs.sample.contentnegotiation.ScoreboardApplication</param-value>
+		</init-param>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
+	<servlet-mapping>
+		<servlet-name>Scoreboard</servlet-name>
+		<url-pattern>/scoreboard/*</url-pattern>
+	</servlet-mapping>
+	<welcome-file-list>
+		<welcome-file>index.html</welcome-file>
+	</welcome-file-list>
+</web-app>
\ No newline at end of file

Added: incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/ObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/ObjectFactory.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/ObjectFactory.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/ObjectFactory.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.jaxrs.sample.contentnegotiation;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+@XmlRegistry
+public class ObjectFactory {
+
+    public Score createScore() {
+        return new Score();
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/Score.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/Score.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/Score.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/Score.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.jaxrs.sample.contentnegotiation;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class Score {
+
+    private String homeTeam;
+
+    private Integer homeScore;
+
+    private String visitorTeam;
+
+    private Integer visitorScore;
+
+    public String getHomeTeam() {
+        return homeTeam;
+    }
+
+    public void setHomeTeam(String homeTeam) {
+        this.homeTeam = homeTeam;
+    }
+
+    public Integer getHomeScore() {
+        return homeScore;
+    }
+
+    public void setHomeScore(Integer homeScore) {
+        this.homeScore = homeScore;
+    }
+
+    public String getVisitorTeam() {
+        return visitorTeam;
+    }
+
+    public void setVisitorTeam(String visitorTeam) {
+        this.visitorTeam = visitorTeam;
+    }
+
+    public Integer getVisitorScore() {
+        return visitorScore;
+    }
+
+    public void setVisitorScore(Integer visitorScore) {
+        this.visitorScore = visitorScore;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/ScoreResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/ScoreResource.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/ScoreResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/ScoreResource.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.jaxrs.sample.contentnegotiation;
+
+import java.util.List;
+import java.util.Locale;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Variant;
+
+@Path("scoreboard")
+public class ScoreResource {
+
+    @GET
+    @Path("multiplemethods/score/{gamenum}.xml")
+    @Produces("text/xml")
+    public Response processRequestWithXML(@PathParam("gamenum") String gameNum) {
+        Score s = Scoreboard.getScoreForGame(gameNum);
+        /* Score is a JAXB annotated class so can return directly */
+        return Response.ok(s).build();
+    }
+
+    @GET
+    @Path("multiplemethods/score/{gamenum}.text")
+    @Produces("text/plain")
+    public Response processRequestWithText(@PathParam("gamenum") String gameNum) {
+        Score s = Scoreboard.getScoreForGame(gameNum);
+        String entity = "Home Team: " + s.getHomeTeam() + " ; Home Score: "
+                + s.getHomeScore() + " ; Visitor Team: " + s.getVisitorTeam()
+                + " ; Visitor Score: " + s.getVisitorScore();
+        return Response.ok(entity).build();
+    }
+
+    @GET
+    @Path("singlemethod/score/{gamenum}.{type}")
+    public Response processRequest(@PathParam("gamenum") String gameNum, @PathParam("type") String type) {
+        Score s = Scoreboard.getScoreForGame(gameNum);
+        if ("xml".equals(type)) {
+            /* Score is a JAXB annotated class so can return directly */
+            return Response.ok(s).type("text/xml").build();
+        } else if ("text".equals(type)) {
+            String entity = "Home Team: " + s.getHomeTeam() + " ; Home Score: "
+                    + s.getHomeScore() + " ; Visitor Team: "
+                    + s.getVisitorTeam() + " ; Visitor Score: "
+                    + s.getVisitorScore();
+            return Response.ok(entity).type(MediaType.TEXT_PLAIN_TYPE).build();
+        } else {
+            /* return a HTTP status code */
+            return Response.status(406).build();
+        }
+    }
+
+    @GET
+    @Path("httpheader/score/{gamenum}")
+    @Produces(value = { "application/xml", "text/xml", "text/plain" })
+    public Response processRequestWithHTTPHeaders(@PathParam("gamenum") String gameNum, @Context HttpHeaders headers) {
+        Score s = Scoreboard.getScoreForGame(gameNum);
+
+        List<MediaType> acceptableMediaTypes = headers
+                .getAcceptableMediaTypes();
+        for (MediaType responseMediaType : acceptableMediaTypes) {
+            if (MediaType.TEXT_XML_TYPE.isCompatible(responseMediaType)
+                    || MediaType.APPLICATION_XML_TYPE
+                            .isCompatible(responseMediaType)) {
+                /* Score is a JAXB annotated class so can return directly */
+                return Response.ok(s).type(responseMediaType).build();
+            } else if (MediaType.TEXT_PLAIN_TYPE
+                    .isCompatible(responseMediaType)) {
+                String entity = "Home Team: " + s.getHomeTeam()
+                        + " ; Home Score: " + s.getHomeScore()
+                        + " ; Visitor Team: " + s.getVisitorTeam()
+                        + " ; Visitor Score: " + s.getVisitorScore();
+                return Response.ok(entity).type("text/plain").build();
+            }
+        }
+
+        /* Return the text/xml version if no Accept header was given */
+        return Response.ok(s).build();
+    }
+
+    @GET
+    @Path("request/score/{gamenum}")
+    @Produces(value = { "application/xml", "text/xml", "text/plain" })
+    public Response processRequest(@PathParam("gamenum") String gameNum, @Context Request requestObj) {
+        Score s = Scoreboard.getScoreForGame(gameNum);
+
+        /* build a list of possible response representation variants */
+        /* in this case, only the media types are uesd */
+        List<Variant> possibleVariants = Variant.mediaTypes(
+                MediaType.TEXT_XML_TYPE, MediaType.APPLICATION_XML_TYPE,
+                MediaType.TEXT_PLAIN_TYPE).add().build();
+
+        /* select the best matching variant based on the request HTTP headers */
+        Variant responseVariant = requestObj.selectVariant(possibleVariants);
+
+        /*
+         * get the media type that the JAX-RS runtime believes is the best
+         * possible variant
+         */
+        MediaType responseMediaType = responseVariant.getMediaType();
+
+        @SuppressWarnings("unused")
+        Locale responseLocale = responseVariant.getLanguage();
+
+        /* ...there would be some code to get a Locale specific translation... */
+        String homeTeamTranslated = s.getHomeTeam();
+        String visitorTeamTranslated = s.getVisitorTeam();
+
+        if (MediaType.TEXT_XML_TYPE.isCompatible(responseMediaType)
+                || MediaType.APPLICATION_XML_TYPE
+                        .isCompatible(responseMediaType)) {
+            /* Score is a JAXB annotated class so can be return directly */
+            return Response.ok(s).type(responseMediaType).build();
+        } else if (MediaType.TEXT_PLAIN_TYPE.isCompatible(responseMediaType)) {
+            String entity = "Home Team: " + homeTeamTranslated
+                    + " ; Home Score: " + s.getHomeScore()
+                    + " ; Visitor Team: " + visitorTeamTranslated
+                    + " ; Visitor Score: " + s.getVisitorScore();
+            return Response.ok(entity).build();
+        }
+
+        /*
+         * the Request object should return the best response type among the 3
+         * given so the following code should never execute
+         */
+        return Response.serverError().build();
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/Scoreboard.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/Scoreboard.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/Scoreboard.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/Scoreboard.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.jaxrs.sample.contentnegotiation;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public final class Scoreboard {
+
+    private final static Map<Integer, Score> scoreboard = new HashMap<Integer, Score>();
+
+    static {
+        /*
+         * load up some sample data
+         */
+        Score s = new Score();
+        s.setHomeTeam("Blue Team");
+        s.setHomeScore(Integer.valueOf(1));
+        s.setVisitorTeam("Red Team");
+        s.setVisitorScore(Integer.valueOf(2));
+        scoreboard.put(Integer.valueOf(1), s);
+
+        s = new Score();
+        s.setHomeTeam("A Team");
+        s.setHomeScore(Integer.valueOf(100));
+        s.setVisitorTeam("B Team");
+        s.setVisitorScore(Integer.valueOf(99));
+        scoreboard.put(Integer.valueOf(2), s);
+    }
+
+    public static Score getScoreForGame(String number) {
+        return scoreboard.get(Integer.valueOf(number));
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/ScoreboardApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/ScoreboardApplication.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/ScoreboardApplication.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/src/com/ibm/jaxrs/sample/contentnegotiation/ScoreboardApplication.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.jaxrs.sample.contentnegotiation;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class ScoreboardApplication extends javax.ws.rs.core.Application {
+
+    @Override
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> clazzes = new HashSet<Class<?>>();
+        clazzes.add(ScoreResource.class);
+        return clazzes;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/static/content.zip
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/static/content.zip?rev=787552&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/static/content.zip
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/static/index.html
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/static/index.html?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/static/index.html (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/contentnegotiation/server/static/index.html Tue Jun 23 05:33:31 2009
@@ -0,0 +1,168 @@
+<html>
+<head>
+<title>Scoreboard - Content Negotiation via Hardcoded URLs and
+HTTP Headers</title>
+
+<link rel="stylesheet" href="dijit/themes/soria/soria.css"
+	type="text/css" media="screen" id="themeCss" charset="utf-8">
+<script type="text/javascript" src="dojo/dojo.js"
+	djConfig="parseOnLoad: true"></script>
+<script type="text/javascript" src="dijit/dijit-all.js"></script>
+<script type="text/javascript">
+	dojo.require("dijit.layout.TabContainer");
+	dojo.require("dijit.layout.ContentPane");
+	dojo.require("dijit.form.Button");
+	dojo.require("dijit.form.TextBox");
+	dojo.require("dijit.form.ComboBox");
+	dojo.require("dijit.form.FilteringSelect");
+</script>
+<script>
+	function updateResponse(data, ioArgs) {
+		var responseStatus = dojo.byId("responseStatusCode");
+		responseStatus.innerHTML = "<pre>" + ioArgs.xhr.status + "</pre>";
+
+		var responseEntity = dojo.byId("responseEntity");
+		var responseEntityValue = ioArgs.xhr.responseText;
+		responseEntityValue = responseEntityValue.replace(/</g, "&lt;")
+				.replace(/>/g, "&gt;");
+		responseEntity.innerHTML = "<pre>" + responseEntityValue + "</pre>";
+
+		var responseHeadersValue = ioArgs.xhr.getAllResponseHeaders();
+
+		var responseHeaders = dojo.byId("responseHeaders");
+		responseHeaders.innerHTML = "<pre>" + responseHeadersValue + "</pre>";
+	}
+
+	function updateRequest(url, method, headers) {
+		var requestURL = dojo.byId("requestURL");
+		var requestMethod = dojo.byId("requestMethod");
+		var requestHeaders = dojo.byId("requestHeaders");
+
+		requestURL.innerHTML = "<pre>" + url + "</pre>";
+		requestMethod.innerHTML = "<pre>" + method + "</pre>";
+		requestHeaders.innerHTML = "<pre>" + headers + "</pre>";
+	}
+
+	function issueRequest() {
+		var resourceurl = dojo.byId("resourceurl");
+		var acceptHeaderValue = dojo.byId("acceptHeader").value;
+
+		var requestHeaders = {
+				
+		};
+		if (acceptHeaderValue != null && acceptHeaderValue != "") {
+			requestHeaders["Accept"] = acceptHeaderValue;
+		}
+		var requestHeaderStrValue = "";
+		for (var header in requestHeaders) {
+			requestHeaderStrValue += header + " : " + requestHeaders[header];
+		}
+		dojo
+				.xhrGet( {
+					url : resourceurl.value,
+					timeout :5000,
+					headers: requestHeaders,
+					preventCache :true,
+					handleAs :"text",
+					handle : function(data, ioArgs) {
+						console.log(data);
+						updateRequest(resourceurl.value, "GET", requestHeaderStrValue);
+						updateResponse(data, ioArgs);
+						console.log("bye");
+						return data;
+					}
+				});
+	}
+
+    dojo.addOnLoad(function() {
+        dojo.connect(dojo.byId("issueRequest"), "onclick", function(event) {
+            issueRequest();
+        });
+    });
+    
+</script>
+</head>
+<body class="soria">
+<p>Scoreboard Content Negotiation Sample</p>
+
+<p>Welcome to the Scoreboard Content Negotiation sample. This sample
+demonstrates the various ways that content can be negotiated from using
+hard coded URL schemes to HTTP Accept headers.</p>
+
+<p>On this page, you can submit a GET request to various URLs with
+or without a HTTP Accept request header.</p>
+
+<div>1) Choose one of the resource URLs to GET. Note that the
+Accept header is only processed in some URLs
+(scoreboard/httpheader/score/1 and scoreboard/request/score/1). The rest
+use the URL to specify the format.
+<form><select id="resourceurl" name="resourceurl">
+	<option value="scoreboard/multiplemethods/score/1.json" selected>scoreboard/multiplemethods/score/1.json</option>
+	<option value="scoreboard/multiplemethods/score/1.xml">scoreboard/multiplemethods/score/1.xml</option>
+	<option value="scoreboard/multiplemethods/score/1.text">scoreboard/multiplemethods/score/1.text</option>
+	<option value="scoreboard/singlemethod/score/1.json">scoreboard/singlemethod/score/1.json</option>
+	<option value="scoreboard/singlemethod/score/1.xml">scoreboard/singlemethod/score/1.xml</option>
+	<option value="scoreboard/singlemethod/score/1.text">scoreboard/singlemethod/score/1.text</option>
+	<option value="scoreboard/httpheader/score/1">scoreboard/httpheader/score/1</option>
+	<option value="scoreboard/request/score/1">scoreboard/request/score/1</option>
+</select></form>
+</div>
+
+<div>2) Specify a HTTP Accept request header value:
+<form id="submissionform">
+<table>
+	<tr>
+		<td align="right">HTTP Accept Header</td>
+		<td align="left"><input type="text" name="acceptHeader" value=""
+			id="acceptHeader" dojoType="dijit.form.TextBox" /></td>
+	</tr>
+	<tr>
+		<td></td>
+		<td align="left">
+		<button name="submit" id="issueRequest" dojoType="dijit.form.Button">Click
+		to issue the Request</button>
+		</td>
+	</tr>
+</table>
+</form>
+</div>
+
+<div>3) See the actual request/response:
+<table>
+	<tr>
+		<th colspan="2">Request</th>
+	</tr>
+	<tr>
+		<td valign="top" align="right">URL:</td>
+		<td id="requestURL" valign="top"></td>
+	</tr>
+	<tr>
+		<td valign="top" align="right">HTTP Method:</td>
+		<td id="requestMethod" valign="top"></td>
+	</tr>
+	<tr>
+		<td valign="top" align="right">Headers:</td>
+		<td id="requestHeaders" valign="top"></td>
+	</tr>
+
+
+	<tr>
+		<th colspan="2">Response</th>
+	</tr>
+	<tr>
+		<td valign="top" align="right">Status Code:</td>
+		<td id="responseStatusCode" valign="top"></td>
+	</tr>
+	<tr>
+		<td valign="top" align="right">Headers:</td>
+		<td id="responseHeaders" valign="top"></td>
+	</tr>
+	<tr>
+		<td valign="top" align="right">Entity:</td>
+		<td id="responseEntity" valign="top"></td>
+	</tr>
+</table>
+</div>
+
+</body>
+</html>

Added: incubator/wink/contrib/ibm-jaxrs/samples/context/build.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/context/build.xml?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/context/build.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/context/build.xml Tue Jun 23 05:33:31 2009
@@ -0,0 +1,171 @@
+<project name="context" default="all">
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+	<dirname file="${ant.file.context}" property="sample.base.dir" />
+	<property name="sample.build.dir" location="${sample.base.dir}/build" />
+	<property name="sample.compile.dir" location="${sample.build.dir}/classes" />
+	<property name="sample.work.dir" location="${sample.build.dir}/work" />
+	<property name="sample.dist.dir" location="${sample.base.dir}/dist" />
+
+	<property name="sample.runtime.dir" location="${sample.base.dir}/runtime" />
+	<available file="${sample.runtime.dir}" type="dir" property="sample.runtime.dir.exists" />
+
+	<property name="sample.server.src.dir" location="${sample.base.dir}/server/src" />
+	<property name="sample.server.build.dir" location="${sample.compile.dir}/server/" />
+	<property name="sample.server.static.dir" location="${sample.base.dir}/server/static" />
+
+	<!-- Get the current directory name.  This is needed to label
+	     the sample WAR, JAR, etc.  -->
+	<basename property="archiveName" file="${sample.base.dir}" />
+
+	<!-- Classpath to compile with -->
+	<path id="sample.compile.classpath">
+		<path refid="${samples.compile.classpathref}" />
+		<pathelement path="${classpath}" />
+	</path>
+
+	<target name="init">
+	</target>
+
+	<target name="clean" description="Cleans all built artifacts." depends="init">
+		<delete dir="${sample.build.dir}" includeemptydirs="true" failonerror="false" />
+		<mkdir dir="${sample.build.dir}" />
+		<mkdir dir="${sample.compile.dir}" />
+		<mkdir dir="${sample.work.dir}" />
+
+		<delete dir="${sample.dist.dir}" includeemptydirs="true" failonerror="false" />
+		<mkdir dir="${sample.dist.dir}" />
+	</target>
+
+	<!-- Just does the compile of sample src.  -->
+	<target name="compileServer" depends="init, clean">
+		<echo>-------------------------------------------</echo>
+		<echo>Compiling Server Side Sample - ${archiveName}</echo>
+		<echo>-------------------------------------------</echo>
+
+		<mkdir dir="${sample.server.build.dir}" />
+		<javac srcdir="${sample.server.src.dir}" destdir="${sample.server.build.dir}" debug="on">
+			<classpath refid="${samples.compile.classpathref}" />
+		</javac>
+	</target>
+
+	<target name="compile" description="Compiles all source code.">
+		<antcall target="compileServer">
+		</antcall>
+	</target>
+
+	<!-- Get the current directory name.  This is needed to label
+	     the sample WAR, JAR, etc.  -->
+	<basename property="archiveName" file="${basedir}" />
+
+	<target name="distServer">
+		<war destfile="${sample.dist.dir}/${archiveName}_server.war" webxml="${sample.base.dir}/server/WEB-INF/web.xml">
+			<fileset dir="." includes="server/src/**" />
+			<classes dir="${sample.server.build.dir}" />
+			<lib refid="${samples.filesetref}" />
+			<lib refid="${samples.runtime.filesetref}" />
+			<zipfileset src="${sample.server.static.dir}/content.zip" />
+			<zipfileset dir="${sample.server.static.dir}">
+				<exclude name="*.zip" />
+			</zipfileset>
+		</war>
+	</target>
+
+	<target name="dist" description="Packages the sample for distribution.">
+		<antcall target="distServer">
+		</antcall>
+	</target>
+
+	<target name="all" depends="clean, compile, dist">
+	</target>
+
+	<!-- Magic -->
+	<condition property="samples.compile.classpathref" value="samples.compile.classpath.packaged" else="samples.compile.classpath.dist.runtime">
+		<isset property="sample.runtime.dir.exists" />
+	</condition>
+
+	<condition property="samples.filesetref" value="samples.classpath.packaged.fileset" else="samples.classpath.dist.fileset">
+		<isset property="sample.runtime.dir.exists" />
+	</condition>
+
+	<condition property="samples.runtime.filesetref" value="samples.runtime.packaged.fileset" else="samples.runtime.dist.fileset">
+		<isset property="sample.runtime.dir.exists" />
+	</condition>
+
+	<path id="samples.compile.classpath.packaged">
+		<!-- If this is a sample by itself, expect the JARs to be in a subdirectory. -->
+		<fileset refid="${samples.filesetref}" />
+		<fileset refid="${samples.runtime.filesetref}" />
+	</path>
+
+	<path id="samples.compile.classpath.dist.runtime">
+		<fileset refid="${samples.filesetref}" />
+		<fileset refid="${samples.runtime.filesetref}" />
+	</path>
+
+	<fileset dir="${sample.base.dir}/lib" id="samples.runtime.packaged.fileset">
+		<include name="ibmjaxrs*.jar" />
+	</fileset>
+
+	<fileset dir="${sample.base.dir}/../../build" id="samples.runtime.dist.fileset">
+		<include name="ibmjaxrs*.jar" />
+	</fileset>
+
+	<fileset dir="${sample.runtime.dir}/lib" id="samples.classpath.packaged.fileset">
+		<include name="abdera-0.4.0-incubating.jar" />
+		<include name="abdera-core-0.4.0-incubating.jar" />
+		<include name="asm-all-3.1.jar" />
+		<include name="axiom-api-1.2.5.jar" />
+		<include name="axiom-impl-1.2.5.jar" />
+		<include name="commons-codec-1.3.jar" />
+		<include name="commons-lang-2.1.jar" />
+		<include name="commons-logging-1.1.1.jar" />
+		<include name="geronimo-annotation_1.0_spec-1.1.1.jar" />
+		<include name="geronimo-servlet_3.0_spec-1.0-EA-20080711.180136-1.jar" />
+		<include name="jaxen-1.1.1.jar" />
+		<include name="jsr311-api-0.11.jar" />
+		<include name="xmlbeans-2.3.0.jar" />
+	</fileset>
+
+	<fileset dir="${sample.base.dir}/../../lib" id="samples.classpath.dist.fileset">
+		<include name="abdera-0.4.0-incubating.jar" />
+		<include name="abdera-core-0.4.0-incubating.jar" />
+		<include name="asm-all-3.1.jar" />
+		<include name="axiom-api-1.2.5.jar" />
+		<include name="axiom-impl-1.2.5.jar" />
+		<include name="commons-codec-1.3.jar" />
+		<include name="commons-lang-2.1.jar" />
+		<include name="commons-logging-1.1.1.jar" />
+		<include name="geronimo-annotation_1.0_spec-1.1.1.jar" />
+		<include name="geronimo-servlet_3.0_spec-1.0-EA-20080711.180136-1.jar" />
+		<include name="jaxen-1.1.1.jar" />
+		<include name="jsr311-api-0.11.jar" />
+		<include name="xmlbeans-2.3.0.jar" />
+	</fileset>
+
+	<target name="packageSampleOnly">
+		<mkdir dir="${sample.runtime.dir}/lib" />
+		<copy todir="${sample.runtime.dir}/lib">
+			<fileset refid="samples.classpath.dist.fileset">
+			</fileset>
+		</copy>
+	</target>
+</project>

Added: incubator/wink/contrib/ibm-jaxrs/samples/context/server/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/context/server/WEB-INF/web.xml?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/context/server/WEB-INF/web.xml (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/context/server/WEB-INF/web.xml Tue Jun 23 05:33:31 2009
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+	<!--
+		This program may be used, executed, copied, modified and distributed
+		without royalty for the purpose of developing, using, marketing, or
+		distributing.
+	-->
+<web-app id="context_sample" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" title="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+	<servlet>
+		<servlet-name>ContextSample</servlet-name>
+		<servlet-class>com.ibm.ws.jaxrs.web.RESTServlet</servlet-class>
+		<init-param>
+			<param-name>javax.ws.rs.Application</param-name>
+			<param-value>com.ibm.ws.jaxrs.sample.context.ScoreboardApplication</param-value>
+		</init-param>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
+	<servlet-mapping>
+		<servlet-name>ContextSample</servlet-name>
+		<url-pattern>/scoreboard/*</url-pattern>
+	</servlet-mapping>
+	<welcome-file-list>
+		<welcome-file>index.html</welcome-file>
+	</welcome-file-list>
+</web-app>

Added: incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/Modifications.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/Modifications.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/Modifications.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/Modifications.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.context;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.ibm.ws.jaxrs.sample.context.xml.BoxScore;
+
+public class Modifications {
+    
+    private static Map<BoxScore, Date> modTimes = new HashMap<BoxScore, Date>();
+
+    public static Date getLastModified(BoxScore bs) {
+        Date d = modTimes.get(bs);
+        if(d == null) {
+            d = new Date();
+            modTimes.put(bs, d);
+        }
+        return d;
+    }
+    
+    public static void updateBoxScore(BoxScore bs, BoxScore updates, String gameNum) {
+        // update box score
+        if(updates.getScore().getHomeScore() != -1)
+            bs.getScore().setHomeScore(updates.getScore().getHomeScore());
+        if(updates.getScore().getVisitorScore() != -1)
+            bs.getScore().setVisitorScore(updates.getScore().getVisitorScore());
+        if(updates.getStats().getHomeTeamHits() != -1)
+            bs.getStats().setHomeTeamHits(updates.getStats().getHomeTeamHits());
+        if(updates.getStats().getHomeTeamErrors() != -1)
+            bs.getStats().setHomeTeamErrors(updates.getStats().getHomeTeamErrors());
+        if(updates.getStats().getHomeTeamWalks() != -1)
+            bs.getStats().setHomeTeamWalks(updates.getStats().getHomeTeamWalks());
+        if(updates.getStats().getHomeTeamDoubles() != -1)
+            bs.getStats().setHomeTeamDoubles(updates.getStats().getHomeTeamDoubles());
+        if(updates.getStats().getHomeTeamTriples() != -1)
+            bs.getStats().setHomeTeamTriples(updates.getStats().getHomeTeamTriples());
+        if(updates.getStats().getHomeTeamHomeRuns() != -1)
+            bs.getStats().setHomeTeamHomeRuns(updates.getStats().getHomeTeamHomeRuns());
+        if(updates.getStats().getHomeTeamHits() != -1)
+            bs.getStats().setHomeTeamHits(updates.getStats().getHomeTeamHits());
+        if(updates.getStats().getVisitorTeamErrors() != -1)
+            bs.getStats().setVisitorTeamErrors(updates.getStats().getVisitorTeamErrors());
+        if(updates.getStats().getVisitorTeamWalks() != -1)
+            bs.getStats().setVisitorTeamWalks(updates.getStats().getVisitorTeamWalks());
+        if(updates.getStats().getVisitorTeamDoubles() != -1)
+            bs.getStats().setVisitorTeamDoubles(updates.getStats().getVisitorTeamDoubles());
+        if(updates.getStats().getVisitorTeamTriples() != -1)
+            bs.getStats().setVisitorTeamTriples(updates.getStats().getVisitorTeamTriples());
+        if(updates.getStats().getVisitorTeamHomeRuns() != -1)
+            bs.getStats().setVisitorTeamHomeRuns(updates.getStats().getVisitorTeamHomeRuns());
+        
+        Date lastModified = new Date();
+        modTimes.put(bs, lastModified);
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ObjectFactory.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ObjectFactory.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ObjectFactory.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.context;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+import com.ibm.ws.jaxrs.sample.context.xml.BoxScore;
+import com.ibm.ws.jaxrs.sample.context.xml.Score;
+
+@XmlRegistry
+public class ObjectFactory {
+
+    public Score createScore() {
+        return new Score();
+    }
+
+    public BoxScore createBoxScore() {
+        return new BoxScore();
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ScoreResource.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ScoreResource.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ScoreResource.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ScoreResource.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.context;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Providers;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import com.ibm.ws.jaxrs.sample.context.xml.BoxScore;
+import com.ibm.ws.jaxrs.sample.context.xml.Score;
+
+@Path("/scoreboard")
+public class ScoreResource {
+
+    @GET
+    @Path("/game/uri")
+    @Produces("text/xml")
+    public Response getGameFromURIInfo(@Context UriInfo uriInfo, @Context Request request) {
+        MultivaluedMap<String, String> mvm = uriInfo.getQueryParameters();
+        String gameNum = mvm.getFirst("gamenum");
+        String type = mvm.getFirst("type");
+        if(gameNum == null || type == null || (!"score".equals(type) && !"boxscore".equals(type)))
+            throw new WebApplicationException(400);
+        return getGame(gameNum, type, request);
+    }
+    
+    @GET
+    @Path("/game/headers")
+    @Produces("text/xml")
+    public Response getGameFromHttpHeaders(@Context HttpHeaders headers, @Context Request request) {
+        List<String> gameNumList = headers.getRequestHeader("X-GameNum");
+        List<String> typeList = headers.getRequestHeader("X-ScoreType");
+        String gameNum = null;
+        String type = null;
+        if(gameNumList != null && gameNumList.size() > 0)
+            gameNum = gameNumList.get(0);
+        if(typeList != null && typeList.size() > 0)
+            type = typeList.get(0);
+        if(!"score".equals(type) && !"boxscore".equals(type))
+            throw new WebApplicationException(400);
+        return getGame(gameNum, type, request);
+    }
+    
+    @GET
+    @Path("/game/servlet")
+    @Produces("text/xml")
+    public Response getGameFromHttpServletRequest(@Context HttpServletRequest requestServlet, 
+                                                  @Context HttpServletResponse responseServlet, 
+                                                  @Context Providers providers,
+                                                  @Context Request request) {
+        String gameNum = requestServlet.getHeader("X-GameNum");
+        String type = requestServlet.getHeader("X-ScoreType");
+        if(gameNum == null || type == null || (!"score".equals(type) && !"boxscore".equals(type)))
+            throw new WebApplicationException(400);
+        BoxScore bs = Scoreboard.getScoreForGame(gameNum);
+        if(bs == null)
+            throw new WebApplicationException(404);
+        
+        ResponseBuilder responseBuilder = request.evaluatePreconditions(getLastModification(bs));
+        if(responseBuilder != null)
+            return responseBuilder.build();
+        
+        Object ret = null;
+        Class<?> c = null;
+        Annotation[] annotations = new Annotation[]{};
+        MediaType mt = new MediaType("text", "xml");
+        if("score".equals(type)) {
+            c = Score.class;
+            ret = bs.getScore();
+            MessageBodyWriter<Score> mbw = providers.getMessageBodyWriter(Score.class, c, annotations, mt);
+            writeResponse(mbw, new Annotation[]{}, mt, (Score)ret, responseServlet);
+        } else {
+            c = BoxScore.class;
+            ret = bs;
+            MessageBodyWriter<BoxScore> mbw = providers.getMessageBodyWriter(BoxScore.class, c, annotations, mt);
+            writeResponse(mbw, new Annotation[]{}, mt, (BoxScore)ret, responseServlet);
+        }
+        
+        return null;
+    }
+    
+    private <T> void writeResponse(MessageBodyWriter<T> mbw, 
+                                   Annotation[] annotations,
+                                   MediaType mediaType,
+                                   T ret,
+                                   HttpServletResponse rs) {
+        try {
+            mbw.writeTo(ret, ret.getClass(), ret.getClass(), annotations, mediaType, null, rs.getOutputStream());
+            rs.flushBuffer();
+        } catch (WebApplicationException e) {
+            throw e;
+        } catch (IOException e) {
+            throw new WebApplicationException(e);
+        }
+    }
+
+    @GET
+    @Path("/game/contextresolver")
+    @Produces("text/xml")
+    public Response getGameFromHttpServletRequestWithJAXBContext(@Context HttpServletRequest requestServlet, 
+                                                  @Context HttpServletResponse responseServlet, 
+                                                  @Context Providers providers,
+                                                  @Context Request request, @Context ContextResolver<JAXBContext> resolver) {
+        String gameNum = requestServlet.getHeader("X-GameNum");
+        String type = requestServlet.getHeader("X-ScoreType");
+        if(gameNum == null || type == null || (!"score".equals(type) && !"boxscore".equals(type)))
+            throw new WebApplicationException(400);
+        BoxScore bs = Scoreboard.getScoreForGame(gameNum);
+        if(bs == null)
+            throw new WebApplicationException(404);
+        
+        ResponseBuilder responseBuilder = request.evaluatePreconditions(getLastModification(bs));
+        if(responseBuilder != null)
+            return responseBuilder.build();
+        
+        Object ret = null;
+        if("score".equals(type))
+            ret = bs.getScore();
+        else
+            ret = bs;
+        
+        JAXBContext context = resolver.getContext(ret.getClass());
+        
+        try {
+            context.createMarshaller().marshal(ret, responseServlet.getOutputStream());
+            responseServlet.flushBuffer();
+        } catch (WebApplicationException e) {
+            throw e;
+        } catch (IOException e) {
+            throw new WebApplicationException(e);
+        } catch (JAXBException e) {
+            throw new WebApplicationException(e);
+        }
+        return null;
+    }
+    
+    public Date getLastModification(BoxScore bs) {
+        return Modifications.getLastModified(bs);
+    }
+    
+    private Response getGame(String gameNum, String type, Request request) {
+        BoxScore bs = Scoreboard.getScoreForGame(gameNum);
+        if(bs == null)
+            throw new WebApplicationException(404);
+        Date lastModified = getLastModification(bs);
+        System.out.println("lastModified: " + lastModified);
+        ResponseBuilder responseBuilder = request.evaluatePreconditions(lastModified);
+        if (responseBuilder != null) {
+            System.out.println("responsebuilder is not null.");
+            return responseBuilder.build();
+        }
+        else {
+            ResponseBuilder rb = null;
+            if("score".equals(type))
+                 rb = Response.ok(bs.getScore());
+            else
+                rb = Response.ok(bs);
+            rb.lastModified(lastModified);
+            return rb.build();
+        }
+    }
+    
+    @GET
+    @Path("/game/{gamenum}")
+    @Produces("text/xml")
+    public Response getGame(@PathParam("gamenum") String gameNum) {
+        BoxScore bs = Scoreboard.getScoreForGame(gameNum);
+        if(bs == null)
+            throw new WebApplicationException(404);
+        return Response.ok(bs).build();
+    }
+    
+    @PUT
+    @Path("/game/{gamenum}")
+    @Consumes("text/xml")
+    public void updateGame(BoxScore boxScore, @PathParam("gamenum") String gameNum) {
+        BoxScore bs = Scoreboard.getScoreForGame(gameNum);
+        if(bs == null)
+            throw new WebApplicationException(404);
+        System.out.println("Found box score");
+        Modifications.updateBoxScore(bs, boxScore, gameNum);
+    }
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/Scoreboard.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/Scoreboard.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/Scoreboard.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/Scoreboard.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.context;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.ibm.ws.jaxrs.sample.context.xml.BoxScore;
+import com.ibm.ws.jaxrs.sample.context.xml.Score;
+import com.ibm.ws.jaxrs.sample.context.xml.Stats;
+
+public final class Scoreboard {
+
+    private final static Map<Integer, BoxScore> scoreboard = new HashMap<Integer, BoxScore>();
+
+    static {
+        /*
+         * load up some sample data
+         */
+        Score s = new Score();
+        s.setHomeTeam("Blue Team");
+        s.setHomeScore(Integer.valueOf(8));
+        s.setVisitorTeam("Red Team");
+        s.setVisitorScore(Integer.valueOf(3));
+        Stats st = new Stats();
+        st.setHomeTeamHits(15);
+        st.setHomeTeamDoubles(3);
+        st.setHomeTeamTriples(1);
+        st.setHomeTeamHomeRuns(3);
+        st.setHomeTeamWalks(5);
+        st.setHomeTeamErrors(1);
+        st.setVisitorTeamHits(6);
+        st.setVisitorTeamDoubles(2);
+        st.setVisitorTeamTriples(0);
+        st.setVisitorTeamHomeRuns(1);
+        st.setVisitorTeamWalks(2);
+        st.setVisitorTeamErrors(0);
+        BoxScore bs = new BoxScore();
+        bs.setScore(s);
+        bs.setStats(st);
+        scoreboard.put(Integer.valueOf(1), bs);
+
+        s = new Score();
+        s.setHomeTeam("A Team");
+        s.setHomeScore(Integer.valueOf(2));
+        s.setVisitorTeam("B Team");
+        s.setVisitorScore(Integer.valueOf(3));
+        st = new Stats();
+        st.setHomeTeamHits(15);
+        st.setHomeTeamDoubles(3);
+        st.setHomeTeamTriples(1);
+        st.setHomeTeamHomeRuns(3);
+        st.setHomeTeamWalks(5);
+        st.setHomeTeamErrors(2);
+        st.setVisitorTeamHits(7);
+        st.setVisitorTeamDoubles(1);
+        st.setVisitorTeamTriples(1);
+        st.setVisitorTeamHomeRuns(2);
+        st.setVisitorTeamWalks(3);
+        st.setVisitorTeamErrors(1);
+        bs = new BoxScore();
+        bs.setScore(s);
+        bs.setStats(st);
+        scoreboard.put(Integer.valueOf(2), bs);
+    }
+
+    public static BoxScore getScoreForGame(String number) {
+        return scoreboard.get(Integer.valueOf(number));
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ScoreboardApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ScoreboardApplication.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ScoreboardApplication.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ScoreboardApplication.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.context;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class ScoreboardApplication extends javax.ws.rs.core.Application {
+
+    @Override
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> clazzes = new HashSet<Class<?>>();
+        clazzes.add(ScoreResource.class);
+        return clazzes;
+    }
+
+    @Override
+    public Set<Object> getSingletons() {
+        Set<Object> s = new HashSet<Object>();
+        s.add(new ScoreboardJAXBContextResolver());
+        return s;
+    }
+
+    
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ScoreboardJAXBContextResolver.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ScoreboardJAXBContextResolver.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ScoreboardJAXBContextResolver.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/ScoreboardJAXBContextResolver.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.context;
+
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import com.ibm.ws.jaxrs.sample.context.xml.BoxScore;
+import com.ibm.ws.jaxrs.sample.context.xml.Score;
+
+@Provider
+public class ScoreboardJAXBContextResolver implements ContextResolver<JAXBContext> {
+
+    public JAXBContext getContext(Class<?> arg0) {
+        if (arg0 == Score.class || arg0 == BoxScore.class)
+            try {
+                return JAXBContext.newInstance(ObjectFactory.class.getPackage()
+                        .getName());
+            } catch (JAXBException e) {
+                return null;
+            }
+        return null;
+    }
+
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/xml/BoxScore.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/xml/BoxScore.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/xml/BoxScore.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/xml/BoxScore.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.context.xml;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+
+@XmlRootElement
+public class BoxScore {
+
+    private Score score;
+    
+    private Stats stats;
+    
+    public Score getScore() {
+        return score;
+    }
+    public void setScore(Score score) {
+        this.score = score;
+    }
+    public Stats getStats() {
+        return stats;
+    }
+    public void setStats(Stats stats) {
+        this.stats = stats;
+    }
+    
+}

Added: incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/xml/Score.java
URL: http://svn.apache.org/viewvc/incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/xml/Score.java?rev=787552&view=auto
==============================================================================
--- incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/xml/Score.java (added)
+++ incubator/wink/contrib/ibm-jaxrs/samples/context/server/src/com/ibm/ws/jaxrs/sample/context/xml/Score.java Tue Jun 23 05:33:31 2009
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ibm.ws.jaxrs.sample.context.xml;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class Score {
+
+    private String homeTeam;
+
+    private Integer homeScore;
+
+    private String visitorTeam;
+
+    private Integer visitorScore;
+
+    public String getHomeTeam() {
+        return homeTeam;
+    }
+
+    public void setHomeTeam(String homeTeam) {
+        this.homeTeam = homeTeam;
+    }
+
+    public Integer getHomeScore() {
+        return homeScore;
+    }
+
+    public void setHomeScore(Integer homeScore) {
+        this.homeScore = homeScore;
+    }
+
+    public String getVisitorTeam() {
+        return visitorTeam;
+    }
+
+    public void setVisitorTeam(String visitorTeam) {
+        this.visitorTeam = visitorTeam;
+    }
+
+    public Integer getVisitorScore() {
+        return visitorScore;
+    }
+
+    public void setVisitorScore(Integer visitorScore) {
+        this.visitorScore = visitorScore;
+    }
+
+}



Mime
View raw message