View Javadoc

    1   package org.codehaus.xfire.aegis.type.java5;
    2
    3   import javax.xml.namespace.QName;
    4
    5   import org.codehaus.xfire.aegis.type.TypeMapping;
    6   import org.codehaus.xfire.aegis.type.basic.BeanType;
    7   import org.codehaus.xfire.util.NamespaceHelper;
    8   import org.codehaus.xfire.util.ServiceUtils;
    9
    10  public class AnnotatedType
    11      extends BeanType
    12  {
    13      public AnnotatedType(Class clazz)
    14      {
    15          super(new AnnotatedTypeInfo(clazz));
    16
    17          setSchemaType(createSchemaType());
    18      }
    19
    20      public QName createSchemaType()
    21      {
    22          String name = null;
    23          String ns = null;
    24
    25          XmlType xtype = (XmlType) getTypeClass().getAnnotation(XmlType.class);
    26          if (xtype != null)
    27          {
    28              name = xtype.name();
    29              ns = xtype.namespace();
    30          }
    31
    32          String clsName = getTypeClass().getName();
    33          if (name == null || name.length() == 0)
    34              name = ServiceUtils.makeServiceNameFromClassName(getTypeClass());
    35
    36          if (ns == null || ns.length() == 0)
    37              ns = NamespaceHelper.makeNamespaceFromClassName(clsName, "http");
    38
    39          return new QName(ns, name);
    40      }
    41
    42      @Override
    43      public void setTypeMapping(TypeMapping typeMapping)
    44      {
    45          getTypeInfo().setTypeMapping(typeMapping);
    46
    47          super.setTypeMapping(typeMapping);
    48      }
    49
    50
    51  }