Save This Page
Home » openejb-3.1.2-src » org.apache » openejb » server » axis » client » [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   package org.apache.openejb.server.axis.client;
   18   
   19   import org.apache.axis.description.FieldDesc;
   20   import org.apache.axis.description.TypeDesc;
   21   import org.apache.axis.encoding.ser.BaseDeserializerFactory;
   22   import org.apache.axis.encoding.ser.BaseSerializerFactory;
   23   
   24   import javax.xml.namespace.QName;
   25   import javax.xml.rpc.encoding.DeserializerFactory;
   26   import javax.xml.rpc.encoding.SerializerFactory;
   27   import javax.xml.rpc.encoding.TypeMapping;
   28   import java.util.Iterator;
   29   import java.util.List;
   30   
   31   public class TypeInfo {
   32       private final Class clazz;
   33       private final QName qName;
   34       private final Class serFactoryClass;
   35       private final Class deserFactoryClass;
   36       private final boolean canSearchParents;
   37       private final FieldDesc[] fields;
   38   
   39       public static void register(List typeInfo, TypeMapping typeMapping) {
   40           for (Iterator iter = typeInfo.iterator(); iter.hasNext();) {
   41               TypeInfo info = (TypeInfo) iter.next();
   42               info.register(typeMapping);
   43           }
   44       }
   45   
   46       public TypeInfo(Class clazz, QName qName, Class serializerClass, Class deserializerClass, boolean canSearchParents, FieldDesc[] fields) {
   47           this.clazz = clazz;
   48           this.qName = qName;
   49           this.serFactoryClass = serializerClass;
   50           this.deserFactoryClass = deserializerClass;
   51           this.canSearchParents = canSearchParents;
   52           this.fields = fields;
   53       }
   54   
   55       public Class getClazz() {
   56           return clazz;
   57       }
   58   
   59       public QName getqName() {
   60           return qName;
   61       }
   62   
   63       public Class getSerFactoryClass() {
   64           return serFactoryClass;
   65       }
   66   
   67       public Class getDeserFactoryClass() {
   68           return deserFactoryClass;
   69       }
   70   
   71       public boolean isCanSearchParents() {
   72           return canSearchParents;
   73       }
   74   
   75       public FieldDesc[] getFields() {
   76           return fields;
   77       }
   78   
   79       public TypeDesc buildTypeDesc() {
   80           TypeDesc typeDesc = new TypeDesc(clazz, canSearchParents);
   81           typeDesc.setXmlType(qName);
   82           typeDesc.setFields(fields);
   83           return typeDesc;
   84       }
   85   
   86       public void register(TypeMapping typeMapping) {
   87           SerializerFactory ser = BaseSerializerFactory.createFactory(serFactoryClass, clazz, qName);
   88           DeserializerFactory deser = BaseDeserializerFactory.createFactory(deserFactoryClass, clazz, qName);
   89   
   90           typeMapping.register(clazz, qName, ser, deser);
   91       }
   92   
   93       public static class UpdatableTypeInfo {
   94           protected Class clazz;
   95           protected QName qName;
   96           protected Class serializerClass;
   97           protected Class deserializerClass;
   98           protected boolean canSearchParents;
   99           protected FieldDesc[] fields;
  100   
  101           public TypeInfo buildTypeInfo() {
  102               if (null == clazz) {
  103                   throw new IllegalStateException("clazz is null");
  104               } else if (null == qName) {
  105                   throw new IllegalStateException("qName is null");
  106               } else if (null == serializerClass) {
  107                   throw new IllegalStateException("serializerClass is null");
  108               } else if (null == deserializerClass) {
  109                   throw new IllegalStateException("deserializerClass is null");
  110               } else if (null == fields) {
  111                   throw new IllegalStateException("fields is null");
  112               }
  113               return new TypeInfo(clazz, qName, serializerClass, deserializerClass, canSearchParents, fields);
  114           }
  115   
  116           public void setClazz(Class clazz) {
  117               this.clazz = clazz;
  118           }
  119   
  120           public void setDeserializerClass(Class deserializerClass) {
  121               this.deserializerClass = deserializerClass;
  122           }
  123   
  124           public void setFields(FieldDesc[] fields) {
  125               this.fields = fields;
  126           }
  127   
  128           public void setQName(QName name) {
  129               qName = name;
  130           }
  131   
  132           public void setSerializerClass(Class serializerClass) {
  133               this.serializerClass = serializerClass;
  134           }
  135   
  136           public void setCanSearchParents(boolean canSearchParents) {
  137               this.canSearchParents = canSearchParents;
  138           }
  139       }
  140   }

Save This Page
Home » openejb-3.1.2-src » org.apache » openejb » server » axis » client » [javadoc | source]