1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.geronimo.ews.ws4j2ee.toWs;
18
19 import org.apache.commons.logging.Log;
20 import org.apache.commons.logging.LogFactory;
21 import org.apache.geronimo.ews.ws4j2ee.context.ContextValidator;
22 import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
23
24 import java.io.File;
25
26 /***
27 * @author hemapani@opensource.lk
28 */
29 public class Ws4J2eeEmitter {
30 protected static Log log =
31 LogFactory.getLog(Ws4J2eeEmitter.class.getName());
32 protected Ws4J2eeFactory factory;
33 protected J2EEWebServiceContext wscontext;
34 private boolean ejbBased;
35 private boolean verbose;
36
37 public Ws4J2eeEmitter(J2EEWebServiceContext wscontext) {
38 this.wscontext = wscontext;
39 this.factory = wscontext.getFactory();
40 this.ejbBased = wscontext.getMiscInfo().isImplwithEJB();
41 this.verbose = wscontext.getMiscInfo().isVerbose();
42 }
43
44 public void prepareOutPutDir() {
45 File file = new File(wscontext.getMiscInfo().getOutPutPath() + "/META-INF");
46 if (!file.exists())
47 file.mkdirs();
48 }
49
50 public void generatedSEIandtypes() throws GenerationFault {
51 Generator seiAndTypegen =
52 factory.getGenerationFactory().createServerSideWsGenerator(wscontext);
53 seiAndTypegen.generate();
54 }
55
56 public void validateTheContext() throws GenerationFault {
57 ContextValidator cvalidater = new ContextValidator(wscontext);
58 cvalidater.validateWithWSDL();
59 }
60
61 public void generateEJB() throws GenerationFault {
62 if (verbose) {
63 log.info("genarating ejb >>");
64 }
65 Generator ejbgen = factory.getGenerationFactory().createEJBGenerator(wscontext);
66 ejbgen.generate();
67 if (verbose) {
68 log.info("genarating j2ee dd >>");
69 }
70 Generator j2eeContainerDDGen =
71 factory.getGenerationFactory()
72 .createContainerSpecificDDGenerator(wscontext);
73 j2eeContainerDDGen.generate();
74 }
75
76 public void generateWrapperWs() throws GenerationFault {
77 Generator wrapgen =
78 factory.getGenerationFactory().createWrapperWsGenerator(wscontext);
79 wrapgen.generate();
80 }
81
82 public void generatedHandlers() throws GenerationFault {
83 Generator handlerGen =
84 factory.getGenerationFactory().createHandlerGenerator(wscontext);
85 handlerGen.generate();
86 }
87
88 public void generateBuildFile() throws GenerationFault {
89 Generator buildFileGen =
90 factory.getGenerationFactory().createBuildFileGenerator(wscontext);
91 if (buildFileGen != null)
92 buildFileGen.generate();
93 }
94
95 public void executeAnt() throws GenerationFault {
96 if (wscontext.getMiscInfo().isCompile()) {
97 org.apache.geronimo.ews.ws4j2ee.utils.AntExecuter executer
98 = new org.apache.geronimo.ews.ws4j2ee.utils.AntExecuter(wscontext);
99 executer.execute(wscontext.getMiscInfo().getOutPutPath() + "/build.xml");
100 }
101 }
102
103 public void emmit() throws GenerationFault {
104 prepareOutPutDir();
105 generatedSEIandtypes();
106 validateTheContext();
107 if (ejbBased) {
108 generateEJB();
109 }
110 generateWrapperWs();
111 generatedHandlers();
112 generateBuildFile();
113 executeAnt();
114 }
115 }