01: package org.objectweb.celtix.tools.processors.java2;
02:
03: import java.io.File;
04: import java.util.logging.Level;
05: import java.util.logging.Logger;
06:
07: import org.objectweb.celtix.common.i18n.Message;
08: import org.objectweb.celtix.common.logging.LogUtils;
09: import org.objectweb.celtix.tools.common.Processor;
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.WSDLModel;
14: import org.objectweb.celtix.tools.generators.java2.WSDLGenerator;
15: import org.objectweb.celtix.tools.processors.java2.internal.ClassProcessor;
16: import org.objectweb.celtix.tools.utils.AnnotationUtil;
17:
18: public class JavaToWSDLProcessor implements Processor {
19: private static final Logger LOG = LogUtils
20: .getL7dLogger(JavaToWSDLProcessor.class);
21: private WSDLModel model;
22: private ProcessorEnvironment penv;
23: private Class seiClass;
24:
25: public void process() throws ToolException {
26: try {
27: model = new WSDLModel();
28: } catch (Exception e) {
29: Message msg = new Message("FAIL_TO_BUILD_WSDLMODEL", LOG);
30: LOG.log(Level.SEVERE, msg.toString());
31: throw new ToolException(msg);
32: }
33:
34: init();
35: buildModel(model, getSEIClass());
36: final WSDLGenerator generator = new WSDLGenerator(model, penv);
37: generator.generate();
38: }
39:
40: public void buildModel(WSDLModel wmodel, Class clazz)
41: throws ToolException {
42: final ClassProcessor classproc = new ClassProcessor(clazz,
43: getEnvironment());
44: classproc.process(wmodel);
45: }
46:
47: public void setEnvironment(ProcessorEnvironment env) {
48: this .penv = env;
49: }
50:
51: public ProcessorEnvironment getEnvironment() {
52: return this .penv;
53: }
54:
55: protected void init() {
56: if (penv.get(ToolConstants.CFG_CLASSPATH) != null) {
57: String newCp = (String) penv
58: .get(ToolConstants.CFG_CLASSPATH);
59: String classpath = System.getProperty("java.class.path");
60: System.setProperty("java.class.path", newCp
61: + File.pathSeparator + classpath);
62: }
63: seiClass = AnnotationUtil.loadClass((String) penv
64: .get(ToolConstants.CFG_CLASSNAME),
65: seiClass == null ? JavaToWSDLProcessor.class
66: .getClassLoader() : getSEIClass()
67: .getClassLoader());
68: }
69:
70: protected Class getSEIClass() {
71: return seiClass;
72: }
73:
74: public WSDLModel getModel() {
75: return this.model;
76: }
77:
78: }
|