summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/sca-java-bindinghttp.html
blob: 62fcef17d2580100fc77242c22e924671a155084 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<!--

    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.
-->


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
    <HEAD>
		<!-- generateKeywords macro -->
	    <META name="description" content="Apache Tuscany">
        <META name="keywords" content="apache, apache tuscany, tuscany, service, services, fabric, soa, service oriented architecture,  sca, service component architecture, das, sdo, csa, ruby, opensource">
		<!-- generateKeywords macro end -->
		
        <LINK type="text/css" rel="stylesheet" href="http://tuscany.apache.org/stylesheets/default.css">
        <LINK rel="SHORTCUT ICON" href="https://cwiki.apache.org/confluence/display/TUSCANY/$images/favicon.ico">   
        <TITLE>Apache Tuscany : SCA Java binding.http</TITLE>
    <META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD>
    
    <BODY onload="init()">
        <!-- topNav macro -->
		<TABLE valign="top" border="0" cellspacing="0" cellpadding="0" width="100%" background="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg">
			<TR>
				<TD valing="top" align="left">
					<A href="https://cwiki.apache.org/confluence/pages/viewpage.action?spaceKey=TUSCANY&title=$siteroot"><IMG src="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg" height="91" width="25" border="0"></A>
				</TD>
				<TD>
					<A href="http://tuscany.apache.org/"><IMG src="http://tuscany.apache.org/images/TuscanyLogo.jpg" border="0"></A>
				</TD>
				
				<TD width="100%">
					&nbsp;
				</TD>

				<!-- Adds the edit page link to the top banner-->
				<TD valign="bottom">
					<DIV style="padding: 2px 10px; margin: 0px;">
						<A href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=98671">
						<IMG src="http://tuscany.apache.org/images/notep_16.gif" height="16" width="16" border="0" align="absmiddle" title="Edit Page"></A>
					</DIV>
				</TD>

			</TR>
		</TABLE>
        <!-- topNav macro end -->

		<!-- breadCrumbs macro -->
		<TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
			<TR class="topBar">
				<TD align="left" valign="middle" class="topBarDiv" nowrap="true" width="100%">
					&nbsp;<A href="home.html" title="Apache Tuscany">Apache Tuscany</A>&nbsp;&gt;&nbsp;<A href="home.html" title="Home">Home</A>&nbsp;&gt;&nbsp;<A href="sca-overview.html" title="SCA Overview">SCA Overview</A>&nbsp;&gt;&nbsp;<A href="sca-java.html" title="SCA Java">SCA Java</A>&nbsp;&gt;&nbsp;<A href="java-sca-documentation-menu.html" title="Java SCA Documentation Menu">Java SCA Documentation Menu</A>&nbsp;&gt;&nbsp;<A href="" title="SCA Java binding.http">SCA Java binding.http</A>
				</TD>
				
				<TD align="right" valign="middle" class="topBarDiv" align="left" nowrap="true">
				<A href="http://mail-archives.apache.org/mod_mbox/tuscany-user">User List</A> | <A href="http://mail-archives.apache.org/mod_mbox/tuscany-dev">Dev List</A> | <A href="http://issues.apache.org/jira/browse/Tuscany">Issue Tracker</A>&nbsp;&nbsp;
				</TD>
			</TR>
		</TABLE>
		<!-- breadCrumbs macro end -->


        <TABLE border="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
            <TR>
                <TD align="left" valign="top">

					<!-- pageContent macro -->
					<DIV id="PageContent">
												
						<DIV class="pagecontent">
							<DIV class="wiki-content">
								<TABLE class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><TBODY><TR>
<TD class="confluenceTd" valign="top" width="15%">
<DIV class="panel" style="background-color: #ECF4D1;border-color: #C3CDA1;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #C3CDA1;background-color: #C3CDA1;"><B>General</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
<P><A href="home.html" title="Home">Home</A><BR>
<A href="http://www.apache.org/licenses/LICENSE-2.0.html" class="external-link" rel="nofollow">License </A><BR>
<A href="sca-java-get-involved.html" title="SCA Java Get Involved">Get Involved</A><BR>
<A href="sca-java-found-a-bug.html" title="SCA Java Found A Bug">Found a Bug?</A></P>
</DIV></DIV>

