Clover coverage report - Apache Addressing - 1.0
Coverage timestamp: Tue Mar 22 2005 07:59:24 EST
file stats: LOC: 179   Methods: 4
NCLOC: 116   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
JavaAddressingServiceImplWriter.java 0% 0% 0% 0%
coverage
 1   
 /*
 2   
  * Copyright  1999-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   
 
 18   
 package org.apache.axis.message.addressing.tools.wsdl;
 19   
 
 20   
 import org.apache.axis.utils.JavaUtils;
 21   
 import org.apache.axis.utils.Messages;
 22   
 import org.apache.axis.utils.WSDLUtils;
 23   
 import org.apache.axis.wsdl.symbolTable.BindingEntry;
 24   
 import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
 25   
 import org.apache.axis.wsdl.symbolTable.ServiceEntry;
 26   
 import org.apache.axis.wsdl.symbolTable.SymbolTable;
 27   
 import org.apache.axis.wsdl.toJava.Emitter;
 28   
 import org.apache.axis.wsdl.toJava.JavaBindingWriter;
 29   
 import org.apache.axis.wsdl.toJava.JavaClassWriter;
 30   
 import org.apache.axis.wsdl.toJava.Utils;
 31   
 
 32   
 import javax.wsdl.Binding;
 33   
 import javax.wsdl.Port;
 34   
 import javax.wsdl.Service;
 35   
 
 36   
 import java.io.IOException;
 37   
 import java.io.PrintWriter;
 38   
 
 39   
 import java.net.MalformedURLException;
 40   
 import java.net.URL;
 41   
 
 42   
 import java.util.Iterator;
 43   
 import java.util.Map;
 44   
 import java.util.Vector;
 45   
 
 46   
 /**
 47   
  *
 48   
  * @author Jarek Gawor (gawor@mcs.anl.gov)
 49   
  */
 50   
 public class JavaAddressingServiceImplWriter extends JavaClassWriter {
 51   
 
 52   
     private ServiceEntry sEntry;
 53   
     private SymbolTable symbolTable;
 54   
 
 55  0
     protected JavaAddressingServiceImplWriter(
 56   
         Emitter emitter,
 57   
         ServiceEntry sEntry,
 58   
         SymbolTable symbolTable
 59   
     ) {
 60  0
         super(emitter, sEntry.getName() + "AddressingLocator", "service");
 61  0
         this.sEntry = sEntry;
 62  0
         this.symbolTable = symbolTable;
 63   
     }
 64   
 
 65   
     // ctor
 66  0
     protected String getExtendsText() {
 67  0
     return "extends " + this.sEntry.getName() + "Locator ";
 68   
     }
 69   
 
 70   
     /**
 71   
      * Returns "implements <serviceInterface>".
 72   
      */
 73  0
     protected String getImplementsText() {
 74  0
         return "implements " + this.sEntry.getName() + "Addressing ";
 75   
     }
 76   
 
 77   
     /**
 78   
      * Write the body of the service file.
 79   
      */
 80  0
     protected void writeFileBody(PrintWriter pw) throws IOException {
 81  0
         Service service = sEntry.getService();
 82   
 
 83   
         // get ports
 84  0
         Map portMap = service.getPorts();
 85  0
         Iterator portIterator = portMap.values().iterator();
 86   
 
 87   
         // write a get method for each of the ports with a SOAP binding
 88  0
         while (portIterator.hasNext()) {
 89  0
             Port p = (Port) portIterator.next();
 90  0
             Binding binding = p.getBinding();
 91   
 
 92  0
             if (binding == null) {
 93  0
                 throw new IOException(
 94   
                     Messages.getMessage(
 95   
                         "emitFailNoBinding01", new String[] { p.getName() }
 96   
                     )
 97   
                 );
 98   
             }
 99   
 
 100  0
             BindingEntry bEntry =
 101   
                 symbolTable.getBindingEntry(binding.getQName());
 102   
 
 103  0
             if (bEntry == null) {
 104  0
                 throw new IOException(
 105   
                     Messages.getMessage(
 106   
                         "emitFailNoBindingEntry01",
 107   
                         new String[] { binding.getQName().toString() }
 108   
                     )
 109   
                 );
 110   
             }
 111   
 
 112  0
             PortTypeEntry ptEntry =
 113   
                 symbolTable.getPortTypeEntry(binding.getPortType().getQName());
 114   
 
 115  0
             if (ptEntry == null) {
 116  0
                 throw new IOException(
 117   
                     Messages.getMessage(
 118   
                         "emitFailNoPortType01",
 119   
                         new String[] { binding.getPortType().getQName()
 120   
                                               .toString() }
 121   
                     )
 122   
                 );
 123   
             }
 124   
 
 125   
             // If this isn't an SOAP binding, skip it
 126  0
             if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
 127  0
                 continue;
 128   
             }
 129   
 
 130  0
             String portName = p.getName();
 131   
 
 132  0
             if (!JavaUtils.isJavaId(portName)) {
 133  0
                 portName = Utils.xmlNameToJavaClass(portName);
 134   
             }
 135   
 
 136  0
             String stubClass = bEntry.getName() + "Stub";
 137   
 
 138  0
             String bindingType =
 139   
                 (String) bEntry.getDynamicVar(JavaBindingWriter.INTERFACE_NAME);
 140   
 
 141  0
             pw.println(
 142   
                 "    public " + bindingType + " get" + portName +
 143   
                 "(org.apache.axis.message.addressing.EndpointReferenceType reference) " +
 144   
                 "throws javax.xml.rpc.ServiceException {"
 145   
             );
 146  0
         pw.println("\torg.apache.axis.message.addressing.AttributedURI address = reference.getAddress();");
 147   
         
 148  0
         pw.println("\tif (address == null) {");
 149  0
         pw.println("\t\tthrow new javax.xml.rpc.ServiceException(\"No address in EndpointReference\");");
 150  0
         pw.println("\t}");
 151  0
         pw.println("\tjava.net.URL endpoint;");
 152  0
         pw.println("\ttry {");
 153  0
         pw.println("\t\tendpoint = new java.net.URL(address.toString());");
 154  0
         pw.println("\t} catch (java.net.MalformedURLException e) {");
 155  0
             pw.println("\t\tthrow new javax.xml.rpc.ServiceException(e);");
 156  0
         pw.println("\t}");
 157  0
         pw.println("\t" + bindingType + " _stub = " +
 158   
                       "get" + portName + "(endpoint);");
 159  0
         pw.println("\tif (_stub != null) {");
 160  0
             pw.println("\t\torg.apache.axis.message.addressing.AddressingHeaders headers =");
 161  0
             pw.println("\t\t\tnew org.apache.axis.message.addressing.AddressingHeaders();");
 162  0
             pw.println("\t\theaders.setTo(address);");
 163  0
             pw.println("\t\theaders.setReferenceProperties(reference.getProperties());");
 164  0
         pw.println("\t\t((javax.xml.rpc.Stub)_stub)._setProperty(org.apache.axis.message.addressing.Constants.ENV_ADDRESSING_SHARED_HEADERS, headers);");
 165  0
         pw.println("\t}");
 166  0
         pw.println("\treturn _stub;");
 167  0
             pw.println("    }");
 168  0
         pw.println();
 169   
         }
 170   
 
 171  0
         pw.println();
 172   
     }
 173   
 
 174   
     // writeFileBody
 175   
 }
 176   
 
 177   
 
 178   
 // class JavaServiceImplWriter
 179