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