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