Author: olamy
Date: Mon Feb 20 18:41:14 2012
New Revision: 1291406
URL: http://svn.apache.org/viewvc?rev=1291406&view=rev
Log:
start adding documentation on server part
Added:
incubator/directmemory/trunk/server/src/
incubator/directmemory/trunk/server/src/site/
incubator/directmemory/trunk/server/src/site/xdoc/
incubator/directmemory/trunk/server/src/site/xdoc/index.xml (with props)
Added: incubator/directmemory/trunk/server/src/site/xdoc/index.xml
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/server/src/site/xdoc/index.xml?rev=1291406&view=auto
==============================================================================
--- incubator/directmemory/trunk/server/src/site/xdoc/index.xml (added)
+++ incubator/directmemory/trunk/server/src/site/xdoc/index.xml Mon Feb 20
18:41:14 2012
@@ -0,0 +1,133 @@
+<?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.
+ -->
+<document>
+ <properties>
+ <title>Apache DirectMemory Server Side</title>
+ <author>Olivier Lamy</author>
+ </properties>
+ <body>
+ <section name="DirectMemory Server">
+ <p>Apache DirectMemory has a server implementation (a servlet) to
provide you a way to store your project remotely and to share those cached
objects with various applications.</p>
+ <p>Server side and client side (Java only) are provided.</p>
+ <p>The exchange are based on http(s) exchange with the following
implementations/format:
+ <ul>
+ <li>JSON format</li>
+ <li>"binary" format: parameters are send via http headers (<b>Not
yet implemented</b>)</li>
+ <li>text/plain format: you can send a text value(json object, xml
etc..), the server will serialize the content and store it for you.(<b>Not yet
implemented</b>)</li>
+ </ul>
+ </p>
+ </section>
+ <section name="Exchange formats">
+ <p>We simply use HTTP method names to resolve the action to proceed and
depends on the Accept or Content-Type headers the format will be different :
+ <ul>
+ <li>GET to retrieve content ${webPath}/${key}</li>
+ <li>DELETE to delete content ${webPath}/${key}</li>
+ <li>PUT to add some content in cache ${webPath}/${key}</li>
+ </ul>
+ </p>
+
+ <subsection name="JSON">
+ <subsection name="PUT Content">
+ <p>
+ JSON Request to put content in cache Content-Type: application/json
+ <source>
+ {"expiresIn":123,
+
"cacheContent":"rO0ABXNyACtvcmcuYXBhY2hlLmRpcmVjdG1lbW9yeS5zZXJ2ZXIuY29tbW9ucy5XaW5l5dYKhxyAjeECAAFMAARuYW1ldAASTGphdmEvbGFuZy9TdHJpbmc7eHB0AAhCb3JkZWF1eA=="}
+ </source>
+ To put this content in DirectMemory Cache Server, just use a PUT
request on path ${webPath}/CacheServlet/${key}.<br/>
+ </p>
+ </subsection>
+ <subsection name="GET Content">
+ <p>Use a GET request on ${webPath}/CacheServlet/${key} and you will
receive the JSON response:
+ <source>
+
+ {"key":"foo","cacheContent":"Zm9vIGJhcg=="}
+
+ </source>
+ <b>If not content is found for the key, you will receive the http
code 204 (No content)</b>
+ </p>
+ </subsection>
+ <subsection name="DELETE Content">
+ <p>Use a DELETE request on ${webPath}/CacheServlet/${key}.
+ Note: if the entry was not available in the server you will
receive a 204 (Not Content)
+ </p>
+ </subsection>
+ </subsection>
+ <subsection name="binary">
+
+ </subsection>
+ <subsection name="text/plain">
+
+ </subsection>
+ </section>
+ <section name="Java Client API">
+ <subsection name="Client Configuration">
+ <p>Before using the client api, you must configure it using the
following pattern:
+ <source>
+ DirectMemoryServerClientConfiguration configuration =
+ new DirectMemoryServerClientConfiguration()
+ .setHost( "localhost" )
+ .setPort( port )
+ .setHttpPath( "/direct-memory/CacheServlet" );
+ DirectMemoryHttpClient httpClient =
HttpClientDirectMemoryHttpClient.instance( configuration );
+ configuration.setDirectMemoryHttpClient( httpClient );
+
+ DirectMemoryServerClient client =
DefaultDirectMemoryServerClient.instance( configuration );
+ </source>
+ Here you have a configured client. Have a look at
DirectMemoryServerClientConfiguration javadoc for advanced options.
+ </p>
+ </subsection>
+ <subsection name="PUT Content">
+ <p>
+ With the Java client is something like:
+ <source>
+ Wine bordeaux = new Wine( "Bordeaux", "very great wine" );
+
+ client.put( new DirectMemoryCacheRequest<Wine>().setObject(
bordeaux ).setKey( "bordeaux" ).setSerializer(
+ SerializerFactory.createNewSerializer() ).setExchangeType(
ExchangeType.JSON ) );
+ </source>
+ </p>
+ </subsection>
+ <subsection name="GET Content">
+ <p>With the Java api:
+ <source>
+ DirectMemoryCacheResponse<Wine> response =
+ client.retrieve(
+ new DirectMemoryCacheRequest().setKey( "bordeaux" )
+ .setSerializer( SerializerFactory.createNewSerializer() )
+ .setExchangeType( ExchangeType.JSON )
+ .setObjectClass( Wine.class ) );
+ </source>
+ You must check the method (response.isFound()) if true retrieve the
object with: Wine wine = response.getResponse();
+ </p>
+ </subsection>
+ <subsection name="DELETE Content">
+ <p>With the Java api:
+ <source>
+ DirectMemoryCacheResponse deleteResponse =
+ client.delete( new
DirectMemoryCacheRequest<Wine>().setKey( "bordeaux" ) );
+ deleteResponse.isDeleted();
+ </source>
+ </p>
+ </subsection>
+ </section>
+ </body>
+</document>
\ No newline at end of file
Propchange: incubator/directmemory/trunk/server/src/site/xdoc/index.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/directmemory/trunk/server/src/site/xdoc/index.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision