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  package org.apache.geronimo.ews.ws4j2ee.toWs.wrapperWs;
17  
18  import org.apache.commons.logging.Log;
19  import org.apache.commons.logging.LogFactory;
20  import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
21  import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
22  import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
23  import org.apache.geronimo.ews.ws4j2ee.toWs.JavaClassWriter;
24  import org.apache.geronimo.ews.ws4j2ee.toWs.UnrecoverableGenerationFault;
25  import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
26  
27  /***
28   * This class genarate the wrapper Webservice.
29   *
30   * @author Srinath Perera(hemapani@opensource.lk)
31   */
32  public abstract class EJBBasedWrapperClassWriter extends JavaClassWriter {
33      protected static Log log =
34              LogFactory.getLog(WrapperWsGenerator.class.getName());
35      protected String seiName = null;
36      protected EJBContext context;
37  
38      /***
39       * @param j2eewscontext
40       * @param qulifiedName
41       * @throws GenerationFault
42       */
43      public EJBBasedWrapperClassWriter(J2EEWebServiceContext j2eewscontext)
44              throws GenerationFault {
45          super(j2eewscontext, getName(j2eewscontext) + "Impl");
46          context = j2eewscontext.getEJBDDContext();
47          if (context == null) {
48              throw new UnrecoverableGenerationFault("for ejbbased Impl" +
49                      " the EJBDDContext must not be null");
50          }
51      }
52  
53      private static String getName(J2EEWebServiceContext j2eewscontext) {
54          String name = j2eewscontext.getWSDLContext().gettargetBinding().getName();
55          if (name == null) {
56              name = Utils.qName2JavaName(j2eewscontext.getWSDLContext().gettargetBinding().getQName());
57          }
58          return name;
59      }
60  
61      protected String getimplementsPart() {
62          return " implements " + j2eewscontext.getMiscInfo().getJaxrpcSEI() + ",org.apache.geronimo.ews.ws4j2ee.wsutils.ContextAccessible";
63      }
64  
65      protected void writeAttributes() throws GenerationFault {
66          out.write("private " + seiName + " ejb = null;\n");
67          out.write("private org.apache.axis.MessageContext msgcontext;\n");
68      }
69  
70      protected void writeConstructors() throws GenerationFault {
71          out.write("\tpublic " + classname + "(){}\n");
72      }
73  }