gdaniels    2003/02/19 13:25:33

  Modified:    java/src/org/apache/axis/description TypeDesc.java
  Log:
  Allow dynamic registration of TypeDescs for given classes.
  
  Several limitations right now:
  
  1) Registration is per-JVM (static), not per engine - is this OK?
  
  2) Potential Classloader problems?  Should we be doing this by
  class name and not Class object?
  
  Revision  Changes    Path
  1.26      +22 -0     xml-axis/java/src/org/apache/axis/description/TypeDesc.java
  
  Index: TypeDesc.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/TypeDesc.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- TypeDesc.java     8 Jan 2003 16:06:29 -0000       1.25
  +++ TypeDesc.java     19 Feb 2003 21:25:33 -0000      1.26
  @@ -64,6 +64,7 @@
   import java.lang.reflect.Method;
   import java.util.HashMap;
   import java.util.Map;
  +import java.util.Hashtable;
   
   /**
    * A TypeDesc represents a Java<->XML data binding.  It is essentially
  @@ -75,6 +76,9 @@
   public class TypeDesc {
       public static final Class [] noClasses = new Class [] {};
       public static final Object[] noObjects = new Object[] {};
  +    
  +    /** A map of class -> TypeDesc */
  +    private static Map classMap = new Hashtable();
   
       /** Have we already introspected for the special "any" property desc? */
       private boolean lookedForAny = false;
  @@ -82,6 +86,18 @@
       public TypeDesc(Class javaClass) {
           this.javaClass = javaClass;
       }
  +    
  +    /**
  +     * Static function to explicitly register a type description for
  +     * a given class.
  +     * 
  +     * @param cls the Class we're registering metadata about
  +     * @param td the TypeDesc containing the metadata
  +     */ 
  +    public static void registerTypeDescForClass(Class cls, TypeDesc td)
  +    {
  +        classMap.put(cls, td);
  +    }
   
       /**
        * Static function for centralizing access to type metadata for a
  @@ -96,6 +112,12 @@
        */
       public static TypeDesc getTypeDescForClass(Class cls)
       {
  +        // First see if we have one explicitly registered
  +        TypeDesc result = (TypeDesc)classMap.get(cls);
  +        if (result != null) {
  +            return result;
  +        }
  +        
           try {
               Method getTypeDesc = null;
               try {
  
  
  


Reply via email to