List of Listings

Chapter 1. Introducing the Restlet Framework

Listing 1.1. Creating a server-side resource

Listing 1.2. Serving the Hello server resource

Listing 1.3. Using a client-side resource

Chapter 2. Beginning a Restlet application

Listing 2.1. Providing the inbound root Restlet for the application

Listing 2.2. Setting basic application properties

Listing 2.3. An IP address-blocking filter

Listing 2.4. An IP address-blocking filter

Listing 2.5. Restlet returning common request properties to the client

Listing 2.6. Illustrating URI-based routing

Listing 2.7. Routing to server resources

Listing 2.8. Illustrating server resource lifecycle

Listing 2.9. Illustrating features of client resources

Listing 2.10. Illustrating resource annotations

Listing 2.11. Annotated Java interface for the root resource

Listing 2.12. Implementing the Java annotated resource interface

Listing 2.13. Creating dynamic proxies based on annotated Java interfaces

Listing 2.14. Updating the MailServerApplication

Listing 2.15. Annotated interfaces in the “common” package

Listing 2.16. Implementation of annotated interfaces in the “server” package

Chapter 3. Deploying a Restlet application

Listing 3.1. Creating the MailServerComponent to deploy the application

Listing 3.2. Simple mail client interacting with component resources

Listing 3.3. Adding HTTP tracing to the internal server connector

Listing 3.4. Configuring the virtual hosting

Listing 3.5. Unit test for virtual host

Listing 3.6. Configuring access logging

Listing 3.7. Declarative XML configuration with the Component class

Listing 3.8. Declarative XML configuration with the Spring Framework

Listing 3.9. Declarative XML configuration with the Spring Framework (continued)

Listing 3.10. Running the declarative XML configuration with the Spring Framework

Listing 3.11. Configuration using Spring namespace for Restlet

Listing 3.12. Trimmed down MailServerComponent for Servlet deployment

Listing 3.13. Configuring the Servlet’s web.xml file

Listing 3.14. Configuring the Servlet’s web.xml file

Listing 3.15. An OSGi activator to manage an embedded Restlet server

Listing 3.16. An OSGi activator to manage registration of a virtual host

Listing 3.17. Handling registrations and unregistrations of virtual host services

Chapter 4. Producing and consuming Restlet representations

Listing 4.1. Manipulating the AppendableRepresentation

Listing 4.2. The target XML mail representation

Listing 4.3. Simple test application serving mail resources

Listing 4.4. Mail server resource using the DOM API

Listing 4.5. Mail client retrieving a mail, then storing it again on the same resource

Listing 4.6. Mail server resource using the SAX API

Listing 4.7. Mail server resource using the XPath API

Listing 4.8. Mail server resource-handling XML namespaces

Listing 4.9. W3C XML Schema for the mail XML representations

Listing 4.10. Mail server resource handling XML namespaces

Listing 4.11. XSLT transform sheet

Listing 4.12. Mail server resource applying an XSLT transformation

Listing 4.13. Compiling the XML Schema into JAXB annotated Java classes

Listing 4.14. Compiling the XML Schema into JAXB annotated Java classes

Listing 4.15. The target JSON mail representation

Listing 4.16. Mail server resource using the JSON.org API

Listing 4.17. Mail server resource using the Jackson extension

Listing 4.18. The target HTML mail representation

Listing 4.19. The FreeMarker template HTML representation

Listing 4.20. Mail server resource using the FreeMarker extension

Listing 4.21. The Velocity template HTML representation

Listing 4.22. Mail server resource using the Velocity extension

Listing 4.23. Mail server resource supporting XML and JSON representations

Listing 4.24. Mail client selecting XML, then JSON variants

Listing 4.25. Annotated MailResource interface

Listing 4.26. Mail server resource implementing the MailResource interface

Listing 4.27. Mail server resource implementing the MailResource interface

Chapter 5. Securing a Restlet application

Listing 5.1. Basic configuration of the keystore on a server

Listing 5.2. Basic configuration of the truststore on a client

Listing 5.3. Two-step client authentication with HTTP Digest

Listing 5.4. Protecting resources with HTTP Basic

Listing 5.5. Protecting resources with HTTP Digest

Listing 5.6. Protecting resources with trusted TLS client certificates