<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>SCA Java</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
<P><A href="sca-java.html" title="SCA Java">SCA Java Home</A><BR>
<A href="tuscany-dashboard.html" title="Tuscany Dashboard">SCA Dashboard</A><BR>
<A href="java-sca-tools.html" title="Java SCA Tools">Tools </A><BR>
<A href="tuscany-sca-java-faq.html" title="Tuscany SCA Java - FAQ">FAQ</A></P>
</DIV></DIV>

<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>SCA Java 1.x</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
<P><A href="sca-java-releases.html" title="SCA Java Releases">Downloads</A><BR>
<A href="java-sca-documentation-menu.html" title="Java SCA Documentation Menu">Documentation</A><BR>
<A href="https://svn.apache.org/repos/asf/tuscany/sca-java-1.x/trunk/" class="external-link" rel="nofollow">1.x Source Code</A><BR>
<A href="http://tinyurl.com/8rlxd3" class="external-link" rel="nofollow">Roadmap</A></P>
</DIV></DIV>

<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>SCA Java 2.x</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
<P><A href="sca-java-2x-releases.html" title="SCA Java 2.x Releases">Downloads</A><BR>
<A href="http://tuscany.apache.org/documentation-2x/" class="external-link" rel="nofollow">Documentation</A><BR>
<A href="https://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/" class="external-link" rel="nofollow">2.x Source Code</A><BR>
<A href="http://tinyurl.com/8rlxd3" class="external-link" rel="nofollow">Roadmap</A></P>
</DIV></DIV>


<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>Documentation</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
<P><A href="sca-java-user-guide.html" title="SCA Java User Guide">User Guide</A><BR>
<A href="sca-java-architecture-guide.html" title="SCA Java Architecture Guide">Architecture Guide</A><BR>
<A href="sca-java-development-guide.html" title="SCA Java Development Guide">Developer Guide</A><BR>
<A href="sca-java-extension-development-guide.html" title="SCA Java Extension Development Guide">Extension Developer Guide</A></P>
</DIV></DIV>

<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>Resources</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;">
<P><A href="tuscany-sca-java-faq.html" title="Tuscany SCA Java - FAQ">FAQ</A><BR>
<A href="https://svn.apache.org/repos/asf/incubator/tuscany/java/sca" class="external-link" rel="nofollow">Source Code</A></P>
</DIV></DIV>
</TD>
<TD class="confluenceTd" valign="top" width="85%">

<H3><A name="SCAJavabinding.http-%3Cbinding.http%3EIntroduction"></A>&lt;binding.http&gt; Introduction</H3>

<P>The Tuscany Java SCA runtime supports Hyper Text Transfer Protocol (HTTP) using the &lt;binding.http&gt; extension. Tuscany can communicate with services that provide or consume business data objects via the well known actions of HTTP, for example POST, GET, PUT, and DELETE. In HTTP interactions between a client and a server takes place as a series of requests and responses. Information is comunicated by reads and rights over server socket ports. HTTP actions, also known as verbs, are communicated between a client and a server in the requests and responses. Each request and response consists of a header and a body. Typically the header contains the request action name, a URI indicating the location of object of the object of the action, and a number property name and value pairs containing other meta information about the transaction (e.g. body length, modification dates, MIME type, etc.). The body contains the subject of the action, whether it be a text or binary encoding of the data, an error message, or a serialized object.</P>

<P>More information on the HTTP protocol is located at:</P>
<UL>
	<LI><A href="http://tools.ietf.org/html/rfc2616" class="external-link" rel="nofollow">Hyper Text Transfer Protocol</A>.</LI>
</UL>


