org.apache.synapse.transport.nhttp
Class DefaultHttpGetProcessor

java.lang.Object
  extended by org.apache.synapse.transport.nhttp.DefaultHttpGetProcessor
All Implemented Interfaces:
HttpGetRequestProcessor

public class DefaultHttpGetProcessor
extends Object
implements HttpGetRequestProcessor

Default http Get processor implementation for Synapse.


Field Summary
protected  ConfigurationContext cfgCtx
           
protected  ServerHandler serverHandler
           
 
Constructor Summary
DefaultHttpGetProcessor()
           
 
Method Summary
protected  void generateServiceDetailsPage(org.apache.http.HttpResponse response, org.apache.http.nio.NHttpServerConnection conn, OutputStream os, String serviceName)
          Generates service details page.
protected  void generateServicesList(org.apache.http.HttpResponse response, org.apache.http.nio.NHttpServerConnection conn, OutputStream os, String servicePath)
          Generates the services list.
protected  void generateWsdl(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response, MessageContext msgContext, org.apache.http.nio.NHttpServerConnection conn, OutputStream os, String serviceName, Map<String,String> parameters, boolean isRestDispatching)
          Generate WSDL.
protected  void generateWsdl2(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response, MessageContext msgContext, org.apache.http.nio.NHttpServerConnection conn, OutputStream os, String serviceName, boolean isRestDispatching)
          Generate WSDL2.
protected  void generateXsd(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response, MessageContext messageCtx, org.apache.http.nio.NHttpServerConnection conn, OutputStream os, String serviceName, Map<String,String> parameters, boolean isRestDispatching)
          Generates Schema.
protected static String getIpAddress()
          Whatever this method returns as the IP is ignored by the actual http/s listener when its getServiceEPR is invoked.
protected  String getServiceName(org.apache.http.HttpRequest request)
          Returns the service name.
protected  String getServicesHTML(String prefix)
          Returns the HTML text for the list of services deployed.
protected  void handleBrowserException(org.apache.http.HttpResponse response, org.apache.http.nio.NHttpServerConnection conn, OutputStream os, String msg, Exception e)
          Handles browser exception.
protected  void handleException(org.apache.http.HttpResponse response, MessageContext msgContext, org.apache.http.nio.NHttpServerConnection conn, OutputStream os, String msg, Exception e)
          Handles exception.
 void init(ConfigurationContext cfgCtx, ServerHandler serverHandler)
          Initialize the HttpGetProcessor
protected static boolean isIP(String hostAddress)
           
protected  boolean isServiceListBlocked(String incomingURI)
          Is the incoming URI is requesting service list and http.block_service_list=true in nhttp.properties
protected  boolean isWSDLProvidedForProxyService(AxisService service)
          Checks whether a wsdl is provided for a proxy service.
 void process(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response, MessageContext msgContext, org.apache.http.nio.NHttpServerConnection conn, OutputStream os, boolean isRestDispatching)
          Process the HTTP GET request.
protected  void processGetAndDelete(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response, MessageContext msgContext, org.apache.http.nio.NHttpServerConnection conn, OutputStream os, String method, boolean isRestDispatching)
          Calls the RESTUtil to process GET and DELETE Request
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cfgCtx

protected ConfigurationContext cfgCtx

serverHandler

protected ServerHandler serverHandler
Constructor Detail

DefaultHttpGetProcessor

public DefaultHttpGetProcessor()
Method Detail

init

public void init(ConfigurationContext cfgCtx,
                 ServerHandler serverHandler)
          throws AxisFault
Description copied from interface: HttpGetRequestProcessor
Initialize the HttpGetProcessor

Specified by:
init in interface HttpGetRequestProcessor
Parameters:
cfgCtx - servers configuration context
serverHandler - dispatching handler
Throws:
AxisFault - if an error occurs

process

public void process(org.apache.http.HttpRequest request,
                    org.apache.http.HttpResponse response,
                    MessageContext msgContext,
                    org.apache.http.nio.NHttpServerConnection conn,
                    OutputStream os,
                    boolean isRestDispatching)
Process the HTTP GET request.

Specified by:
process in interface HttpGetRequestProcessor
Parameters:
request - The HttpRequest
response - The HttpResponse
msgContext - The MessageContext
conn - The NHttpServerConnection
os - The OutputStream
isRestDispatching - Rest dispatching

isServiceListBlocked

protected boolean isServiceListBlocked(String incomingURI)
Is the incoming URI is requesting service list and http.block_service_list=true in nhttp.properties

Parameters:
incomingURI - incoming URI
Returns:
whether to proceed with incomingURI

getServiceName

protected String getServiceName(org.apache.http.HttpRequest request)
Returns the service name.

