View Javadoc

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