<P><IMG class="emoticon" src="https://cwiki.apache.org/confluence/images/icons/emoticons/lightbulb_on.gif" height="16" width="16" align="absmiddle" alt="" border="0"> Some of the advanced function described here is included in the Tuscany 1.3.2 and 1.4 releases. The complete timeline of available and future plans is given in the <A href="http://tuscany.apache.org/sca-java-roadmap.html" class="external-link" rel="nofollow">Tuscany Web 2.0 Roadmap</A>. Users should also be aware of the <A href="http://tuscany.apache.org/sca-java-bindingatom.html" class="external-link" rel="nofollow">Atom binding</A> and <A href="http://tuscany.apache.org/sca-java-bindingrss.html" class="external-link" rel="nofollow">RSS binding</A> which sit on top of the HTTP binding, but have additional features and data types associated with the actions.</P>

<P>A Tuscany protocol binding such as the HTTP binding, is a way to fit a common protocol into the Tuscany abstraction and way of doing things. Each binding identifies itself to the Tuscany runtime and states under what conditions it is available. The Tuscany runtime uses the binding to translate invocations and data from the Tuscany world into the world of the protocol and back. So in the case of the HTTP binding, Tuscany uses the HTTP request and response mechanism to share business data between service components.</P>


<H3><A name="SCAJavabinding.http-UsingtheTuscanyHTTPbinding"></A>Using the Tuscany HTTP binding</H3>

