org.apache.cocoon.servletservice
Class AbstractServletConnection

java.lang.Object
  extended byorg.apache.cocoon.servletservice.AbstractServletConnection
All Implemented Interfaces:
ServletConnection
Direct Known Subclasses:
AbsoluteServletConnection, RelativeServletConnection

public abstract class AbstractServletConnection
extends Object
implements ServletConnection

Since:
1.0.0
Version:
$Id: AbstractServletConnection.java 664526 2008-06-08 17:17:45Z reinhard $

Nested Class Summary
protected static class AbstractServletConnection.NoServletContextAvailableException
          A special exception indicating that there is no servlet context available.
 
Field Summary
protected  boolean connected
          If already connected
protected  ServletContext context
          The current block context
protected  Log logger
          By default we use the logger for this class.
protected  ServletServiceRequest request
          Connection request
protected  ByteArrayOutputStream requestBody
           
protected  ServletServiceResponse response
          Connection response
protected  InputStream responseBody
           
protected  URI uri
           
 
Constructor Summary
AbstractServletConnection()
           
 
Method Summary
 void connect()
          Connect to the servlet service.
 String getContentType()
          Get the mime-type of the servlet-service.
 String getHeaderField(String name)
           
 long getHeaderFieldDate(String name, long defaultValue)
           
 InputStream getInputStream()
          Return an InputStream object to read from the source.
 long getLastModified()
          Get the last modification date of the servlet service.
 OutputStream getOutputStream()
          Returns an output stream that writes as POST to this connection.
 int getResponseCode()
           
 URI getURI()
          Get a URI representing this servlet connection.
protected abstract  void performConnect()
          Access the servlet and fill the response object.
 void setIfModifiedSince(long ifmodifiedsince)
          Set the last modification date if you want to make use of caching.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
By default we use the logger for this class.


request

protected ServletServiceRequest request
Connection request


response

protected ServletServiceResponse response
Connection response


context

protected ServletContext context
The current block context


connected

protected boolean connected
If already connected


requestBody

protected ByteArrayOutputStream requestBody

responseBody

protected InputStream responseBody

uri

protected URI uri
Constructor Detail

AbstractServletConnection

public AbstractServletConnection()
Method Detail

connect

public void connect()
             throws IOException,
                    ServletException
Description copied from interface: ServletConnection
Connect to the servlet service. Establishing a connection means that the service is executed and the response is available.

Specified by:
connect in interface ServletConnection
Throws:
ServletException - Any other problem when connecting to a servlet service.
IOException - The connection to the servlet service can't be established.

performConnect

protected abstract void performConnect()
                                throws ServletException,
                                       IOException
Access the servlet and fill the response object.

Throws:
ServletException
IOException

getInputStream

public InputStream getInputStream()
                           throws IOException,
                                  ServletException
Return an InputStream object to read from the source.

Specified by:
getInputStream in interface ServletConnection
Returns:
An input stream on the servlet service response.
Throws:
IOException
ServletException

setIfModifiedSince

public void setIfModifiedSince(long ifmodifiedsince)
Description copied from interface: ServletConnection
Set the last modification date if you want to make use of caching. This method has to be called before any of the other methods of this interface is invoked.

Specified by:
setIfModifiedSince in interface ServletConnection
Parameters:
ifmodifiedsince - The timestamp of the last known resource.

getLastModified

public long getLastModified()
Description copied from interface: ServletConnection
Get the last modification date of the servlet service.

Specified by:
getLastModified in interface ServletConnection
Returns:
The last modification date of the servlet service.

getContentType

public String getContentType()
Description copied from interface: ServletConnection
Get the mime-type of the servlet-service.

Specified by:
getContentType in interface ServletConnection
Returns:
The mime-type of the servlet-service.

getHeaderFieldDate

public long getHeaderFieldDate(String name,
                               long defaultValue)

getHeaderField

public String getHeaderField(String name)

getResponseCode

public int getResponseCode()
                    throws IOException
Specified by:
getResponseCode in interface ServletConnection
Returns:
The HTTP status code returned by the servlet service.
Throws:
IOException

getOutputStream

public OutputStream getOutputStream()
                             throws IllegalStateException
Returns an output stream that writes as POST to this connection.

Specified by:
getOutputStream in interface ServletConnection
Returns:
an output stream that writes as POST to this connection.
Throws:
IllegalStateException - - if already connected

getURI

public URI getURI()
Description copied from interface: ServletConnection
Get a URI representing this servlet connection.

Specified by:
getURI in interface ServletConnection
Returns:
a URI representing this servlet connection.


Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.