[jboss-cvs] JBossAS SVN: r105621 - projects/docs/enterprise/EAP/trunk/5.x/Seam_Reference_Guide/en-US.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jun 3 03:01:41 EDT 2010
Author: misty at redhat.com
Date: 2010-06-03 03:01:41 -0400 (Thu, 03 Jun 2010)
New Revision: 105621
Modified:
projects/docs/enterprise/EAP/trunk/5.x/Seam_Reference_Guide/en-US/Webservices.xml
Log:
JBPAPP-4387
Modified: projects/docs/enterprise/EAP/trunk/5.x/Seam_Reference_Guide/en-US/Webservices.xml
===================================================================
--- projects/docs/enterprise/EAP/trunk/5.x/Seam_Reference_Guide/en-US/Webservices.xml 2010-06-03 06:55:34 UTC (rev 105620)
+++ projects/docs/enterprise/EAP/trunk/5.x/Seam_Reference_Guide/en-US/Webservices.xml 2010-06-03 07:01:41 UTC (rev 105621)
@@ -16,7 +16,7 @@
<filename>standard-jaxws-endpoint-config.xml</filename> (a configuration file) should be placed in the <literal>META-INF</literal> directory of the <filename>JAR</filename> file that contains the web service classes. This file contains the following SOAP handler configuration:
</para>
-<programlisting role="XML"><![CDATA[<jaxws-config xmlns="urn:jboss:jaxws-config:2.0"
+<programlisting language="XML" role="XML"><![CDATA[<jaxws-config xmlns="urn:jboss:jaxws-config:2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation=
@@ -54,7 +54,7 @@
Seam uses a SOAP header element in both SOAP request and response messages to carry the conversation ID beteen the consumer and the service. One example of a web service request containing a conversation ID is:
</para>
-<programlisting role="XML"><![CDATA[
+<programlisting language="XML" role="XML"><![CDATA[
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:seam="http://seambay.example.seam.jboss.org/">
@@ -79,7 +79,7 @@
The <literal>conversationId</literal> header element must be qualified with a namespace of <literal>http://www.jboss.org/seam/webservice</literal>, or Seam will be unable to read the conversation ID from the request. An example response to the above request message is:
</para>
-<programlisting role="XML"><![CDATA[<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
+<programlisting language="XML" role="XML"><![CDATA[<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
<env:Header>
<seam:conversationId xmlns:seam='http://www.jboss.org/seam/webservice'>
2
@@ -120,7 +120,7 @@
The example code that follows is from the seamBay example application, which can be found in Seam's <literal>/examples</literal> directory, and follows the recommended strategy outlined in the previous section. First, we will look at the web service class and one of its web service methods:
</para>
-<programlisting role="JAVA"><![CDATA[@Stateless
+<programlisting language="Java" role="JAVA">@Stateless
@WebService(name = "AuctionService", serviceName = "AuctionService")
public class AuctionService implements AuctionServiceRemote
{
@@ -134,7 +134,7 @@
}
// snip
-}]]>
+}
</programlisting>
<para>
Here, the web service is a stateless session bean annotated with the JWS annotations from the <literal>javax.jws</literal> package, as defined by JSR-181. The <literal>@WebService</literal> annotation tells the container that this class implements a web service. The <literal>@WebMethod</literal> annotation on the <literal>login()</literal> method identifies the method as a web service method. The <literal>name</literal> and <literal>serviceName</literal> attributes in the <literal>@WebService</literal> annotation are optional.
@@ -149,27 +149,27 @@
In the following example, the web service method begins a new conversation by delegating to the <literal>AuctionAction.createAuction()</literal> method:
</para>
-<programlisting role="JAVA"><![CDATA[@WebMethod
+<programlisting language="Java" role="JAVA">@WebMethod
public void createAuction(String title, String description, int categoryId)
{
AuctionAction action =
(AuctionAction) Component.getInstance(AuctionAction.class, true);
action.createAuction();
action.setDetails(title, description, categoryId);
-}]]>
+}
</programlisting>
<para>
The code from <literal>AuctionAction</literal> is as follows:
</para>
-<programlisting role="JAVA"><![CDATA[@Begin
+<programlisting language="Java" role="JAVA">@Begin
public void createAuction()
{
auction = new Auction();
auction.setAccount(authenticatedAccount);
auction.setStatus(Auction.STATUS_UNLISTED);
durationDays = DEFAULT_AUCTION_DURATION;
-}]]>
+}
</programlisting>
<para>
Here, we see how web services can participate in long-running conversations by acting as a facade and delegating the real work to a conversational Seam component.
@@ -258,7 +258,7 @@
GET requests using the URI <filename>http://your.hostname/myapp/seam/resource/rest/customer/123</filename>:
</para>
- <programlisting role="JAVA"><![CDATA[@Path("/customer")
+ <programlisting language="Java" role="JAVA">@Path("/customer")
public class MyCustomerResource {
@GET
@@ -268,7 +268,7 @@
return ...;
}
-}]]></programlisting>
+}</programlisting>
<para>
No additional configuration is required, you do not have to edit <literal>web.xml</literal> or any
@@ -276,7 +276,7 @@
First import the <literal>resteasy</literal> namespace into your XML configuration file header:
</para>
- <programlisting role="XML"><![CDATA[<components
+ <programlisting language="XML" role="XML"><![CDATA[<components
xmlns="http://jboss.com/products/seam/components"
xmlns:resteasy="http://jboss.com/products/seam/resteasy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -290,7 +290,7 @@
You can then change the <filename>/rest</filename> prefix as mentioned earlier:
</para>
- <programlisting role="XML"><![CDATA[<resteasy:application resource-path-prefix="/restv1"/>]]></programlisting>
+ <programlisting language="XML" role="XML"><![CDATA[<resteasy:application resource-path-prefix="/restv1"/>]]></programlisting>
<para>
The full base path to your resources is now <filename>/myapp/seam/resource/restv1/{resource}</filename> - note
@@ -304,7 +304,7 @@
classes manually:
</para>
- <programlisting role="XML"><![CDATA[<resteasy:application
+ <programlisting language="XML" role="XML"><![CDATA[<resteasy:application
scan-providers="false"
scan-resources="false"
use-builtin-providers="true">
@@ -344,7 +344,7 @@
Finally, you can configure media type and language URI extensions:
</para>
- <programlisting role="XML"><![CDATA[<resteasy:application>
+ <programlisting language="XML" role="XML"><![CDATA[<resteasy:application>
<resteasy:media-type-mappings>
<key>txt</key><value>text/plain</value>
@@ -380,7 +380,7 @@
Seam component:
</para>
- <programlisting role="JAVA"><![CDATA[@Name("customerResource")
+ <programlisting language="Java" role="JAVA">@Name("customerResource")
@Path("/customer")
public class MyCustomerResource {
@@ -394,7 +394,7 @@
return customerDAO.find(id).getName();
}
-}]]></programlisting>
+}</programlisting>
<para>
An instance of <literal>customerResource</literal> is now handled by Seam when a request hits the
@@ -409,7 +409,7 @@
You can annotate an interface and keep the implementation free from JAX-RS annotations:
</para>
- <programlisting role="JAVA"><![CDATA[@Path("/customer")
+ <programlisting language="Java" role="JAVA">@Path("/customer")
public interface MyCustomerResource {
@GET
@@ -417,9 +417,9 @@
@Produces("text/plain")
public String getCustomer(@PathParam("customerId") int id);
-}]]></programlisting>
+}</programlisting>
- <programlisting role="JAVA"><![CDATA[@Name("customerResource")
+ <programlisting language="Java" role="JAVA">@Name("customerResource")
@Scope(ScopeType.STATELESS)
public class MyCustomerResourceBean implements MyCustomerResource {
@@ -430,7 +430,7 @@
return customerDAO.find(id).getName();
}
-}]]></programlisting>
+}</programlisting>
<para>
You can use <literal>SESSION</literal>-scoped Seam components. By default, the session will however be shortened
@@ -453,7 +453,7 @@
behavior in your configuration file:
</para>
- <programlisting role="XML"><![CDATA[<resteasy:application destroy-session-after-request="false"/>]]></programlisting>
+ <programlisting language="XML" role="XML"><![CDATA[<resteasy:application destroy-session-after-request="false"/>]]></programlisting>
<para>
Every REST HTTP request will now create a new session that will only be removed by timeout or explicit
@@ -500,7 +500,7 @@
<filename>components.xml</filename>:
</para>
- <programlisting role="XML"><![CDATA[<web:authentication-filter url-pattern="/seam/resource/rest/*" auth-type="basic"/>]]></programlisting>
+ <programlisting language="XML" role="XML"><![CDATA[<web:authentication-filter url-pattern="/seam/resource/rest/*" auth-type="basic"/>]]></programlisting>
<para>
See the Seam security chapter on how to write an authentication routine.
@@ -533,7 +533,7 @@
The following example intercepts <emphasis>all</emphasis> HTTP requests and enables Seam exception handling:
</para>
- <programlisting role="XML"><![CDATA[<filter>
+ <programlisting language="XML" role="XML"><![CDATA[<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
</filter>
@@ -549,7 +549,7 @@
<filename>pages.xml</filename> descriptor:
</para>
- <programlisting role="XML"><![CDATA[<exception class="java.lang.UnsupportedOperationException">
+ <programlisting language="XML" role="XML"><![CDATA[<exception class="java.lang.UnsupportedOperationException">
<http-error error-code="501">
<message>The requested operation is not supported</message>
</http-error>
@@ -559,7 +559,7 @@
Custom or checked exceptions are handled the same:
</para>
- <programlisting role="XML"><![CDATA[<exception class="my.CustomException" log="false">
+ <programlisting language="XML" role="XML"><![CDATA[<exception class="my.CustomException" log="false">
<http-error error-code="503">
<message>Service not available: #{org.jboss.seam.handledException.message}</message>
</http-error>
@@ -601,7 +601,7 @@
cases. The following example demonstrates how easily ResourceQuery can be configured:
</para>
- <programlisting role="XML"><![CDATA[<resteasy:resource-query
+ <programlisting language="XML" role="XML"><![CDATA[<resteasy:resource-query
path="/user"
name="userResourceQuery"
entity-class="com.example.User"/>]]></programlisting>
@@ -630,7 +630,7 @@
</listitem>
</itemizedlist>
- <programlisting role="XML"><![CDATA[<resteasy:resource-query
+ <programlisting language="XML" role="XML"><![CDATA[<resteasy:resource-query
path="/user"
name="userResourceQuery"
entity-class="com.example.User"
@@ -640,11 +640,11 @@
Alternatively, if you do not like configuring components using XML, you can set up the component by extension:
</para>
- <programlisting role="JAVA"><![CDATA[@Name("userResourceQuery")
+ <programlisting language="Java" role="JAVA">@Name("userResourceQuery")
@Path("user")
-public class UserResourceQuery extends ResourceQuery<User>
+public class UserResourceQuery extends ResourceQuery<User>
{
-}]]></programlisting>
+}</programlisting>
<para>
Queries are read-only operations, the resource only responds to GET requests. Furthermore, ResourceQuery allows
@@ -760,7 +760,7 @@
Home component and the Java type of the entity identifier property.
</para>
- <programlisting role="XML"><![CDATA[<resteasy:resource-home
+ <programlisting language="XML" role="XML"><![CDATA[<resteasy:resource-home
path="/user"
name="userResourceHome"
entity-home="#{userHome}"
@@ -768,20 +768,20 @@
<para>Again, you can write a subclass of ResourceHome instead of XML:</para>
- <programlisting role="JAVA"><![CDATA[@Name("userResourceHome")
+ <programlisting language="Java" role="JAVA">@Name("userResourceHome")
@Path("user")
-public class UserResourceHome extends ResourceHome<User, Integer>
+public class UserResourceHome extends ResourceHome<User, Integer>
{
@In
- private EntityHome<User> userHome;
+ private EntityHome<User> userHome;
@Override
- public Home<?, User> getEntityHome()
+ public Home<?, User> getEntityHome()
{
return userHome;
}
-}]]></programlisting>
+}</programlisting>
<para>
For more examples of ResourceHome and ResourceQuery components, take a look at the <emphasis>Seam Tasks</emphasis>
@@ -803,7 +803,7 @@
<literal>ResourceRequestEnvironment.ResourceRequest</literal> to emulate HTTP requests/response cycles:
</para>
- <programlisting role="JAVA"><![CDATA[import org.jboss.seam.mock.ResourceRequestEnvironment;
+ <programlisting language="Java" role="JAVA">import org.jboss.seam.mock.ResourceRequestEnvironment;
import org.jboss.seam.mock.EnhancedMockHttpServletRequest;
import org.jboss.seam.mock.EnhancedMockHttpServletResponse;
import static org.jboss.seam.mock.ResourceRequestEnvironment.ResourceRequest;
@@ -817,8 +817,8 @@
public void prepareSharedEnvironment() throws Exception {
sharedEnvironment = new ResourceRequestEnvironment(this) {
@Override
- public Map<String, Object> getDefaultHeaders() {
- return new HashMap<String, Object>() {{
+ public Map<String, Object> getDefaultHeaders() {
+ return new HashMap<String, Object>() {{
put("Accept", "text/plain");
}};
}
@@ -848,7 +848,7 @@
}.run();
}
-}]]></programlisting>
+}</programlisting>
<para>
This test only executes local calls, it does not communicate with the <literal>SeamResourceServlet</literal>
More information about the jboss-cvs-commits
mailing list