<P>The primary use of the HTTP binding is to share resources and services over HTTP over the web in a distributed fashion. Resources are items that have a resource implementation such as web content. Services are items that have data types and a defined business interfaces such as shared collections. Examples of shared collections includes shopping carts, telephone directories, insurance forms, and blog sites. These collections of items can be added, retrieved, updated, and deleted using the 4 basic actions of the HTTP protocol:</P>
<UL>
	<LI>POST (create or add)</LI>
	<LI>GET (retreive or query)</LI>
	<LI>PUT (update)</LI>
	<LI>DELETE (destroy or remove</LI>
</UL>


<P>The simplest way to use the HTTP binding is to declare a resource that can be shared over the web via HTTP and provide an HTTP address where one can access the resource. This resource is declared in an SCA composite file which describes the SCA domain.</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
    &lt;component name=<SPAN class="code-quote">&quot;ResourceServiceComponent&quot;</SPAN>&gt;
        &lt;tuscany:implementation.resource location=<SPAN class="code-quote">&quot;content&quot;</SPAN>/&gt;
    	&lt;service name=<SPAN class="code-quote">&quot;Resource&quot;</SPAN>&gt;
    		&lt;tuscany:binding.http uri=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//localhost:8085/webcontent&quot;</SPAN>/&gt;
</SPAN>    	&lt;/service&gt;
    &lt;/component&gt;
</PRE>
</DIV></DIV>
<P>No further implementation is needed with a resource. It is served on the web like any other static web content.</P>

<P>The HTTP binding can also declare a business service that can be shared over the web and provide an HTTP address where one can access the service. This resource is declared in an SCA composite file which describes the SCA domain.</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
    &lt;component name=<SPAN class="code-quote">&quot;HTTPBindingComponent&quot;</SPAN>&gt;
        &lt;implementation.java class=<SPAN class="code-quote">&quot;org.apache.tuscany.sca.binding.http.TestBindingImpl&quot;</SPAN>/&gt;
    	&lt;service name=<SPAN class="code-quote">&quot;TestBindingImpl&quot;</SPAN>&gt;
    		&lt;tuscany:binding.http uri=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//localhost:8085/httpbinding&quot;</SPAN>/&gt;
</SPAN>    	&lt;/service&gt;
    &lt;/component&gt;
</PRE>
</DIV></DIV>

<H3><A name="SCAJavabinding.http-ExampleHTTPServletandServiceImplementations"></A>Example HTTP Servlet and Service Implementations</H3>

<P>A service that uses the HTTP binding usually implements the javax.servlet.Servlet interface. This interface declares the basic access methods mentioned in the J2EE specification: init, destroy, service, getServletInfo, etc. The Tuscany runtime ensures that the proper method is invoked whenever a service does one of the HTTP actions. For example here is a TestService implemented in the package org.apache.tuscany.sca.binding.http;</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
@Service(Servlet.class)
<SPAN class="code-keyword">public</SPAN> class TestServiceImpl <SPAN class="code-keyword">implements</SPAN> Servlet {

    <SPAN class="code-keyword">public</SPAN> void init(ServletConfig config) <SPAN class="code-keyword">throws</SPAN> ServletException {
    }

    <SPAN class="code-keyword">public</SPAN> void service(ServletRequest request, ServletResponse response) <SPAN class="code-keyword">throws</SPAN> ServletException, IOException {
        response.getOutputStream().print(<SPAN class="code-quote">&quot;&lt;html&gt;&lt;body&gt;&lt;p&gt;Hello from Tuscany HTTP service&lt;/body&gt;&lt;/html&gt;&quot;</SPAN>);
    }

}
</PRE>
</DIV></DIV>

<P>Another way of implementing an HTTP service is to use a collection interface that matches the actions of the HTTP protocol. In this case, the methods must be named post, get, put, and delete. Tuscany ensures that the proper method is invoked via the request and response protocol of HTTP:</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
<SPAN class="code-keyword">public</SPAN> class TestGetImpl {
    
    <SPAN class="code-keyword">public</SPAN> InputStream get(<SPAN class="code-object">String</SPAN> id) {
        <SPAN class="code-keyword">return</SPAN> <SPAN class="code-keyword">new</SPAN> ByteArrayInputStream((<SPAN class="code-quote">&quot;&lt;html&gt;&lt;body&gt;&lt;p&gt;This is the service GET method, item=&quot;</SPAN> + id + <SPAN class="code-quote">&quot;&lt;/body&gt;&lt;/html&gt;&quot;</SPAN>).getBytes());

    }
}
</PRE>
</DIV></DIV>

<P>So using the common verbs of HTTP and Java object serialization, one can implement services and run them anywhere the HTTP protocol is implemented. The service developer or implementer simply creates methods for post, get, put, and delete, and a business collection such as a shopping cart, telephone directory, insurance form, or blog sites can be created. See the Tuscany module binding-http-runtime for complete examples.</P>

<P>Unlike the Atom or RSS bindings, which have defined data types which encapsulate the business objects, the HTTP binding uses Java object serialization for passing business object data back and forth. Thus it is up to the developer or implementer to deserialize the data and reconstitute a business object.</P>

<H3><A name="SCAJavabinding.http-AdvancedFeaturesoftheTuscanyHTTPBinding"></A>Advanced Features of the Tuscany HTTP Binding</H3>

<H4><A name="SCAJavabinding.http-HTTPConditionalActionsandCachingusingETagsandLastModified"></A>HTTP Conditional Actions and Caching using ETags and Last-Modified</H4>

<P>The HTTP specification provides a set of methods for HTTP clients and servers to interact. These methods form the foundation of the World Wide Web. Tuscany implements many of these methods a binding interface to a collection. The main methods are:</P>

<UL>
	<LI>GET - retrieves an item from a collection</LI>
	<LI>POST - creates or adds an item to a collection</LI>
	<LI>PUT - updates or replaces an item in a collection</LI>
	<LI>DELETE - removes an item in a a collection</LI>
</UL>


<P>The HTTP specification (HTTP 1.1 Chapter 13 - Caching) also provides a mechanism by which these methods may be executed conditionally. To perform conditional methods, an HTTP client puts 3 items in the HTTP request header:</P>

<UL>
	<LI>ETag - entity tag, a unique identifier to an item in a collection. Normally created and returned by the server when creating (POST) a new item.</LI>
	<LI>LastModified - an updated field. Normally a string containing a date and time of the last modification of the item.</LI>
	<LI>Predicate - a logical test (e.g. IfModified, IfUnmodified) to use with the ETag and LastModified to determine whether to act.</LI>
</UL>


<P>The complete list of predicates is given in the HTTP specification.</P>

<P>The most common use of conditional methods is to prevent two requests to the server instead of one conditional request. For example, a common scenario is to check if an item has been modified, if not changed update it with a new version, if changed do not update it. With a conditional PUT method (using the IfUnmodifed predicate and a LastModified date), this can be done in one action. Another common use is to prevent multiple GETs of an item to ensure we have a valid copy. Rather than doing a second request of a large item, one can do a conditional GET request (using an IfModified predicate and a LastModified date), and avoid the second request if our object is still valid. The server responds with either a normal response body, or status code 304 (Not Modified), or status code 412 (precondition failed).</P>

<P>Tuscany implements the logic to move these caching items to and from the HTTP request and response headers, and deliver them to the collection implementation. The items are delivered to a user implementation via a serializable object called CacheContext. This object contains the value of the ETag, the LastModified value, and any predicates. It is up to the implementer of a collection to provide the correct server logic to act on these predicates. The CacheContext class is found in found in the Tuscany module package org.apache.tuscany.sca.binding.http.</P>

<P>To implement conditional actions on your service, the developer or implementer implements any of the condional HTTP actions: conditionalPost, conditionalGet, conditionalPut, or conditionalDelete. Tuscany automatically routes a request with proper request header fields (ETag, LastModified, and predicates) to the proper collection method.</P>

<P>For example, the TestBindingCacheImpl class in package org.apache.tuscany.sca.binding.http implements a server collection which pays attention to conditional methods. Notice that this collection implements conditionalGet, conditionalPut, conditionalPost, and conditionalDelete methods as well as get, put, post, delete. The server collection can look at the CacheContext obect to determine whether an item or a status code should be returned. In this example code, the conditionalGet checked the If-Modified predicate and determines whether the item is not modified and if so, throws a NotModifiedException.</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
	<SPAN class="code-keyword">public</SPAN> InputStream conditionalGet(<SPAN class="code-object">String</SPAN> id, HTTPCacheContext cacheContext)
			<SPAN class="code-keyword">throws</SPAN> NotModifiedException, PreconditionFailedException {

		<SPAN class="code-keyword">if</SPAN> (cacheContext != <SPAN class="code-keyword">null</SPAN>) {
			<SPAN class="code-keyword">if</SPAN> (cacheContext.ifModifiedSince) {
				<SPAN class="code-keyword">if</SPAN> ((id.equals(<SPAN class="code-quote">&quot;1&quot;</SPAN>))
						&amp;&amp; (0 &gt; cacheContext.lastModifiedDate
								.compareTo(<SPAN class="code-keyword">new</SPAN> Date())))
					<SPAN class="code-keyword">throw</SPAN> <SPAN class="code-keyword">new</SPAN> NotModifiedException(<SPAN class="code-quote">&quot;item 1 was modified on &quot;</SPAN>
							+ <SPAN class="code-keyword">new</SPAN> Date());
			}
                ...
        ...
</PRE>
</DIV></DIV>

<P>For a full example of all conditional methods and many combinations of predicates, one can look to the module http-binding unit tests to understand how these conditional request work. The HTTPBindingCacheTestCase contains 36 tests of all 4 HTTP conditonal methods. Various predicates are tested with various ETags and LastModified fields. The fields are tested in both the positive and negative cases.</P>

<P>Here is a complete list of the tests:</P>
<UL>
	<LI>testGet() - tests normal GET method of collection, expects item</LI>
	<LI>testConditionalGetIfModifiedNegative() - tests not modified GET, expects item</LI>
	<LI>testConditionalGetIfModifiedPositive() - tests modified GET, expect code 304</LI>
	<LI>testConditionalGetIfUnmodifiedNegative() - tests unmodifed GET, expects item</LI>
	<LI>testConditionalGetIfUnmodifiedPositive() - tests modified GET, expects code 412</LI>
	<LI>testConditionalGetIfMatchNegative() - tests matching GET, expects code 412</LI>
	<LI>testConditionalGetIfMatchPositive() - tests matching GET, expects item</LI>
	<LI>testConditionalGetIfNoneMatchNegative - tests unmatching GET, expects item</LI>
	<LI>testConditionalGetIfNoneMatchPositive() - tests unmatching GET, expects code 412</LI>
</UL>


<P>Similarly, there are 9 tests each for DELETE, POST, and PUT, making a total of 36 test cases.</P>

<H4><A name="SCAJavabinding.http-DifferencesBetweenHTTPBindingCachingandAtomBindingCachinginTuscany"></A>Differences Between HTTP Binding Caching and Atom Binding Caching in Tuscany</H4>

<P>A similar sort of conditional posting is implemented in the Atom Binding. The difference is that the HTTP binding requires an implementer to provide conditional methods. The Atom binding caching uses the Abdera Atom model objects to automatically derive an ETag and a LastModified tags. In the Atom model, the Entry or Feed ID is used to make an item ETag field. The Atom Entry or Feed updated field is used to make an item LastModified field.</P>

<P><IMG class="emoticon" src="https://cwiki.apache.org/confluence/images/icons/emoticons/lightbulb_on.gif" height="16" width="16" align="absmiddle" alt="" border="0"> Use the HTTP binding caching when you are not using Atom Entries and Feeds as your business objects. However, the more flexible HTTP binding caching requires you to implement special conditional methods. Use the Atom binding when you can model your business data in terms of Atom Entries and Feeds. The more constrictive Atom binding caching will derive caching tags from your data model fields.</P>

<H3><A name="SCAJavabinding.http-SecurityPolicysupportinHTTPandWeb2.0Bindings"></A>Security Policy support in HTTP and Web 2.0 Bindings</H3>

<DIV class="panelMacro"><TABLE class="infoMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="https://cwiki.apache.org/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD>work in progress</TD></TR></TABLE></DIV>

<H3><A name="SCAJavabinding.http-Scenarios"></A>Scenarios</H3>

<UL>
	<LI>A Web 2.0 application requires that a user get authenticated before it can access the application.</LI>
	<LI>A Web 2.0 application requires that all communication between client/server be done using SSL.</LI>
	<LI>A given service, exposed using a web 2.0 binding requires user authentication.</LI>
	<LI>A given operation, exposed using a web 2.0 binding requires user authentication.</LI>
</UL>


<H3><A name="SCAJavabinding.http-PolicyInterceptor"></A>Policy Interceptor</H3>

<P>The design approach that is being considered is to inject policy security interceptors, that would properly validate and enforce the security intents.<BR>
The authentication will be done using JAAS modules for authentication, and initially we would support authenticating to a list of username/password supplied by the application or using an LDAP.</P>

<P><SPAN class="image-wrap" style="display: block; text-align: center"><IMG src="sca-java-bindinghttp-security-policy-section.data/high_level_design.jpg" style="border: 0px solid black"></SPAN></P>
</TD></TR></TBODY></TABLE>
							</DIV>
						</DIV>
					</DIV>	
		            <!-- pageContent macro end -->
					
                </TD>
            </TR>
        </TABLE>

		<!-- footer macro -->
				<SCRIPT src="http://www.google-analytics.com/urchin.js" type="text/javascript">
		</SCRIPT>
		<SCRIPT type="text/javascript">
		   _uacct = "UA-1174707-5";
		   urchinTracker();
		</SCRIPT>
		
				<A href="http://www.statcounter.com/" target="_blank"><IMG src="http://c26.statcounter.com/counter.php?sc_project=2619156&java=0&security=94bd7e7d&invisible=0" alt="website stats" border="0"></A>    

		<DIV class="footer">
			Copyright � 2003-2012, The Apache Software Foundation&nbsp;&nbsp;</BR>
                        Apache Tuscany and the Apache Tuscany project logo are trademarks of The Apache Software Foundation.
		</DIV>
		<!-- footer macro end -->

    </BODY>
</HTML>