Parameters:
request - HttpRequest
Returns:
service name as a String

generateServicesList

protected void generateServicesList(org.apache.http.HttpResponse response,
                                    org.apache.http.nio.NHttpServerConnection conn,
                                    OutputStream os,
                                    String servicePath)
Generates the services list.

Parameters:
response - HttpResponse
conn - NHttpServerConnection
os - OutputStream
servicePath - service path of the service

generateServiceDetailsPage

protected void generateServiceDetailsPage(org.apache.http.HttpResponse response,
                                          org.apache.http.nio.NHttpServerConnection conn,
                                          OutputStream os,
                                          String serviceName)
Generates service details page.

Parameters:
response - HttpResponse
conn - NHttpServerConnection
os - OutputStream
serviceName - service name

generateXsd

protected void generateXsd(org.apache.http.HttpRequest request,
                           org.apache.http.HttpResponse response,
                           MessageContext messageCtx,
                           org.apache.http.nio.NHttpServerConnection conn,
                           OutputStream os,
                           String serviceName,
                           Map<String,String> parameters,
                           boolean isRestDispatching)
Generates Schema.

Parameters:
request - HttpRequest
response - HttpResponse
messageCtx - Current MessageContext
conn - NHttpServerConnection
os - OutputStream
serviceName - service name
parameters - url parameters
isRestDispatching - Whether to handle this as REST

generateWsdl2

protected void generateWsdl2(org.apache.http.HttpRequest request,
                             org.apache.http.HttpResponse response,
                             MessageContext msgContext,
                             org.apache.http.nio.NHttpServerConnection conn,
                             OutputStream os,
                             String serviceName,
                             boolean isRestDispatching)
Generate WSDL2.

Parameters:
request - HttpRequest
response - HttpResponse
msgContext - MessageContext
conn - NHttpServerConnection
os - OutputStream
serviceName - service name
isRestDispatching - weather nhttp should do rest dispatching

generateWsdl

protected void generateWsdl(org.apache.http.HttpRequest request,
                            org.apache.http.HttpResponse response,
                            MessageContext msgContext,
                            org.apache.http.nio.NHttpServerConnection conn,
                            OutputStream os,
                            String serviceName,
                            Map<String,String> parameters,
                            boolean isRestDispatching)
Generate WSDL.

Parameters:
request - HttpRequest
response - HttpResponse
msgContext - MessageContext
conn - NHttpServerConnection
os - OutputStream
serviceName - service name
parameters - parameters
isRestDispatching - if restDispatching is on

processGetAndDelete

protected void processGetAndDelete(org.apache.http.HttpRequest request,
                                   org.apache.http.HttpResponse response,
                                   MessageContext msgContext,
                                   org.apache.http.nio.NHttpServerConnection conn,
                                   OutputStream os,
                                   String method,
                                   boolean isRestDispatching)
Calls the RESTUtil to process GET and DELETE Request

Parameters:
request - HttpRequest
response - HttpResponse
msgContext - MessageContext
conn - NHttpServerConnection
os - OutputStream
method - HTTP method, either GET or DELETE
isRestDispatching - weather transport should do rest dispatching

handleException

protected void handleException(org.apache.http.HttpResponse response,
                               MessageContext msgContext,
                               org.apache.http.nio.NHttpServerConnection conn,
                               OutputStream os,
                               String msg,
                               Exception e)
Handles exception.

Parameters:
response - HttpResponse
msgContext - MessageContext
conn - NHttpServerConnection
os - OutputStream
msg - message
e - Exception

handleBrowserException

protected void handleBrowserException(org.apache.http.HttpResponse response,
                                      org.apache.http.nio.NHttpServerConnection conn,
                                      OutputStream os,
                                      String msg,
                                      Exception e)
Handles browser exception.

Parameters:
response - HttpResponse
conn - NHttpServerConnection
os - OutputStream
msg - message
e - Exception

isWSDLProvidedForProxyService

protected boolean isWSDLProvidedForProxyService(AxisService service)
Checks whether a wsdl is provided for a proxy service.

Parameters:
service - AxisService
Returns:
whether the wsdl is provided or not

getIpAddress

protected static String getIpAddress()
                              throws SocketException
Whatever this method returns as the IP is ignored by the actual http/s listener when its getServiceEPR is invoked. This was originally copied from axis2

Returns:
Returns String.
Throws:
SocketException - if the socket can not be accessed

isIP

protected static boolean isIP(String hostAddress)

getServicesHTML

protected String getServicesHTML(String prefix)
Returns the HTML text for the list of services deployed. This can be delegated to another Class as well where it will handle more options of GET messages.

Parameters:
prefix - to be used for the Service names
Returns:
the HTML to be displayed as a String


Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.