User: cgjung  
  Date: 02/04/09 02:59:41

  Modified:    jboss.net/src/main/org/jboss/net/axis Deployment.java
  Added:       jboss.net/src/main/org/jboss/net/axis
                        ParameterizableDeserializer.java
                        ParameterizableDeserializerFactory.java
                        TypeMapping.java
  Log:
  parameterizable typemappings.
  adopted latest subdeployer changes/patches from Mr. Maisey.
  
  Revision  Changes    Path
  1.2       +121 -45   contrib/jboss.net/src/main/org/jboss/net/axis/Deployment.java
  
  Index: Deployment.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/jboss.net/src/main/org/jboss/net/axis/Deployment.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Deployment.java   12 Mar 2002 11:04:45 -0000      1.1
  +++ Deployment.java   9 Apr 2002 09:59:40 -0000       1.2
  @@ -5,7 +5,7 @@
    * See terms of license at gnu.org.
    */
   
  -// $Id: Deployment.java,v 1.1 2002/03/12 11:04:45 cgjung Exp $
  +// $Id: Deployment.java,v 1.2 2002/04/09 09:59:40 cgjung Exp $
   
   package org.jboss.net.axis;
   
  @@ -13,7 +13,12 @@
   import org.apache.axis.deployment.wsdd.WSDDDeployment;
   import org.apache.axis.deployment.wsdd.WSDDService;
   import org.apache.axis.deployment.wsdd.WSDDException;
  +import org.apache.axis.deployment.wsdd.WSDDTypeMapping;
   import org.apache.axis.deployment.DeploymentException;
  +import org.apache.axis.ConfigurationException;
  +import org.apache.axis.encoding.TypeMappingRegistry;
  +import javax.xml.rpc.encoding.DeserializerFactory;
  +
   import org.w3c.dom.Element;
   
   // JAXP
  @@ -29,21 +34,33 @@
    * <br>
    * <h3>Change History</h3>
    * <ul>
  + * <li> jung, 06.04.2002: Introduced parameterizable typemappings. </li>
    * </ul>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Christoph G. Jung</a>
    * @created 09.03.2002
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   
   public class Deployment extends WSDDDeployment {
   
  -     /** 
  -      * holds a map of service q-names to classloaders 
  -      * this map must be initialised lazily, since accesses are already done
  -      * in the super-constructor! Newbies!
  -      */
  -     protected Map service2ClassLoader;
  -              
  +   //
  +   // Attributes
  +   //
  +
  +   /** 
  +    * holds a map of service q-names to classloaders 
  +    * this map must be initialised lazily, since accesses are already done
  +    * in the super-constructor! Newbies!
  +    */
  +   protected Map service2ClassLoader;
  +
  +     /** whether the type mapping has been registered */
  +     protected boolean tmrCreated=false;
  +     
  +   //
  +   // Constructors
  +   // 
  +
      /**
       * Constructor for Deployment.
       * @param e root element of the deployment document
  @@ -51,48 +68,107 @@
       */
      public Deployment(Element e) throws WSDDException {
         super(e);
  +      Element[] elements = getChildElements(e, "typeMapping");
  +      for (int i = 0; i < elements.length; i++) {
  +         TypeMapping mapping = new TypeMapping(elements[i]);
  +         deployTypeMapping(mapping);
  +      }
  +   }
  +
  +   //
  +   // protected helpers
  +   //
  +
  +   /** lazily initialises the classloader map */
  +   protected synchronized Map getService2ClassLoader() {
  +      if (service2ClassLoader == null) {
  +         service2ClassLoader = new java.util.HashMap();
  +      }
  +
  +      return service2ClassLoader;
  +   }
  +
  +   /** installs the typemappings parameter table inside a deserializer */
  +   protected void equipTypeMappingWithOptions(TypeMapping typeMapping)
  +      throws ConfigurationException {
  +      DeserializerFactory dser =
  +         (
  +            (org.apache.axis.encoding.TypeMapping) 
getTypeMappingRegistry().getTypeMapping(
  +               typeMapping.getEncodingStyle())).getDeserializer(
  +            typeMapping.getQName());
  +      if (dser instanceof ParameterizableDeserializerFactory) {
  +         // Load up our params
  +         ((ParameterizableDeserializerFactory) dser).setOptions(
  +            typeMapping.getParametersTable());
  +      }
      }
   
  -     /** lazily initialises the classloader map */
  -     protected synchronized Map getService2ClassLoader() {
  -        if(service2ClassLoader==null) {
  -           service2ClassLoader=new java.util.HashMap();
  -        }
  -        
  -        return service2ClassLoader;
  -     }
  +   //
  +   // Public API
  +   //
   
  -     /**
  +   /**
        * Put a WSDDService into this deployment, replacing any other
        * WSDDService which might already be present with the same QName.
        *
        * @param service a WSDDHandler to insert in this deployment
        */
  -    public void deployService(WSDDService service)
  -    {
  -        service.deployToRegistry(this);
  -        
getService2ClassLoader().put(service.getQName(),Thread.currentThread().getContextClassLoader());
  -    }
  -    
  -    public void deployToRegistry(WSDDDeployment target)
  -        throws DeploymentException
  -    {
  -       super.deployToRegistry(target);
  -       if(target instanceof Deployment) {
  -             Map targetMap=((Deployment) target).getService2ClassLoader();
  -             Iterator myEntries=getService2ClassLoader().entrySet().iterator();
  -             while(myEntries.hasNext()) {
  -                Map.Entry nextEntry=(Map.Entry) myEntries.next();
  -                targetMap.put(nextEntry.getKey(),nextEntry.getValue());
  -             }
  -        }
  -    }
  +   public void deployService(WSDDService service) {
  +      service.deployToRegistry(this);
  +      getService2ClassLoader().put(
  +         service.getQName(),
  +         Thread.currentThread().getContextClassLoader());
  +   }
   
  -    /**
  -     * retrieve the classloader that loaded the given service
  -     */
  -    public ClassLoader getClassLoader(QName serviceName) {
  -     return (ClassLoader) getService2ClassLoader().get(serviceName);
  -    }
  -    
  -}
  +   /** deploy the information inside a given target */
  +   public void deployToRegistry(WSDDDeployment target)
  +      throws DeploymentException {
  +      super.deployToRegistry(target);
  +      if (target instanceof Deployment) {
  +         Map targetMap = ((Deployment) target).getService2ClassLoader();
  +         Iterator myEntries = getService2ClassLoader().entrySet().iterator();
  +         while (myEntries.hasNext()) {
  +            Map.Entry nextEntry = (Map.Entry) myEntries.next();
  +            targetMap.put(nextEntry.getKey(), nextEntry.getValue());
  +         }
  +      }
  +   }
  +
  +   /**
  +    * retrieve the classloader that loaded the given service
  +    */
  +   public ClassLoader getClassLoader(QName serviceName) {
  +      return (ClassLoader) getService2ClassLoader().get(serviceName);
  +   }
  +
  +   /** overwrite to equip with options */
  +   public void deployTypeMapping(WSDDTypeMapping typeMapping)
  +      throws WSDDException {
  +      super.deployTypeMapping(typeMapping);
  +      if (typeMapping instanceof TypeMapping) {
  +         try {
  +            equipTypeMappingWithOptions((TypeMapping) typeMapping);
  +         } catch (ConfigurationException e) {
  +            throw new WSDDException("Could not equip typemapping with options 
because of"+ e);
  +         }
  +      }
  +   }
  +
  +
  +   /** overwrite to equip with options */
  +   public TypeMappingRegistry getTypeMappingRegistry()
  +      throws ConfigurationException {
  +      TypeMappingRegistry tmr = super.getTypeMappingRegistry();
  +      if(!tmrCreated) {
  +         tmrCreated=true;
  +      WSDDTypeMapping[] typeMappings = (WSDDTypeMapping[]) getTypeMappings();
  +      for (int count = 0; count < typeMappings.length; count++) {
  +         if (typeMappings[count] instanceof TypeMapping) {
  +            equipTypeMappingWithOptions((TypeMapping) typeMappings[count]);
  +         }
  +      }
  +      }
  +      return tmr;
  +   }
  +
  +}
  \ No newline at end of file
  
  
  
  1.1                  
