01: package org.objectweb.celtix.tools.generators.wsdl2;
02:
03: import java.net.URL;
04: import java.util.Iterator;
05: import java.util.Map;
06: import java.util.logging.Logger;
07:
08: import org.objectweb.celtix.common.i18n.Message;
09: 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
20: .getL7dLogger(AbstractGenerator.class);
21: private static final String SERVICE_TEMPLATE = TEMPLATE_BASE
22: + "/service.vm";
23:
24: public ServiceGenerator(JavaModel jmodel, ProcessorEnvironment env) {
25: super (jmodel, env);
26: this .name = ToolConstants.SERVICE_GENERATOR;
27: }
28:
29: public boolean passthrough() {
30: return false;
31: }
32:
33: public void generate() throws ToolException {
34: if (passthrough()) {
35: return;
36: }
37:
38: Map<String, JavaServiceClass> serviceClasses = javaModel
39: .getServiceClasses();
40:
41: Iterator ite = serviceClasses.values().iterator();
42:
43: while (ite.hasNext()) {
44:
45: JavaServiceClass js = (JavaServiceClass) ite.next();
46:
47: String location = (String) env
48: .get(ToolConstants.CFG_WSDLURL);
49: URL url = null;
50: try {
51: url = ProcessorUtil.getWSDLURL(location);
52: } catch (Exception e) {
53: Message message = new Message("FAIL_TO_GET_WSDL", LOG,
54: location);
55: throw new ToolException(message, e);
56: }
57:
58: clearAttributes();
59:
60: setAttributes("service", js);
61: setAttributes("wsdlLocation", url.toString());
62: setCommonAttributes();
63:
64: doWrite(SERVICE_TEMPLATE, parseOutputName(js
65: .getPackageName(), js.getName()));
66: }
67: }
68: }
|