com.noelios.restlet.ext.xdb
Class XdbServerServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.noelios.restlet.ext.servlet.ServerServlet
              extended by com.noelios.restlet.ext.xdb.XdbServerServlet
All Implemented Interfaces:
java.io.Serializable, Servlet, ServletConfig

public class XdbServerServlet
extends ServerServlet

Servlet acting like an HTTP server connector. See Developper FAQ #2 for details on how to integrate a Restlet application into a servlet container.
Here is a sample configuration for your Restlet webapp:

 <?xml version="1.0" encoding="ISO-8859-1"?>
 <!DOCTYPE web-app PUBLIC
       "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
       "http://java.sun.com/dtd/web-app_2_3.dtd">
 <web-app>
         <display-name>Restlet adapter</display-name>
 
 
       <!-- Restlet adapter -->
       <servlet>
        <servlet-name>XDBServerServlet</servlet-name>
          <servlet-class>
              com.noelios.restlet.ext.xdb.XDBServerServlet
          </servlet-class>
          <!-- Your application class name -->
          <init-param
            xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd">
            <param-name>org.restlet.application</param-name>
            <param-value>
               SCOTT:org.restlet.example.tutorial.Part12
            </param-value>
            <description>REST Application</description>
          </init-param>
       </servlet>
 
       <!-- Catch all requests -->
       <servlet-mapping>
         <servlet-name>XDBServerServlet</servlet-name>
         <url-pattern>/userapp/*</url-pattern>
       </servlet-mapping>
 </web-app>
 
The enumeration of initParameters of your Servlet will be copied to the "context.parameters" property of your application. This way, you can pass additional initialization parameters to your Restlet application, and share them with existing Servlets.

Author:
Marcelo F. Ochoa (mochoa@ieee.org)
See Also:
J2EE home page, Serialized Form

Constructor Summary
XdbServerServlet()
          Constructor.
 
Method Summary
protected static void closeDbResources(java.sql.Statement statement, java.sql.ResultSet resultSet)
          Closes JDBC resources
protected  HttpServerCall createCall(Server server, HttpServletRequest request, HttpServletResponse response)
          Creates a new Servlet call wrapping a Servlet request/response couple and a Server connector.
protected  HttpServerHelper createServer(HttpServletRequest request)
          Creates the associated HTTP server handling calls.
protected  Client createWarClient(Context appCtx, ServletConfig config)
          Creates a new client for the WAR protocol.
 void destroy()
           
protected static java.sql.Connection getConnection()
          Returns a JDBC connection.
 java.lang.String getInitParameter(java.lang.String name, java.lang.String defaultValue)
          Returns the value of a given initialization parameter, first from the Servlet configuration, then from the Web Application context.
 void init()
           
protected  java.lang.Class<?> loadClass(java.lang.String className)
          Returns a class for a given qualified class name.
 
Methods inherited from class com.noelios.restlet.ext.servlet.ServerServlet
createApplication, createComponent, getApplication, getComponent, getServer, service
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XdbServerServlet

public XdbServerServlet()
Constructor.

Method Detail

closeDbResources

protected static void closeDbResources(java.sql.Statement statement,
                                       java.sql.ResultSet resultSet)
Closes JDBC resources

Parameters:
statement - Any statement.
resultSet - Any result set.

getConnection

protected static java.sql.Connection getConnection()
                                            throws ServletException
Returns a JDBC connection. Works inside or outside the OJVM. outside the it uses db.str, db.usr and db.pwd System's properties

Returns:
A JDBC connection.
Throws:
ServletException

createCall

protected HttpServerCall createCall(Server server,
                                    HttpServletRequest request,
                                    HttpServletResponse response)
Description copied from class: ServerServlet
Creates a new Servlet call wrapping a Servlet request/response couple and a Server connector.

Overrides:
createCall in class ServerServlet
Parameters:
server - The Server connector.
request - The Servlet request.
response - The Servlet response.
Returns:
The new ServletCall instance.

createServer

protected HttpServerHelper createServer(HttpServletRequest request)
Description copied from class: ServerServlet
Creates the associated HTTP server handling calls.

Overrides:
createServer in class ServerServlet
Parameters:
request - The HTTP Servlet request.
Returns:
The new HTTP server handling calls.

createWarClient

protected Client createWarClient(Context appCtx,
                                 ServletConfig config)
Description copied from class: ServerServlet
Creates a new client for the WAR protocol.

Overrides:
createWarClient in class ServerServlet
Parameters:
appCtx - The parent context.
config - The Servlet config.
Returns:
The new WAR client instance.

destroy

public void destroy()
Specified by:
destroy in interface Servlet
Overrides:
destroy in class ServerServlet

loadClass

protected java.lang.Class<?> loadClass(java.lang.String className)
                                throws java.lang.ClassNotFoundException
Description copied from class: ServerServlet
Returns a class for a given qualified class name.

Overrides:
loadClass in class ServerServlet
Parameters:
className - The class name to lookup.
Returns:
The class object.
Throws:
java.lang.ClassNotFoundException

getInitParameter

public java.lang.String getInitParameter(java.lang.String name,
                                         java.lang.String defaultValue)
Description copied from class: ServerServlet
Returns the value of a given initialization parameter, first from the Servlet configuration, then from the Web Application context.

Overrides:
getInitParameter in class ServerServlet
Parameters:
name - The parameter name.
defaultValue - The default to use in case the parameter is not found.
Returns:
The value of the parameter or null.

init

public void init()
          throws ServletException
Overrides:
init in class ServerServlet
Throws:
ServletException


Copyright © 2005-2008 Noelios Technologies.