Coverage Report - org.mule.transport.servlet.ServletConnector
 
Classes in this File Line Coverage Branch Coverage Complexity
ServletConnector
0%
0/21
N/A
0
 
 1  
 /*
 2  
  * $Id: ServletConnector.java 20109 2010-11-07 05:20:30Z mike.schilling $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.transport.servlet;
 12  
 
 13  
 import org.mule.api.MuleContext;
 14  
 import org.mule.api.MuleException;
 15  
 import org.mule.api.MuleMessage;
 16  
 import org.mule.api.config.MuleProperties;
 17  
 import org.mule.api.construct.FlowConstruct;
 18  
 import org.mule.api.endpoint.EndpointURI;
 19  
 import org.mule.api.endpoint.InboundEndpoint;
 20  
 import org.mule.api.lifecycle.InitialisationException;
 21  
 import org.mule.api.transport.MessageReceiver;
 22  
 import org.mule.transport.AbstractConnector;
 23  
 import org.mule.transport.http.HttpConnector;
 24  
 import org.mule.transport.http.HttpsConnector;
 25  
 
 26  
 import java.util.Map;
 27  
 
 28  
 import javax.servlet.http.HttpServletRequest;
 29  
 
 30  
 /**
 31  
  * <code>ServletConnector</code> is a channel adapter between Mule and a servlet
 32  
  * engine. It allows the MuleReceiverServlet to look up components interested in
 33  
  * requests it receives via the servlet container.
 34  
  * 
 35  
  * @see MuleReceiverServlet
 36  
  */
 37  
 
 38  
 public class ServletConnector extends AbstractConnector
 39  
 {
 40  
     public static final String SERVLET = "servlet";
 41  
 
 42  
     /**
 43  
      * This property name is used to store the session id {@link HttpServletRequest} to
 44  
      * the {@link MuleMessage}
 45  
      */
 46  
     public static final String SESSION_ID_PROPERTY_KEY = MuleProperties.PROPERTY_PREFIX + "SESSION_ID";
 47  
 
 48  
     /**
 49  
      * This property name is used to store the character encoding of the {@link HttpServletRequest} to
 50  
      * the {@link MuleMessage}
 51  
      */
 52  
     public static final String CHARACTER_ENCODING_PROPERTY_KEY = MuleProperties.PROPERTY_PREFIX + "CHARACTER_ENCODING";
 53  
 
 54  
     /**
 55  
      * This property name is used to store the content type of the {@link HttpServletRequest} to
 56  
      * the {@link MuleMessage}
 57  
      */
 58  
     public static final String CONTENT_TYPE_PROPERTY_KEY = MuleProperties.PROPERTY_PREFIX + "CONTENT_TYPE";
 59  
 
 60  
     /**
 61  
      * This prefix is used to store parameters from the incoming {@link HttpServletRequest} to
 62  
      * the {@link MuleMessage}.
 63  
      */
 64  
     public static final String PARAMETER_PROPERTY_PREFIX = "REQUEST_PARAMETER_";
 65  
     
 66  
     /**
 67  
      * This property name is used to store a {@link Map} containing all request parameters to the
 68  
      * {@link MuleMessage}.
 69  
      */
 70  
     public static final String PARAMETER_MAP_PROPERTY_KEY = "request.parameters";
 71  
 
 72  
     // The real URL that the servlet container is bound on.
 73  
     // If this is not set the wsdl may not be generated correctly
 74  
     protected String servletUrl;
 75  
     
 76  0
     private boolean useCachedHttpServletRequest = false;
 77  
 
 78  
     public ServletConnector(MuleContext context)
 79  
     {
 80  0
         super(context);
 81  0
         registerSupportedProtocol(HttpConnector.HTTP);
 82  0
         registerSupportedProtocol(HttpsConnector.HTTPS);
 83  0
     }
 84  
 
 85  
 
 86  
     @Override
 87  
     protected void doInitialise() throws InitialisationException
 88  
     {
 89  
         // template method, nothing to do
 90  0
     }
 91  
 
 92  
     @Override
 93  
     protected void doDispose()
 94  
     {
 95  
         // template method
 96  0
     }
 97  
 
 98  
     @Override
 99  
     protected void doConnect() throws Exception
 100  
     {
 101  
         // template method
 102  0
     }
 103  
 
 104  
     @Override
 105  
     protected void doDisconnect() throws Exception
 106  
     {
 107  
         // template method
 108  0
     }
 109  
 
 110  
     @Override
 111  
     protected void doStart() throws MuleException
 112  
     {
 113  
         // template method
 114  0
     }
 115  
 
 116  
     @Override
 117  
     protected void doStop() throws MuleException
 118  
     {
 119  
         // template method
 120  0
     }
 121  
 
 122  
     public String getProtocol()
 123  
     {
 124  0
         return SERVLET;
 125  
     }
 126  
 
 127  
     @Override
 128  
     public Map<Object, MessageReceiver> getReceivers()
 129  
     {
 130  0
         return receivers;
 131  
     }
 132  
 
 133  
     public String getServletUrl()
 134  
     {
 135  0
         return servletUrl;
 136  
     }
 137  
 
 138  
     public void setServletUrl(String servletUrl)
 139  
     {
 140  0
         this.servletUrl = servletUrl;
 141  0
     }
 142  
 
 143  
     @Override
 144  
     protected Object getReceiverKey(FlowConstruct flowConstruct, InboundEndpoint endpoint)
 145  
     {
 146  0
         EndpointURI uri = endpoint.getEndpointURI();
 147  0
         return uri.getAddress();
 148  
     }
 149  
 
 150  
     public boolean isUseCachedHttpServletRequest()
 151  
     {
 152  0
         return useCachedHttpServletRequest;
 153  
     }
 154  
 
 155  
     public void setUseCachedHttpServletRequest(boolean useCachedHttpServletRequest)
 156  
     {
 157  0
         this.useCachedHttpServletRequest = useCachedHttpServletRequest;
 158  0
     }
 159  
 }