1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.geronimo.ews.ws4j2ee.toWs.ws;
17
18 import org.apache.axis.wsdl.symbolTable.SymbolTable;
19 import org.apache.commons.logging.Log;
20 import org.apache.commons.logging.LogFactory;
21 import org.apache.geronimo.ews.jaxrpcmapping.J2eeEmitter;
22 import org.apache.geronimo.ews.jaxrpcmapping.JaxRpcMapper;
23 import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
24 import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
25 import org.apache.geronimo.ews.ws4j2ee.toWs.Generator;
26 import org.apache.geronimo.ews.ws4j2ee.toWs.Ws4J2eeFactory;
27
28 /***
29 * <p>This genarated the Server side SEI and other classes required in the
30 * Axis.</p>
31 * <h3>Service Endpoint Interface</h3>
32 * <p>The JAX-RPC specification requires that a JAX-RPC service endpoint interface must
33 * follow the following rules:</p>
34 * <ol>
35 * <li>Service endpoint interface must extend java.rmi.Remote either directly or indirectly</li>
36 * <li>All methods in the interface must throw java.rmi.RemoteException. Methods may
37 * throw service specific exceptions in addition to the RemoteException.</li>
38 * <li>Method parameters and return types must be the JAX-RPC supported Java types
39 * (refer to the section 5.1, ???JAX-RPC Supported Java Types???). At runtime, values of a
40 * supported Java type must be serializable to and from the corresponding XML
41 * representation.
42 * </li>
43 * <li>Holder classes may be used as method parameters. These Holder classes are either
44 * generated or those packaged in the standard javax.xml.rpc.holders package.</li>
45 * <li>Service endpoint interface must not include constant (as public final static)
46 * declarations. WSDL 1.1 specification does not define any standard representation for
47 * constants in a wsdl:portType definition.</li>
48 * </ol>
49 *
50 * @author Srinath Perera(hemapani@opensource.lk)
51 */
52 public class ServerSideWsGenerator implements Generator {
53 private J2EEWebServiceContext j2eewscontext;
54 private Ws4J2eeFactory factory;
55 protected static Log log =
56 LogFactory.getLog(ServerSideWsGenerator.class.getName());
57
58 public ServerSideWsGenerator(J2EEWebServiceContext j2eewscontext) {
59 this.j2eewscontext = j2eewscontext;
60 factory = j2eewscontext.getFactory();
61 }
62
63 public void generate() throws GenerationFault {
64 try {
65 String mappingfile =
66 j2eewscontext.getMiscInfo().getJaxrpcfile().fileName();
67 String wsdlfile =
68 j2eewscontext.getMiscInfo().getWsdlFile().fileName();
69
70
71
72 J2eeGeneratorFactory genFac = new J2eeGeneratorFactory();
73 J2eeEmitter j2ee = new J2eeEmitter(j2eewscontext, genFac);
74 if (j2eewscontext.getMiscInfo().isVerbose()) {
75 log.info("wsdl file = " + wsdlfile);
76 log.info("jaxrpc mapping file = " + mappingfile);
77 log.info("calling the jaxrpcmapper >> ");
78 }
79 j2ee.setMappingFilePath(mappingfile);
80 j2ee.setOutputDir(j2eewscontext.getMiscInfo().getOutPutPath());
81 j2ee.setServerSide(true);
82 j2ee.setVerbose(j2eewscontext.getMiscInfo().isVerbose());
83
84 j2ee.setHelperWanted(true);
85 j2ee.runServerSide(wsdlfile);
86 SymbolTable axisSymboltable = j2ee.getSymbolTable();
87 j2eewscontext.setWSDLContext(factory.getContextFactory().createWSDLContext(axisSymboltable));
88 JaxRpcMapper mapper = j2ee.getJaxRpcMapper();
89 j2eewscontext.setJAXRPCMappingContext(factory.getContextFactory().createJaxRpcMapperContext(mapper, j2ee));
90 } catch (Exception e) {
91 if (e instanceof RuntimeException) {
92 throw (RuntimeException) e;
93 } else {
94 e.printStackTrace();
95 throw GenerationFault.createGenerationFault(e);
96 }
97 }
98 }
99
100 }