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

  Modified:    jboss.net/src/main/org/jboss/net/axis/server
                        AxisService.java AxisServiceMBean.java
                        EntityBeanDeserializer.java
                        EntityBeanDeserializerFactory.java
  Log:
  parameterizable typemappings.
  adopted latest subdeployer changes/patches from Mr. Maisey.
  
  Revision  Changes    Path
  1.17      +8 -27     
contrib/jboss.net/src/main/org/jboss/net/axis/server/AxisService.java
  
  Index: AxisService.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/jboss.net/src/main/org/jboss/net/axis/server/AxisService.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- AxisService.java  4 Apr 2002 04:34:41 -0000       1.16
  +++ AxisService.java  9 Apr 2002 09:59:41 -0000       1.17
  @@ -5,7 +5,7 @@
    * See terms of license at gnu.org.
    */
   
  -// $Id: AxisService.java,v 1.16 2002/04/04 04:34:41 user57 Exp $
  +// $Id: AxisService.java,v 1.17 2002/04/09 09:59:41 cgjung Exp $
   
   package org.jboss.net.axis.server;
   
  @@ -18,8 +18,8 @@
   import org.jboss.deployment.DeploymentInfo;
   import org.jboss.deployment.MainDeployerMBean;
   import org.jboss.deployment.SubDeployer;
  +import org.jboss.deployment.SubDeployerSupport;
   
  -import org.jboss.system.ServiceMBeanSupport;
   import org.jboss.web.WebApplication;
   
   import org.apache.log4j.Category;
  @@ -84,11 +84,11 @@
    * </ul>
    * @created 27. September 2001
    * @author <a href="mailto:[EMAIL PROTECTED]";>Christoph G. Jung</a>
  - * @version $Revision: 1.16 $
  + * @version $Revision: 1.17 $
    */
   
   public class AxisService
  -   extends ServiceMBeanSupport
  +   extends SubDeployerSupport
      implements AxisServiceMBean, MBeanRegistration {
   
      // 
  @@ -324,16 +324,7 @@
            // and deploy the info
            webDeployer.start(myDeploymentInfo);
   
  -         try {
  -            // Register with the main deployer
  -            server.invoke(
  -               MainDeployerMBean.OBJECT_NAME,
  -               "addDeployer",
  -               new Object[] { this },
  -               new String[] { "org.jboss.deployment.SubDeployer" });
  -         } catch (Exception e) {
  -            log.error("Could not register with MainDeployer", e);
  -         }
  +             super.startService();
         } else {
            throw new Exception(Constants.CANNOT_FIND_WEB_DEPLOYER);
         }
  @@ -342,6 +333,9 @@
   
      /** what to do to stop axis temporarily --> undeploy the servlet */
      public void stopService() throws Exception {
  +
  +       super.stopService();
  +             
         // tear down all running web services
         //Is this really what you want to do? Not leave services running anyway? 
         for (Iterator apps = new java.util.ArrayList(deployments.values()).iterator();
  @@ -358,19 +352,6 @@
            } catch (Exception e) {
               log.error("Could not undeploy deployment " + info, e);
            }
  -      }
  -
  -      // deregister from main deployer such that we do not get
  -      // web services assigned anymore
  -      try {
  -         // Register with the main deployer
  -         server.invoke(
  -            MainDeployerMBean.OBJECT_NAME,
  -            "removeDeployer",
  -            new Object[] { this },
  -            new String[] { "org.jboss.deployment.SubDeployer" });
  -      } catch (Exception e) {
  -         log.error("Could not deregister from MainDeployer", e);
         }
   
         // undeploy Axis servlet
  
  
  
  1.5       +3 -3      
