Clover coverage report - Apache Addressing - 1.0
Coverage timestamp: Tue Mar 22 2005 07:59:24 EST
file stats: LOC: 245   Methods: 19
NCLOC: 136   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
AxisServerSideAddressingHandler.java 0% 0% 0% 0%
coverage
 1   
 /*
 2   
  * Copyright  2004 The Apache Software Foundation.
 3   
  *
 4   
  *  Licensed under the Apache License, Version 2.0 (the "License");
 5   
  *  you may not use this file except in compliance with the License.
 6   
  *  You may obtain a copy of the License at
 7   
  *
 8   
  *      http://www.apache.org/licenses/LICENSE-2.0
 9   
  *
 10   
  *  Unless required by applicable law or agreed to in writing, software
 11   
  *  distributed under the License is distributed on an "AS IS" BASIS,
 12   
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13   
  *  See the License for the specific language governing permissions and
 14   
  *  limitations under the License.
 15   
  *
 16   
  */
 17   
 package org.apache.axis.message.addressing.handler;
 18   
 
 19   
 import org.apache.axis.AxisFault;
 20   
 import org.apache.axis.Handler;
 21   
 import org.apache.axis.Message;
 22   
 import org.apache.axis.MessageContext;
 23   
 import org.apache.axis.message.addressing.AddressingHeaders;
 24   
 import org.apache.axis.message.addressing.Constants;
 25   
 import org.apache.axis.message.addressing.EndpointReference;
 26   
 import org.apache.ws.addressing.handler.ServerSideAddressingHandler;
 27   
 import org.w3c.dom.Document;
 28   
 import org.w3c.dom.Element;
 29   
 
 30   
 import javax.xml.namespace.QName;
 31   
 import javax.xml.rpc.Call;
 32   
 import javax.xml.rpc.JAXRPCException;
 33   
 import javax.xml.rpc.Service;
 34   
 import javax.xml.rpc.handler.soap.SOAPMessageContext;
 35   
 import javax.xml.soap.SOAPBody;
 36   
 import java.util.Hashtable;
 37   
 import java.util.List;
 38   
 
 39   
 /**
 40   
  * Axis-specific server-side WS-Addressing handler.
 41   
  *
 42   
  * @author Davanum Srinivas (dims@yahoo.com)
 43   
  * @author Ian P. Springer
 44   
  */
 45   
 public class AxisServerSideAddressingHandler extends ServerSideAddressingHandler implements Handler
 46   
 {
 47   
 
 48   
     private GenericAxisHandler axisHelperHandler = new GenericAxisHandler( this );
 49   
 
 50   
     /**
 51   
      * @see org.apache.axis.Handler#init()
 52   
      */
 53  0
     public void init()
 54   
     {
 55  0
         axisHelperHandler.init();
 56   
     }
 57   
 
 58   
     /**
 59   
      * @see org.apache.axis.Handler#cleanup()
 60   
      */
 61  0
     public void cleanup()
 62   
     {
 63  0
         axisHelperHandler.cleanup();
 64   
     }
 65   
 
 66   
     /**
 67   
      * @see org.apache.axis.Handler#canHandleBlock(javax.xml.namespace.QName)
 68   
      */
 69  0
     public boolean canHandleBlock( QName qname )
 70   
     {
 71  0
         return ( axisHelperHandler.canHandleBlock( qname ) );
 72   
     }
 73   
 
 74   
     /**
 75   
      * @see org.apache.axis.Handler#setOption(java.lang.String, java.lang.Object)
 76   
      */
 77  0
     public void setOption( String name,
 78   
                            Object value )
 79   
     {
 80  0
         axisHelperHandler.setOption( name, value );
 81   
     }
 82   
 
 83   
     /**
 84   
      * Set a default value for the given option:
 85   
      * if the option is not already set, then set it.
 86   
      * if the option is already set, then do not set it.
 87   
      * <p/>
 88   
      * If this is called multiple times, the first with a non-null value
 89   
      * if 'value' will set the default, remaining calls will be ignored.
 90   
      * <p/>
 91   
      * Returns true if value set (by this call), otherwise false;
 92   
      */
 93  0
     public boolean setOptionDefault( String name,
 94   
                                      Object value )
 95   
     {
 96  0
         return axisHelperHandler.setOptionDefault( name, value );
 97   
     }
 98   
 
 99   
     /**
 100   
      * @see org.apache.axis.Handler#getOption(java.lang.String)
 101   
      */
 102  0
     public Object getOption( String name )
 103   
     {
 104  0
         return axisHelperHandler.getOption( name );
 105   
     }
 106   
 
 107   
     /**
 108   
      * @see org.apache.axis.Handler#getOptions()
 109   
      */
 110  0
     public Hashtable getOptions()
 111   
     {
 112  0
         return axisHelperHandler.getOptions();
 113   
     }
 114   
 
 115   
     /**
 116   
      * @see org.apache.axis.Handler#setOptions(java.util.Hashtable)
 117   
      */
 118  0
     public void setOptions( Hashtable opts )
 119   
     {
 120  0
         axisHelperHandler.setOptions( opts );
 121   
     }
 122   
 
 123   
     /**
 124   
      * @see org.apache.axis.Handler#setName(java.lang.String)
 125   
      */
 126  0
     public void setName( String name )
 127   
     {
 128  0
         axisHelperHandler.setName( name );
 129   
     }
 130   
 
 131   
     /**
 132   
      * @see org.apache.axis.Handler#getName()
 133   
      */
 134  0
     public String getName()
 135   
     {
 136  0
         return axisHelperHandler.getName();
 137   
     }
 138   
 
 139   
     /**
 140   
      * @see org.apache.axis.Handler#getDeploymentData(org.w3c.dom.Document)
 141   
      */
 142  0
     public Element getDeploymentData( Document doc )
 143   
     {
 144  0
         return axisHelperHandler.getDeploymentData( doc );
 145   
     }
 146   
 
 147   
     /**
 148   
      * @see org.apache.axis.Handler#getUnderstoodHeaders()
 149   
      */
 150  0
     public List getUnderstoodHeaders()
 151   
     {
 152  0
         return axisHelperHandler.getUnderstoodHeaders();
 153   
     }
 154   
 
 155   
     /**
 156   
      * @see org.apache.axis.Handler#generateWSDL(org.apache.axis.MessageContext)
 157   
      */
 158  0
     public void generateWSDL( MessageContext msgContext ) throws AxisFault
 159   
     {
 160  0
         axisHelperHandler.generateWSDL( msgContext );
 161   
     }
 162   
 
 163   
     /**
 164   
      * @see org.apache.axis.Handler#invoke(org.apache.axis.MessageContext)
 165   
      */
 166  0
     public void invoke( MessageContext msgContext ) throws AxisFault
 167   
     {
 168  0
         axisHelperHandler.invoke( msgContext );
 169   
     }
 170   
 
 171   
     /**
 172   
      * @see org.apache.axis.Handler#onFault(org.apache.axis.MessageContext)
 173   
      */
 174  0
     public void onFault( MessageContext msgContext )
 175   
     {
 176  0
         axisHelperHandler.onFault( msgContext );
 177   
     }
 178   
 
 179   
     /**
 180   
      * Use the UUID generator that comes with Axis.
 181   
      *
 182   
      * @return a UUID
 183   
      */
 184  0
     protected String generateUUId()
 185   
     {
 186  0
         return axisHelperHandler.generateUUId();
 187   
     }
 188   
 
 189   
     // TODO: not sure if overriding this method is even necessary.
 190  0
     protected void forwardMessage( SOAPMessageContext soapMsgContext, EndpointReference endpointRef )
 191   
     {
 192  0
         try
 193   
         {
 194  0
             Service service = getService( soapMsgContext );
 195  0
             Call call = service.createCall();
 196  0
             call.setTargetEndpointAddress( endpointRef.getAddress().toString() );
 197  0
             ( (org.apache.axis.client.Call) call ).setRequestMessage( (Message) soapMsgContext.getMessage() );
 198  0
             AddressingHeaders addrHeaders = buildAddressingHeadersForMessageForward( soapMsgContext, endpointRef );
 199  0
             call.setProperty( Constants.ENV_ADDRESSING_REQUEST_HEADERS, addrHeaders );
 200  0
             configureCall( call, soapMsgContext );
 201  0
             call.invoke( new Object[0] );
 202  0
             SOAPBody responseBody = soapMsgContext.getMessage().getSOAPPart().getEnvelope().getBody();
 203  0
             removeAllChildElements( responseBody );
 204   
         }
 205   
         catch ( Exception e )
 206   
         {
 207  0
             throw new JAXRPCException( "Failed to forward SOAP message." );
 208   
         }
 209   
 
 210   
     }
 211   
 
 212  0
     protected void setTargetService( SOAPMessageContext soapMsgContext, AddressingHeaders headers )
 213   
             throws Exception
 214   
     {
 215  0
         org.apache.axis.MessageContext axisMsgContext = (org.apache.axis.MessageContext) soapMsgContext;
 216   
         // TODO: why is the below code necessary? - add comments
 217  0
         if ( axisMsgContext.getService() == null &&
 218   
                 axisMsgContext.getTargetService() == null )
 219   
         {
 220  0
             axisMsgContext.setTargetService( getTargetServiceName( headers ) );
 221   
             // This is to ensure the SOAPEnvelope is rebuilt with the right type mappings and
 222   
             // MessageContext is set with the right properties.
 223  0
             if ( axisMsgContext.getTargetService() != null )
 224   
             {
 225  0
                 ( (Message) axisMsgContext.getMessage() ).getSOAPPartAsString();
 226   
             }
 227   
         }
 228   
     }
 229   
 
 230  0
     private AddressingHeaders buildAddressingHeadersForMessageForward( SOAPMessageContext soapMsgContext, EndpointReference endpointRef )
 231   
     {
 232  0
         AddressingHeaders headers = null;
 233  0
         if ( soapMsgContext != null )
 234   
         {
 235  0
             headers = (AddressingHeaders) soapMsgContext.getProperty( Constants.ENV_ADDRESSING_RESPONSE_HEADERS );
 236   
         }
 237  0
         if ( headers == null )
 238   
         {
 239  0
             headers = new AddressingHeaders( endpointRef );
 240   
         }
 241  0
         return headers;
 242   
     }
 243   
 
 244   
 }
 245