contrib/jboss.net/src/main/org/jboss/net/axis/ParameterizableDeserializer.java
  
  Index: ParameterizableDeserializer.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  // $Id: ParameterizableDeserializer.java,v 1.1 2002/04/09 09:59:40 cgjung Exp $
  
  package org.jboss.net.axis;
  
  import javax.xml.rpc.encoding.Deserializer;
  import java.util.Map;
  
  /**
   * Extended deserializer that may be equipped with additional
   * options.
   * @author jung
   * @created 06.04.2002
   * @version $Revision: 1.1 $
   */
  
  public interface ParameterizableDeserializer extends Deserializer {
  
        public Map getOptions();
        public void setOptions(Map options);
                
  }
  
  
  1.1                  
contrib/jboss.net/src/main/org/jboss/net/axis/ParameterizableDeserializerFactory.java
  
  Index: ParameterizableDeserializerFactory.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  // $Id: ParameterizableDeserializerFactory.java,v 1.1 2002/04/09 09:59:40 cgjung Exp 
$
  
  package org.jboss.net.axis;
  
  import org.apache.axis.encoding.ser.BaseDeserializerFactory;
  
  import javax.xml.rpc.encoding.DeserializerFactory;
  import javax.xml.rpc.namespace.QName;
  
  import java.util.Map;
  
  /**
   * Deserializer Factory that may be parameterized with additional
   * options.
   * <br>
   * <h3>Change History</h3>
   * <ul>
   * </ul>
   * @created 06.04.2002
   * @author <a href="mailto:[EMAIL PROTECTED]";>Christoph G. Jung</a>
   * @version $Revision: 1.1 $
   */
  
  public class ParameterizableDeserializerFactory extends BaseDeserializerFactory {
  
        // 
        // Attributes
        // 
        
        protected Map options;
        
        //
        // Constructors
        //
                
        /** regular constructor */
        public ParameterizableDeserializerFactory(Class deserializerType, boolean 
reusable, Class javaType, QName xmlType) {
           super(deserializerType,reusable,xmlType,javaType);
        }
        
        /** the extended constructor that is parameterized */
        public ParameterizableDeserializerFactory(Class deserializerType, boolean 
reusable, Class javaType, QName xmlType, Map options) {
           super(deserializerType,reusable,xmlType,javaType);
           this.options=options;
        }
  
        //
        // public API
        //
  
        /** return options */
        protected Map getOptions() {
           return options;
        }
        
        /** set options */
        protected void setOptions(Map options) {
           this.options=options;
        }
                
        /** return a new deserializer that we equip with the right options */
      public javax.xml.rpc.encoding.Deserializer getDeserializerAs(String 
mechanismType) {
         javax.xml.rpc.encoding.Deserializer 
deser=super.getDeserializerAs(mechanismType);
         if(deser instanceof ParameterizableDeserializer) {
            ((ParameterizableDeserializer) deser).setOptions(options);
         }
         return deser;
      }
           
  }
  
  
  1.1                  contrib/jboss.net/src/main/org/jboss/net/axis/TypeMapping.java
  
  Index: TypeMapping.java
  ===================================================================
  /*
   * JBoss, the OpenSource J2EE webOS
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  // $Id: TypeMapping.java,v 1.1 2002/04/09 09:59:40 cgjung Exp $
  
  package org.jboss.net.axis;
  
  import org.apache.axis.deployment.wsdd.WSDDException;
  import org.apache.axis.deployment.wsdd.WSDDTypeMapping;
  import org.apache.axis.utils.LockableHashtable;
  
  import org.w3c.dom.Element;
  
  import java.util.Map;
  
  /**
   * A parameterizable typemapping.
   * <br>
   * <h3>Change History</h3>
   * <ul>
   * </ul>
   * @author <a href="mailto:[EMAIL PROTECTED]";>Christoph G. Jung</a>
   * @created 06.04.2002
   * @version $Revision: 1.1 $
   */
  
  
  public class TypeMapping extends WSDDTypeMapping {
  
        //
        // Attributes
        //
        
        /** carries the options */
     protected LockableHashtable parameters = new LockableHashtable();
  
        //
        // Constructors 
        //
        
     /**
      * Constructor for TypeMapping.
      */
     public TypeMapping() {
        super();
     }
  
     /**
      * Constructor for TypeMapping.
      * @param e
      * @throws WSDDException
      */
     public TypeMapping(Element e) throws WSDDException {
        super(e);
        readParams(e);
     }
  
     /**
      * Constructor for TypeMapping.
      * @param e
      * @param b
      * @throws WSDDException
      */
     protected TypeMapping(Element e, boolean b) throws WSDDException {
        super(e, b);
        readParams(e);
     }
  
        //
        // protected helpers
        //
        
        /** reads out the additional parameter elements */
     protected void readParams(Element e) {
        Element[] paramElements = getChildElements(e, "parameter");
  
        for (int i = 0; i < paramElements.length; i++) {
           Element param = paramElements[i];
           String pname = param.getAttribute("name");
           String value = param.getAttribute("value");
           String locked = param.getAttribute("locked");
           parameters.put(
              pname,
              value,
              (locked != null && locked.equalsIgnoreCase("true")));
        }
  
     }
  
        //
        // public API
        //
        
        /** returns the set of parameters */   
     public Map getParametersTable() {
        return parameters;
     }
     
  } // TypeMapping
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to