contrib/jboss.net/src/main/org/jboss/net/axis/server/AxisServiceMBean.java
  
  Index: AxisServiceMBean.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/jboss.net/src/main/org/jboss/net/axis/server/AxisServiceMBean.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AxisServiceMBean.java     3 Apr 2002 08:44:52 -0000       1.4
  +++ AxisServiceMBean.java     9 Apr 2002 09:59:41 -0000       1.5
  @@ -5,7 +5,7 @@
   * See terms of license at gnu.org.
   */
   
  -// $Id: AxisServiceMBean.java,v 1.4 2002/04/03 08:44:52 user57 Exp $
  +// $Id: AxisServiceMBean.java,v 1.5 2002/04/09 09:59:41 cgjung Exp $
    
   package org.jboss.net.axis.server;
   
  @@ -13,10 +13,10 @@
    * Mbean interface to the AxisService 
    * @author <a href="mailto:[EMAIL PROTECTED]";>Christoph G. Jung</a>
    * @created 27. September 2001
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public interface AxisServiceMBean 
  -   extends org.jboss.deployment.SubDeployerMBean 
  +   extends org.jboss.deployment.SubDeployer, org.jboss.system.ServiceMBean
   {    
     public String getRootContext();
     public void setRootContext(String name) throws Exception;
  
  
  
  1.2       +146 -82   
contrib/jboss.net/src/main/org/jboss/net/axis/server/EntityBeanDeserializer.java
  
  Index: EntityBeanDeserializer.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/jboss.net/src/main/org/jboss/net/axis/server/EntityBeanDeserializer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EntityBeanDeserializer.java       2 Apr 2002 13:48:39 -0000       1.1
  +++ EntityBeanDeserializer.java       9 Apr 2002 09:59:41 -0000       1.2
  @@ -5,10 +5,12 @@
    * See terms of license at gnu.org.
    */
   
  -// $Id: EntityBeanDeserializer.java,v 1.1 2002/04/02 13:48:39 cgjung Exp $
  +// $Id: EntityBeanDeserializer.java,v 1.2 2002/04/09 09:59:41 cgjung Exp $
   
   package org.jboss.net.axis.server;
   
  +import org.jboss.net.axis.ParameterizableDeserializer;
  +
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   
  @@ -30,6 +32,7 @@
   
   import javax.naming.InitialContext;
   import javax.ejb.EJBHome;
  +import javax.naming.NamingException;
   
   import java.beans.PropertyDescriptor;
   import java.beans.IntrospectionException;
  @@ -39,6 +42,7 @@
   import java.util.List;
   import java.util.Collection;
   import java.util.Iterator;
  +import java.util.StringTokenizer;
   
   /**
    * Server-side deserializer hitting an existing entity bean. Derived
  @@ -47,80 +51,137 @@
    * descriptor.
    * @author jung
    * @created 21.03.2002
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   
  -public class EntityBeanDeserializer extends DeserializerImpl {
  +public class EntityBeanDeserializer
  +   extends DeserializerImpl
  +   implements ParameterizableDeserializer {
   
      //
      // Attributes
      //
   
  +   protected Map options;
  +
      protected EJBHome home;
      protected Method findMethod;
  -   protected Class[] findSignature;
  -   protected List findElements = new java.util.ArrayList();
  +   protected List findElements = new java.util.ArrayList(1);
      protected Object[] findObjects;
      protected TypeDesc typeDesc;
      protected QName xmlType;
      protected Class javaType;
  -   protected Map propertyMap = new java.util.HashMap();
  +   protected Map propertyMap = new java.util.HashMap(4);
      protected int collectionIndex = -1;
  -   protected Collection fieldSetters=new java.util.ArrayList();
  -   
  +   protected Collection fieldSetters = new java.util.ArrayList(4);
  +   protected boolean initialized = false;
  +
      /** 
       * Construct a new BeanSerializer
  -    * @param homeType home class of the entity bean
       * @param remoteType remote interface of the entity bean
  -    * @param findMethodName name of the find method to reconstruct the bean
  -    * @param findSignature signature of the find method
  -    * @param findAttributes the name of the attributes used to call the find method
       * @param xmlType fully-qualified xml tag-name of the corresponding xml structure
       */
   
  -   public EntityBeanDeserializer(
  -      String jndiName,
  -      Class remoteType,
  -      String findMethodName,
  -      Class[] findSignature,
  -      String[] findElements,
  -      QName xmlType)
  +   public EntityBeanDeserializer(Class remoteType, QName xmlType)
         throws Exception {
         // first the default constructor
         this.xmlType = xmlType;
         this.javaType = remoteType;
  -      // Get a list of the bean properties
  -      BeanPropertyDescriptor[] pd = getPd(javaType);
  -      // loop through properties and grab the names for later
  -      for (int i = 0; i < pd.length; i++) {
  -         BeanPropertyDescriptor descriptor = pd[i];
  -         propertyMap.put(descriptor.getName(), descriptor);
  -         propertyMap.put(JavaUtils.xmlNameToJava(descriptor.getName()), descriptor);
  -      }
  -      typeDesc = TypeDesc.getTypeDescForClass(javaType);
  -      this.findSignature = findSignature;
  -      // then we do the lookup struff
  -      this.home = (EJBHome) new InitialContext().lookup(jndiName);
  -      findMethod = home.getClass().getMethod(findMethodName, findSignature);
  -      for (int count = 0; count < findElements.length; count++) {
  -         if (typeDesc != null) {
  -            
this.findElements.add(typeDesc.getAttributeNameForField(findElements[count]));
  -         } else {
  -            this.findElements.add(new QName("", findElements[count]));
  -         }
  +   }
  +
  +   /** returns an option string with a default */
  +   protected String getStringOption(String key, String def) {
  +      String value = (String) options.get(key);
  +      if (value == null) {
  +         value = def;
         }
  -      this.findObjects = new Object[findElements.length];
  +      return value;
      }
   
  -   public EntityBeanDeserializer(
  -      Class remoteType,
  -      QName xmlType)
  -      throws Exception {
  -         this(remoteType.getName().
  -             substring(remoteType.getName().lastIndexOf(".")+1)
  -                     +"Home",remoteType,"findByPrimaryKey",new Class[] 
{String.class}, 
  -                             new String[] {"name"},xmlType);
  +   /**
  +    * initialize the deserializer 
  +    */
  +
  +   protected void initialize() throws SAXException {
  +      if (!initialized) {
  +         initialized = true;
  +
  +         try {
  +            //
  +            // Extract home from jndiName
  +            //
  +            this.home =
  +               (EJBHome) new InitialContext().lookup(
  +                  getStringOption("JndiName", javaType.getName() + "Home"));
  +
  +            //
  +            // Extract find method from name and sig
  +            //
  +
  +            String findMethodName = getStringOption("FindMethodName", 
"findByPrimaryKey");
  +            String findMethodSignatureString =
  +               getStringOption("FindMethodSignature", "java.lang.String");
  +            List findMethodSignatureClasses = new java.util.ArrayList(1);
  +            StringTokenizer tokenizer = new 
StringTokenizer(findMethodSignatureString, ";");
  +            while (tokenizer.hasMoreTokens()) {
  +               findMethodSignatureClasses.add(
  +                  Thread.currentThread().getContextClassLoader().loadClass(
  +                     tokenizer.nextToken()));
  +            }
  +            this.findMethod =
  +               home.getClass().getMethod(
  +                  findMethodName,
  +                  (Class[]) findMethodSignatureClasses.toArray(
  +                     new Class[findMethodSignatureClasses.size()]));
  +
  +            //
  +            // Do some reasonable preprocessing
  +            //
  +
  +            // Get a list of the bean properties
  +            BeanPropertyDescriptor[] pd = getPd(javaType);
  +            // loop through properties and grab the names for later
  +            for (int i = 0; i < pd.length; i++) {
  +               BeanPropertyDescriptor descriptor = pd[i];
  +               propertyMap.put(descriptor.getName(), descriptor);
  +               propertyMap.put(JavaUtils.xmlNameToJava(descriptor.getName()), 
descriptor);
  +            }
  +            typeDesc = TypeDesc.getTypeDescForClass(javaType);
  +
  +            //
  +            // Next prepare the elements we need to call the finder
  +            //
  +
  +            String findMethodElements = getStringOption("FindMethodElements", 
"name");
  +            tokenizer = new StringTokenizer(findMethodElements, ";");
  +            while (tokenizer.hasMoreElements()) {
  +               if (typeDesc != null) {
  +                  
this.findElements.add(typeDesc.getAttributeNameForField(tokenizer.nextToken()));
  +               } else {
  +                  this.findElements.add(new QName("", tokenizer.nextToken()));
  +               }
  +            }
  +
  +            this.findObjects = new Object[findElements.size()];
  +         } catch (NamingException e) {
  +            throw new SAXException("Could not lookup home.", e);
  +         } catch (ClassNotFoundException e) {
  +            throw new SAXException("Could not find signature class.", e);
  +         } catch (NoSuchMethodException e) {
  +            throw new SAXException("Could not find finder method.", e);
  +         }
  +
         }
  +   }
  +
  +   public void setOptions(Map options) {
  +      this.options = options;
  +   }
  +
  +   public Map getOptions() {
  +      return options;
  +   }
  +
      /**
       * Deserializer interface called on each child element encountered in
       * the XML stream.
  @@ -183,9 +244,10 @@
            dSer.setDefaultType(tm.getTypeQName(type));
         }
   
  -        QName elementQName=new QName(namespace,localName);
  +      QName elementQName = new QName(namespace, localName);
         if (findElements.contains(elementQName)) {
  -         dSer.registerValueTarget(new 
FindPropertyTarget(findElements.indexOf(elementQName)));
  +         dSer.registerValueTarget(
  +            new FindPropertyTarget(findElements.indexOf(elementQName)));
         } else if (propDesc.getWriteMethod().getParameterTypes().length == 1) {
            // Success!  Register the target and deserializer.
            collectionIndex = -1;
  @@ -193,8 +255,7 @@
         } else {
            // Success! This is a collection of properties so use the index
            collectionIndex++;
  -         dSer.registerValueTarget(
  -            new BeanPropertyTarget(propDesc, collectionIndex));
  +         dSer.registerValueTarget(new BeanPropertyTarget(propDesc, 
collectionIndex));
         }
         return (SOAPHandler) dSer;
      }
  @@ -218,6 +279,8 @@
         DeserializationContext context)
         throws SAXException {
   
  +      initialize();
  +
         if (typeDesc == null)
            return;
   
  @@ -254,7 +317,8 @@
                     JavaUtils.getMessage("AttrNotSimpleType00", bpd.getName(), 
type.toString()));
   
               if (findElements.contains(attrQName)) {
  -               dSer.registerValueTarget(new 
FindPropertyTarget(findElements.indexOf(attrQName)));
  +               dSer.registerValueTarget(
  +                  new FindPropertyTarget(findElements.indexOf(attrQName)));
               } else if (bpd.getWriteMethod().getParameterTypes().length == 1) {
                  // Success!  Create an object from the string and set
                  // it in the bean
  @@ -277,15 +341,15 @@
         throws SAXException {
         try {
            value = findMethod.invoke(home, findObjects);
  -         Iterator allSetters=fieldSetters.iterator();
  -        while(allSetters.hasNext()) {
  +         Iterator allSetters = fieldSetters.iterator();
  +         while (allSetters.hasNext()) {
               ((BeanPropertyTarget) allSetters.next()).setReal(value);
            }
  -         fieldSetters=null;
  +         fieldSetters = null;
         } catch (InvocationTargetException e) {
  -         throw new SAXException("Encountered exception "+e.getTargetException());
  +         throw new SAXException("Encountered exception " + e.getTargetException());
         } catch (IllegalAccessException e) {
  -         throw new SAXException("Encountered exception "+e);
  +         throw new SAXException("Encountered exception " + e);
         }
         super.onEndElement(namespace, localName, context);
      }
  @@ -306,10 +370,10 @@
       * Class which knows how to update a bean property
       */
      public class BeanPropertyTarget implements Target {
  -     private BeanPropertyDescriptor pd;
  +      private BeanPropertyDescriptor pd;
         private int index = -1;
  -       Object value;
  -       
  +      Object value;
  +
         /** 
          * This constructor is used for a normal property.
          * @param Object is the bean class
  @@ -332,14 +396,14 @@
         }
   
         public void set(Object value) throws SAXException {
  -                     this.value=value;
  -                     if(fieldSetters!=null) {
  -                             fieldSetters.add(this);
  -                     } else {
  -                        setReal(EntityBeanDeserializer.this.value);
  -                     }
  +         this.value = value;
  +         if (fieldSetters != null) {
  +            fieldSetters.add(this);
  +         } else {
  +            setReal(EntityBeanDeserializer.this.value);
  +         }
         }
  -      
  +
         public void setReal(Object target) throws SAXException {
            try {
               if (index < 0)
  @@ -483,21 +547,21 @@
            return myPd;
         }
      }
  -   
  -    /**
  -     * Create a BeanPropertyDescriptor array for the indicated class.
  -     */
  -    public static BeanPropertyDescriptor[] getPd(Class javaType) {
  -        BeanPropertyDescriptor[] pd;
  -        try {
  -            PropertyDescriptor[] rawPd = 
Introspector.getBeanInfo(javaType).getPropertyDescriptors();
  -            pd = BeanPropertyDescriptor.processPropertyDescriptors(rawPd,javaType);
  -        } catch (Exception e) {
  -            // this should never happen
  -            throw new RuntimeException(e.getMessage());
  -        }
  -        return pd;
  -    }
   
  +   /**
  +    * Create a BeanPropertyDescriptor array for the indicated class.
  +    */
  +   public static BeanPropertyDescriptor[] getPd(Class javaType) {
  +      BeanPropertyDescriptor[] pd;
  +      try {
  +         PropertyDescriptor[] rawPd =
  +            Introspector.getBeanInfo(javaType).getPropertyDescriptors();
  +         pd = BeanPropertyDescriptor.processPropertyDescriptors(rawPd, javaType);
  +      } catch (Exception e) {
  +         // this should never happen
  +         throw new RuntimeException(e.getMessage());
  +      }
  +      return pd;
  +   }
   
   }
  
  
  
  1.2       +17 -8     
contrib/jboss.net/src/main/org/jboss/net/axis/server/EntityBeanDeserializerFactory.java
  
  Index: EntityBeanDeserializerFactory.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/jboss.net/src/main/org/jboss/net/axis/server/EntityBeanDeserializerFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EntityBeanDeserializerFactory.java        2 Apr 2002 13:48:39 -0000       1.1
  +++ EntityBeanDeserializerFactory.java        9 Apr 2002 09:59:41 -0000       1.2
  @@ -5,33 +5,42 @@
    * See terms of license at gnu.org.
    */
   
  -// $Id: EntityBeanDeserializerFactory.java,v 1.1 2002/04/02 13:48:39 cgjung Exp $
  +// $Id: EntityBeanDeserializerFactory.java,v 1.2 2002/04/09 09:59:41 cgjung Exp $
   
   package org.jboss.net.axis.server;
   
  -import org.apache.axis.encoding.ser.BaseDeserializerFactory;
  -import javax.xml.rpc.namespace.QName;
  +import org.jboss.net.axis.ParameterizableDeserializerFactory;
   
  +import javax.xml.rpc.namespace.QName;
  +import java.util.Hashtable;
   
   /**
    * Factory for server-side Entity Bean Deserialization. 
    * <br>
    * <h3>Change History</h3>
    * <ul>
  + * <li> jung, 06.04.2002: Added parameter table for additional
  + * deserializer options. </li>
    * </ul>
    * @created 21.03.2002
    * @author <a href="mailto:[EMAIL PROTECTED]";>Christoph G. Jung</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   
  -public class EntityBeanDeserializerFactory extends BaseDeserializerFactory {
  -
  +public class EntityBeanDeserializerFactory extends 
ParameterizableDeserializerFactory {
  +     
        //
        // Constructors
        //
        
  +     /** the usual constructor used by axis */
        public EntityBeanDeserializerFactory(Class javaType, QName xmlType) {
  -        super(EntityBeanDeserializer.class,false,xmlType,javaType);
  +        this(javaType,xmlType,new Hashtable(0));
  +     }
  +     
  +     /** the extended constructor that is parameterized */
  +     public EntityBeanDeserializerFactory(Class javaType, QName xmlType, Hashtable 
options) {
  +        super(EntityBeanDeserializer.class,false,javaType,xmlType,options);
        }
  -        
  +                
   }
  
  
  

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

Reply via email to