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.ejb;
18  
19  import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
20  import org.apache.geronimo.ews.ws4j2ee.context.SEIOperation;
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.JavaInterfaceWriter;
24  
25  import java.util.ArrayList;
26  import java.util.Iterator;
27  
28  /***
29   * This class can be used to write the appropriate EJB Remote interface
30   * class for the given port type.
31   *
32   * @author Rajith Priyanga
33   * @author Srinath Perera
34   * @date Nov 26, 2003
35   */
36  public class EJBRemoteWriter extends JavaInterfaceWriter {
37      private String name;
38      protected EJBContext ejbcontext;
39  
40      /***
41       * Constructs a EJBRemoteWriter.
42       *
43       * @param portType The port type which contains the details.
44       * @throws GenerationFault
45       */
46      public EJBRemoteWriter(J2EEWebServiceContext context, EJBContext ejbcontext) throws GenerationFault {
47          super(context, ejbcontext.getEjbRemoteInterface());
48          this.ejbcontext = ejbcontext;
49      }
50  
51      protected String getExtendsPart() {
52          return " extends javax.ejb.EJBObject";
53      }
54  
55      protected void writeAttributes() throws GenerationFault {
56      }
57  
58      protected void writeMethods() throws GenerationFault {
59          String parmlistStr = "";
60          ArrayList operations = j2eewscontext.getMiscInfo().getSEIOperations();
61          for (int i = 0; i < operations.size(); i++) {
62              SEIOperation op = (SEIOperation) operations.get(i);
63              String returnType = op.getReturnType();
64              if (returnType == null)
65                  returnType = "void";
66              out.write("\tpublic " + returnType + " " + op.getMethodName() + "(");
67              Iterator pas = op.getParameterNames().iterator();
68              boolean first = true;
69              while (pas.hasNext()) {
70                  String name = (String) pas.next();
71                  String type = (String) op.getParameterType(name);
72                  if (first) {
73                      first = false;
74                      out.write(type + " " + name);
75                      parmlistStr = parmlistStr + name;
76                  } else {
77                      out.write("," + type + " " + name);
78                      parmlistStr = "," + name;
79                  }
80              }
81              out.write(") throws java.rmi.RemoteException");
82  //ejb giving problems deploying check this            
83  //			  ArrayList faults = op.getFaults();
84  //			  for (int j = 0; j < faults.size(); j++) {
85  //				  out.write("," + (String) faults.get(i));
86  //			  }
87              out.write(";\n");
88          }
89      }
90  
91  }