| <?xml version="1.0"?> |
| <!-- |
| 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. |
| --> |
| |
| <document> |
| |
| <properties> |
| <title>JSON Component for GSON</title> |
| <author email="gk@apache.org">Georg Kallidis</author> |
| </properties> |
| |
| <body> |
| |
| <section name="Overview"> |
| <p>The intent of this component is to provide a configurable and customized integration of JSON De-/Seriallizers using <a href="https://github.com/google/gson/">GSON</a>, Jackson 1 and Jackson 2 APIs into Avalon/Turbine. |
| |
| It is written for use in Turbine but it can be used in any container compatible |
| with Avalon's ECM container. There are three implementations |
| <ul> |
| <li>GSONBuilderService and</li> |
| <li>Jackson2MapperService</li> |
| <li>JacksonMapperService</li> |
| </ul> |
| All Services provide basic serialization and deserialization functions for applications. |
| </p> |
| </section> |
| |
| |
| <section name="JSON Service Component with GSON API"> |
| <subsection name="Role Configuration"> |
| <source><![CDATA[ |
| <role |
| name="org.apache.fulcrum.json.JsonService" |
| shorthand="json" |
| default-class="org.apache.fulcrum.json.gson.GSONBuilderService"/> |
| ]]></source> |
| </subsection> |
| <subsection name="Component Configuration"> |
| <table> |
| <tr> |
| <th>Item</th> |
| <th>Datatype</th> |
| <th>Cardinality</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>globalAdapters</td> |
| <td>Complex</td> |
| <td>[0|1]</td> |
| <td> |
| If not set no adapter is set. Otherwise provide for each sub element <code>adapter</code> the class name of the adapter and set the attribute <code>forClass</code> to the class name the adapter should be applied. See the configuration example below. |
| </td> |
| </tr> |
| <tr> |
| <td>dateFormat</td> |
| <td>String</td> |
| <td>[0|*]</td> |
| <td> |
| If set changes the date format. Provided string should be in a Format acceptable to the class <code>java.text.SimpleDateFormat.SimpleDateFormat(String)</code>. The default value is |
| <code>MM/dd/yyyy</code>. |
| </td> |
| </tr> |
| </table> |
| </subsection> |
| |
| <subsection name="Component Configuration Example"> |
| <source><![CDATA[ |
| <json> |
| <dateFormat>MM/dd/yyyy</dateFormat> |
| <globalAdapters>> |
| <adapter forClass="x.y.z.Class">a.b.c.d.AdapterForClassXYZ</adapter--> |
| </globalAdapters> |
| </json> |
| ]]></source> |
| </subsection> |
| |
| <subsection name="Usage"> |
| <p> |
| You get a JSON service from the service like this: |
| </p> |
| |
| <source><![CDATA[ |
| JsonService jsonService = (JsonService)TurbineServices |
| .getInstance().getService(JsonService.ROLE); |
| ]]></source> |
| |
| <p> |
| </p> |
| </subsection> |
| |
| </section> |
| |
| |
| </body> |
| </document> |