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