Debian Codegraph @

samples/jaxb/README.html

raw
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <!--
3
4 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5
6 Copyright (c) 2010-2012 Oracle and/or its affiliates. All rights reserved.
7
8 The contents of this file are subject to the terms of either the GNU
9 General Public License Version 2 only ("GPL") or the Common Development
10 and Distribution License("CDDL") (collectively, the "License"). You
11 may not use this file except in compliance with the License. You can
12 obtain a copy of the License at
13 http://glassfish.java.net/public/CDDL+GPL_1_1.html
14 or packager/legal/LICENSE.txt. See the License for the specific
15 language governing permissions and limitations under the License.
16
17 When distributing the software, include this License Header Notice in each
18 file and include the License file at packager/legal/LICENSE.txt.
19
20 GPL Classpath Exception:
21 Oracle designates this particular file as subject to the "Classpath"
22 exception as provided by Oracle in the GPL Version 2 section of the License
23 file that accompanied this code.
24
25 Modifications:
26 If applicable, add the following below the License Header, with the fields
27 enclosed by brackets [] replaced by your own identifying information:
28 "Portions Copyright [year] [name of copyright owner]"
29
30 Contributor(s):
31 If you wish your version of this file to be governed by only the CDDL or
32 only the GPL Version 2, indicate your decision by adding "[Contributor]
33 elects to include this software in this distribution under the [CDDL or GPL
34 Version 2] license." If you don't indicate a single choice of license, a
35 recipient has the option to distribute your version of this file under
36 either the CDDL, the GPL Version 2 or to extend the choice of license to
37 its licensees as provided above. However, if you add GPL Version 2 code
38 and therefore, elected the GPL Version 2 license, then the option applies
39 only if the new code is made subject to such option by the copyright
40 holder.
41
42 -->
43 <html>
44 <head>
45 <title>JAXB Example</title>
46 <style type="text/css"><!--
47 .figure { text-align:center;
48 margin: 20px}
49 .cliSample { background-color:lightgray }
50 --></style>
51 </head>
52
53
54 <body>
55 <h1>JAXB Example</h1>
56 <p>This example demonstrates how to use JAXB types with resource classes and the Jersey Client API.
57 <p>The following JAXB types are supported and demonstrated:
58 <ul>
59 <li>JAXB classes annotated with @XmlRootElement</li>
60 <li>JAXB classes annotated with @XmlType</li>
61 <li>JAXBElement&lt;T&gt; where T is a JAXB xml type that may or may not be annotated with @XmlType</li>
62 <li>List&lt;T&gt;, Collection&lt;T&gt;, and T[] where T is a JAXB class annotated with @XmlRootElement or @XmlType</li>
63 </ul>
64 <p>It also shows how to use @XmlHeader annotation to specify the header of the XML
65 responses.
66 <h2>Contents</h2>
67 <p>The mapping of the URI path space is presented in the following table:</p>
68 <table border="1">
69 <tr>
70 <th>URI path</th>
71 <th>Resource class</th>
72 <th>HTTP methods</th>
73 </tr>
74
75 <tr>
76 <td>/jaxb/XmlRootElement</td>
77 <td>JAXBResource</td>
78 <td>GET, POST</td>
79 </tr>
80
81 <tr>
82 <td>/jaxb/XmlRootElementWithHeader</td>
83 <td>JAXBResource</td>
84 <td>GET</td>
85 </tr>
86
87 <tr>
88 <td>/jaxb/JAXBElement</td>
89 <td>JAXBResource</td>
90 <td>GET, POST</td>
91 </tr>
92
93 <tr>
94 <td>/jaxb/XmlType</td>
95 <td>JAXBResource</td>
96 <td>POST</td>
97 </tr>
98
99 <tr>
100 <td>/jaxb/collection/XmlRootElement</td>
101 <td>JAXBCollectionResource</td>
102 <td>GET, POST</td>
103 </tr>
104
105 <tr>
106 <td>/jaxb/collection/XmlType</td>
107 <td>JAXBCollectionResource</td>
108 <td>POST</td>
109 </tr>
110
111 <tr>
112 <td>/jaxb/array/XmlRootElement</td>
113 <td>JAXBArrayResource</td>
114 <td>GET, POST</td>
115 </tr>
116
117 <tr>
118 <td>/jaxb/array/XmlType</td>
119 <td>JAXBArrayResource</td>
120 <td>POST</td>
121 </tr>
122
123 </table>
124
125 <p>JAXB classes annotated with @XmlRootElement may be produced and consumed. JAXB classses annotated with @XmlType can only be consumed
126 hence why only the POST method is supported for the resources associated with XmlType. This is because the JAXB requires enough
127 information to serialize the JAXB instance to a well-formed XML document. The same rules apply to collections of such classes.
128 <p>For the serialization of a Collection of JAXB type, or an array, Jersey will automatically derive the XML root element of the XML document to serialize from the
129 XML name of the JAXB class annoated with @XmlRootElement.
130
131 <h2>Running the Example</h2>
132 <p>Run the example as follows:</p>
133 <blockquote><pre>
134 mvn clean test</pre></blockquote>
135 <p>This deploys the JAXB example using
136 <a href="http://grizzly.java.net/">Grizzly</a> and executes the Jersey Client API using the unit test framework.
137 </p>
138 <p>You can see test classes at <code>src/main/test</code> subdirectory
139 for detailed information how to consume the service using Jersey Client API</p>
140 </body>
141 </html>