Listing 5.7. Defining a memory realm with users and mapping to roles

Listing 5.8. Example policy file

Listing 5.9. Running sensitive code as a privileged user

Listing 5.10. Example HTTP response with Content-MD5 header

Listing 5.11. Example setting the representation’s digest as a sender

Chapter 6. Documenting and versioning a Restlet application

Listing 6.1. Sample WADL description

Listing 6.2. WADL-enhanced account resource with a dynamic name and description

Listing 6.3. WADL-enhanced accounts server resource with static documentation

Listing 6.4. WADL-enhanced root server resource

Listing 6.5. Improved WADL application description

Listing 6.6. WADL resource description snippet

Chapter 7. Enhancing a Restlet application with recipes and best practices

Listing 7.1. Mail-editing form as a FreeMarker template

Listing 7.2. Simple cookie-based authentication

Listing 7.3. Guarding the mail server application

Listing 7.4. Authenticating the mail client

Listing 7.5. Merging websites and web services

Listing 7.6. Changing the default status service

Listing 7.7. Content of the MailStatus.ftl template

Listing 7.8. Adding a file attachment field to the mail-editing form

Listing 7.9. Adding a file attachment field to the mail-editing form

Listing 7.10. Account feed server resource

Listing 7.11. Consuming account feeds

Listing 7.12. Redirecting clients to a new permanent location

Listing 7.13. Server program listing hosting the old and new resource

Listing 7.14. Client-side redirection with attribute extraction

Listing 7.15. Server Resource that generates dynamic content

Listing 7.16. Requesting parts of a resource

Listing 7.17. Server resource that time-stamps its representation

Listing 7.18. Retrieving caching metadata

Listing 7.19. Updating a resource with conditions

Listing 7.20. Optimizing internal calls with the server dispatcher

Listing 7.21. Optimizing internal calls with the RIAP pseudoprotocol

Listing 7.22. XML request for the JDBC client connector

Chapter 8. Using Restlet with cloud platforms

Listing 8.1. Configuring Google Accounts-based authentication in Restlet applications

Listing 8.2. Content of the ServiceDefinition.csdef file

Listing 8.3. Commands to execute at the hosted service startup

Listing 8.4. Content returned by a simple OData request

Listing 8.5. Adding a category with OData using an HTTP POST request

Listing 8.6. Response received for the add request for a category

Listing 8.7. Ant script for launching the OData generation of Restlet

Listing 8.8. Implementing the CRUD methods to manage entities of OData service

Listing 8.9. Using AWS S3 security in HTTP requests with Restlet

Listing 8.10. Remotely create and delete S3 resources using Restlet

Listing 8.11. Using Azure secret key security in HTTP requests with Restlet

Listing 8.12. Creating a table using the REST API of the table service

Listing 8.13. Global configuration of the SDC agent

Listing 8.14. Rule configuration to access intranet applications through SDC agent

Chapter 9. Using Restlet in browsers and mobile devices

Listing 9.1. Using RequestBuilder class

Listing 9.2. Using the ClientResource class within GWT client side

Listing 9.3. Parsing JSON content received through the representation

Listing 9.4. Parsing XML content received through the representation

Listing 9.5. Using deferred binding support of Restlet to execute REST call

Listing 9.6. Using jsonp within GWT

Listing 9.7. Using cross-domain header in a Restlet response

Listing 9.8. Configure both GWT-RPC and Restlet support

Listing 9.9. Implementation of the SimpleWebMailActivity class

Listing 9.10. Starting a Restlet server within an Android activity

Chapter 10. Embracing hypermedia and the Semantic Web

Listing 10.1. Creating an RDF graph with Restlet RDF extension

Listing 10.2. Setting up the domain model with user accounts

Listing 10.3. Enhanced Account annotated resource interface

Listing 10.4. Enhanced Account server resource

Listing 10.5. Generic FOAF browser

Appendix B. Installing the Restlet Framework

Listing B.1. Sample HelloWord program

Listing B.2. Unit test for RootServerResource

Listing B.3. Unit test for Application

Listing B.4. Unit test for Component

Listing B.5. Unit test for Component

Listing B.6. Programmatically configuring the log level

Listing B.7. Programmatically enable log traces for MSIE clients

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.233.205