1 package org.objectweb.celtix.tools.generators.wsdl2; 2 3 import java.net.URL ; 4 import java.util.Iterator ; 5 import java.util.Map ; 6 import java.util.logging.Logger ; 7 8 import org.objectweb.celtix.common.i18n.Message; 9 import org.objectweb.celtix.common.logging.LogUtils; 10 import org.objectweb.celtix.tools.common.ProcessorEnvironment; 11 import org.objectweb.celtix.tools.common.ToolConstants; 12 import org.objectweb.celtix.tools.common.ToolException; 13 import org.objectweb.celtix.tools.common.model.JavaModel; 14 import org.objectweb.celtix.tools.common.model.JavaServiceClass; 15 import org.objectweb.celtix.tools.generators.AbstractGenerator; 16 import org.objectweb.celtix.tools.utils.ProcessorUtil; 17 18 public class ServiceGenerator extends AbstractGenerator { 19 private static final Logger LOG = LogUtils.getL7dLogger(AbstractGenerator.class); 20 private static final String SERVICE_TEMPLATE = TEMPLATE_BASE + "/service.vm"; 21 22 public ServiceGenerator(JavaModel jmodel, ProcessorEnvironment env) { 23 super(jmodel, env); 24 this.name = ToolConstants.SERVICE_GENERATOR; 25 } 26 27 public boolean passthrough() { 28 return false; 29 } 30 31 public void generate() throws ToolException { 32 if (passthrough()) { 33 return; 34 } 35 36 Map <String , JavaServiceClass> serviceClasses = javaModel.getServiceClasses(); 37 38 Iterator ite = serviceClasses.values().iterator(); 39 40 while (ite.hasNext()) { 41 42 JavaServiceClass js = (JavaServiceClass)ite.next(); 43 44 String location = (String )env.get(ToolConstants.CFG_WSDLURL); 45 URL url = null; 46 try { 47 url = ProcessorUtil.getWSDLURL(location); 48 } catch (Exception e) { 49 Message message = new Message("FAIL_TO_GET_WSDL", LOG, location); 50 throw new ToolException(message, e); 51 } 52 53 clearAttributes(); 54 55 setAttributes("service", js); 56 setAttributes("wsdlLocation", url.toString()); 57 setCommonAttributes(); 58 59 doWrite(SERVICE_TEMPLATE, parseOutputName(js.getPackageName(), js.getName())); 60 } 61 } 62 } 63 | Popular Tags |