Home » geronimo-2.2-source-release » org.apache.geronimo.gbean » [javadoc | source]

    1   /**
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   
   18   package org.apache.geronimo.gbean;
   19   
   20   import java.io.Serializable;
   21   import java.util.ArrayList;
   22   import java.util.Arrays;
   23   import java.util.Collections;
   24   import java.util.Iterator;
   25   import java.util.List;
   26   
   27   /**
   28    * Describes an operation on a GBean.
   29    *
   30    * @version $Rev: 564608 $ $Date: 2007-08-10 07:43:14 -0700 (Fri, 10 Aug 2007) $
   31    */
   32   public class GOperationInfo implements Serializable {
   33       private static final long serialVersionUID = -5593225815559931812L;
   34       /**
   35        * The name of this method.
   36        */
   37       private final String name;
   38       
   39       /**
   40        * The return type of this method.
   41        */
   42       private final String returnType;
   43       
   44       /**
   45        * Parameters of this method.
   46        */
   47       private final List parameters;
   48   
   49       /**
   50        * Target method name.
   51        */
   52       private final String methodName;
   53   
   54       public GOperationInfo(String name, String type) {
   55           this(name, name, Collections.EMPTY_LIST, type);
   56       }
   57   
   58       public GOperationInfo(String name, Class[] paramTypes, String returnType) {
   59           this.name = this.methodName = name;
   60           this.returnType = returnType;
   61           String[] args = new String[paramTypes.length];
   62           for (int i = 0; i < args.length; i++) {
   63               args[i] = paramTypes[i].getName();
   64           }
   65           this.parameters = Collections.unmodifiableList(Arrays.asList(args));
   66       }
   67   
   68       public GOperationInfo(String name, String[] paramTypes, String returnType) {
   69           this(name, name, Arrays.asList(paramTypes), returnType);
   70       }
   71       
   72       public GOperationInfo(String name, List parameters, String returnType) {
   73           this(name, name, parameters, returnType);
   74       }
   75       
   76       public GOperationInfo(String name, String methodName, List parameters, String returnType) {
   77           this.name = name;
   78           this.returnType = returnType;
   79           this.methodName = methodName;
   80           this.parameters = Collections.unmodifiableList(new ArrayList(parameters));
   81       }
   82   
   83       public String getName() {
   84           return name;
   85       }
   86       
   87       public String getReturnType() {
   88           return returnType;
   89       }
   90   
   91       public String getMethodName() {
   92           return methodName;
   93       }
   94   
   95       public List getParameterList() {
   96           return parameters;
   97       }
   98   
   99       public String toString() {
  100           return "[GOperationInfo: name=" + name + " parameters=" + parameters + " returnType =" + returnType + "]";
  101       }
  102   
  103       public String toXML() {
  104           StringBuilder xml = new StringBuilder();
  105   
  106           xml.append("<gOperationInfo ");
  107           xml.append("name='" + name + "' ");
  108           xml.append("returnType='" + returnType + "' ");
  109           xml.append(">");
  110   
  111           xml.append("<parameters>");
  112   
  113           for (Iterator loop = parameters.iterator(); loop.hasNext(); ) {
  114               xml.append("<parameterType>" + loop.next().toString() + "</parameterType>");
  115           }
  116   
  117           xml.append("</parameters>");
  118   
  119           xml.append("</gOperationInfo>");
  120   
  121           return xml.toString();
  122       }
  123   }

Home » geronimo-2.2-source-release » org.apache.geronimo.gbean » [javadoc | source]