axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject cvs commit: xml-axis/java/test/encoding TestSer.java TestString.java
Date Sat, 05 May 2001 16:48:33 GMT
rubys       01/05/05 09:48:33

  Modified:    java/samples/encoding TestSer.java
               java/src/org/apache/axis Message.java MessageContext.java
               java/src/org/apache/axis/client AdminClient.java
                        HTTPCall.java
               java/src/org/apache/axis/encoding
                        DeserializationContext.java
                        SerializationContext.java
               java/src/org/apache/axis/handlers MsgDispatchHandler.java
               java/src/org/apache/axis/message MessageElement.java
                        RPCParam.java SAXAdapter.java SOAPSAXHandler.java
                        ThreadedSAXAdapter.java
               java/test/encoding TestSer.java TestString.java
  Log:
  Move TypeMappingRegistry to the MessageContext, part I
  
  Revision  Changes    Path
  1.4       +4 -2      xml-axis/java/samples/encoding/TestSer.java
  
  Index: TestSer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/encoding/TestSer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestSer.java	2001/05/05 13:54:00	1.3
  +++ TestSer.java	2001/05/05 16:48:31	1.4
  @@ -1,5 +1,6 @@
   package samples.encoding;
   
  +import org.apache.axis.MessageContext;
   import org.apache.axis.message.*;
   import org.apache.axis.encoding.*;
   import org.apache.axis.utils.QName;
  @@ -15,6 +16,7 @@
       public static final String myNS = "urn:myNS";
       
       public static void main(String args[]) {
  +        MessageContext msgContext = new MessageContext();
           SOAPEnvelope msg = new SOAPEnvelope();
           RPCParam arg1 = new RPCParam("urn:myNamespace", "testParam", "this is a string");
           QName dataQName = new QName("typeNS", "Data");
  @@ -35,7 +37,7 @@
               
               if (args.length == 0) {
                   Writer stringWriter = new StringWriter();
  -                SerializationContext context = new SerializationContext(stringWriter);
  +                SerializationContext context = new SerializationContext(stringWriter, msgContext);
                   
                   TypeMappingRegistry reg = context.getTypeMappingRegistry();
                   
  @@ -55,7 +57,7 @@
                   reader = new FileReader(args[0]);
               }
               
  -            SAXAdapter adapter = new SAXAdapter(new SAXParser(), new InputSource(reader));
  +            SAXAdapter adapter = new SAXAdapter(new SAXParser(), new InputSource(reader),
new MessageContext());
               adapter.setServiceDescription(service);
               TypeMappingRegistry reg = adapter.getContext().getTypeMappingRegistry();
               reg.addDeserializerFactory(dataQName, Data.class, DataSer.getFactory());
  
  
  
  1.28      +15 -3     xml-axis/java/src/org/apache/axis/Message.java
  
  Index: Message.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Message.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Message.java	2001/05/05 11:44:32	1.27
  +++ Message.java	2001/05/05 16:48:32	1.28
  @@ -81,6 +81,7 @@
     private String currentForm ;
     private String messageType ;
     private ServiceDescription serviceDesc = null;
  +  private MessageContext msgContext;
   
     /**
      * Just something to us working...
  @@ -118,6 +119,16 @@
         this.serviceDesc = serviceDesc;
     }
   
  +  public MessageContext getMessageContext()
  +  {
  +      if (msgContext == null) msgContext=new MessageContext();
  +      return msgContext;
  +  }
  +  public void setMessageContext(MessageContext msgContext)
  +  {
  +      this.msgContext = msgContext;
  +  }
  +
     public void setCurrentMessage(Object currMsg, String form) {
       Debug.Print( 2, "Setting current message form to: ",  form );
       currentMessage = currMsg ;
  @@ -216,7 +227,7 @@
           StringWriter writer = new StringWriter();
           AxisFault env = (AxisFault)currentMessage;
           try {
  -            env.output(new SerializationContext(writer));
  +            env.output(new SerializationContext(writer, getMessageContext()));
           } catch (Exception e) {
               e.printStackTrace();
               return null;
  @@ -229,7 +240,7 @@
           StringWriter writer = new StringWriter();
           SOAPEnvelope env = (SOAPEnvelope)currentMessage;
           try {
  -            env.output(new SerializationContext(writer));
  +            env.output(new SerializationContext(writer, getMessageContext()));
           } catch (Exception e) {
               e.printStackTrace();
               return null;
  @@ -333,7 +344,8 @@
       // ThreadedSAXAdapter parser = 
       //    new ThreadedSAXAdapter(new org.apache.xerces.parsers.SAXParser(), is);
       SAXAdapter parser = 
  -        new SAXAdapter(new org.apache.xerces.parsers.SAXParser(), is);
  +        new SAXAdapter(new org.apache.xerces.parsers.SAXParser(), is, 
  +                       getMessageContext());
       parser.setServiceDescription(serviceDesc);
       SOAPEnvelope env = parser.getEnvelope();
       env.setMessageType(messageType);
  
  
  
  1.16      +19 -0     xml-axis/java/src/org/apache/axis/MessageContext.java
  
  Index: MessageContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/MessageContext.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- MessageContext.java	2001/05/02 18:57:13	1.15
  +++ MessageContext.java	2001/05/05 16:48:32	1.16
  @@ -58,6 +58,8 @@
   import java.util.* ;
   import org.apache.axis.* ;
   import org.apache.axis.utils.AxisClassLoader ;
  +import org.apache.axis.encoding.TypeMappingRegistry;
  +import org.apache.axis.encoding.SOAPTypeMappingRegistry;
   
   /**
    * Some more general docs will go here.
  @@ -113,8 +115,25 @@
   
       public MessageContext() {}
   
  +    
       public MessageContext( Message inMsg ) {
           setRequestMessage( inMsg );
  +    }
  +
  +    /**
  +     * Mappings of QNames to serializers/deserializers (and therfore
  +     * to Java types).
  +     */
  +    private TypeMappingRegistry mappingRegistry = null;
  +
  +    public void setTypeMappingRegistry(TypeMappingRegistry reg) {
  +        mappingRegistry = reg;
  +    }
  +
  +    public TypeMappingRegistry getTypeMappingRegistry() {
  +        if (mappingRegistry == null)
  +            mappingRegistry = new SOAPTypeMappingRegistry();
  +        return mappingRegistry;
       }
   
       /**
  
  
  
  1.17      +1 -1      xml-axis/java/src/org/apache/axis/client/AdminClient.java
  
  Index: AdminClient.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/AdminClient.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- AdminClient.java	2001/04/28 16:29:35	1.16
  +++ AdminClient.java	2001/05/05 16:48:32	1.17
  @@ -118,7 +118,7 @@
           input.close();
           SOAPEnvelope envelope = (SOAPEnvelope) outMsg.getAs("SOAPEnvelope");
           SOAPBodyElement body = envelope.getFirstBody();
  -        SerializationContext ctx = new SerializationContext(new PrintWriter(System.out));
  +        SerializationContext ctx = new SerializationContext(new PrintWriter(System.out),
msgContext);
           body.output(ctx);
           // System.out.println( outMsg.getAs( "String" ) );
         }
  
  
  
  1.24      +1 -1      xml-axis/java/src/org/apache/axis/client/HTTPCall.java
  
  Index: HTTPCall.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/HTTPCall.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- HTTPCall.java	2001/05/03 21:17:49	1.23
  +++ HTTPCall.java	2001/05/05 16:48:32	1.24
  @@ -192,7 +192,7 @@
   
       if (DEBUG_LOG) {
           try {
  -            SerializationContext ctx = new SerializationContext(new PrintWriter(System.out));
  +            SerializationContext ctx = new SerializationContext(new PrintWriter(System.out),
msgContext);
               System.out.println("");
               System.out.println("**DEBUG**");
               reqEnv.output(ctx);
  
  
  
  1.8       +11 -9     xml-axis/java/src/org/apache/axis/encoding/DeserializationContext.java
  
  Index: DeserializationContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializationContext.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DeserializationContext.java	2001/05/05 13:47:12	1.7
  +++ DeserializationContext.java	2001/05/05 16:48:32	1.8
  @@ -61,6 +61,7 @@
   import org.apache.axis.encoding.*;
   import org.apache.axis.message.*;
   import org.apache.axis.utils.QName;
  +import org.apache.axis.MessageContext;
   
   /** Keeps track of the active typeMappings, element IDs, parser, and
    * SOAPSAXHandler in an ongoing parse.  Might want to move the
  @@ -73,13 +74,16 @@
   {
       public SOAPSAXHandler baseHandler;
       public Hashtable idMappings = new Hashtable();
  -    public TypeMappingRegistry mappingRegistry = null;
       public Hashtable fixups = new Hashtable();
       public boolean hasUnresolvedHrefs = false;
       
  -    public DeserializationContext(SOAPSAXHandler baseHandler)
  +    private MessageContext msgContext;
  +
  +    public DeserializationContext(SOAPSAXHandler baseHandler, 
  +                                  MessageContext msgContext)
       {
           this.baseHandler = baseHandler;
  +        this.msgContext  = msgContext;
       }
       
       public SOAPSAXHandler getSAXHandler()
  @@ -172,16 +176,14 @@
           return getQNameFromString(type);
       }
       
  -    public void setTypeMappingRegistry(TypeMappingRegistry reg)
  +    public TypeMappingRegistry getTypeMappingRegistry()
       {
  -        mappingRegistry = reg;
  +        return msgContext.getTypeMappingRegistry();
       }
  -
  -    public TypeMappingRegistry getTypeMappingRegistry()
  +    
  +    public MessageContext getMessageContext()
       {
  -        if (mappingRegistry == null) 
  -            mappingRegistry = new SOAPTypeMappingRegistry();
  -        return mappingRegistry;
  +        return msgContext;
       }
       
       public void registerID(String id, MessageElement element)
  
  
  
  1.7       +6 -10     xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java
  
  Index: SerializationContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SerializationContext.java	2001/05/04 21:29:57	1.6
  +++ SerializationContext.java	2001/05/05 16:48:32	1.7
  @@ -61,6 +61,7 @@
   import org.xml.sax.helpers.AttributesImpl;
   import org.apache.axis.message.*;
   import org.apache.axis.utils.*;
  +import org.apache.axis.MessageContext;
   
   /** Manage a serialization, including keeping track of namespace mappings
    * and element stacks.
  @@ -83,23 +84,18 @@
       
       int lastPrefixIndex = 1;
       
  -    private TypeMappingRegistry mappingRegistry = null;
  +    private MessageContext msgContext;
       
  -    public SerializationContext(Writer writer)
  +    public SerializationContext(Writer writer, MessageContext msgContext)
       {
           this.writer = writer;
  +        this.msgContext = msgContext;
  +        if (msgContext==null) throw new NullPointerException();
       }
       
  -    public void setTypeMappingRegistry(TypeMappingRegistry reg)
  -    {
  -        mappingRegistry = reg;
  -    }
  -    
       public TypeMappingRegistry getTypeMappingRegistry()
       {
  -        if (mappingRegistry == null) 
  -            mappingRegistry = new SOAPTypeMappingRegistry();
  -        return mappingRegistry;
  +        return msgContext.getTypeMappingRegistry();
       }
       
       public String getPrefixForURI(String uri)
  
  
  
  1.21      +1 -1      xml-axis/java/src/org/apache/axis/handlers/MsgDispatchHandler.java
  
  Index: MsgDispatchHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/MsgDispatchHandler.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- MsgDispatchHandler.java	2001/05/02 14:37:14	1.20
  +++ MsgDispatchHandler.java	2001/05/05 16:48:32	1.21
  @@ -126,7 +126,7 @@
                                 (SOAPEnvelope)resMsg.getAs("SOAPEnvelope");
         
         StringWriter writer = new StringWriter();
  -      reqBody.output(new SerializationContext(writer));
  +      reqBody.output(new SerializationContext(writer, msgContext));
         
         Reader reader = new StringReader(writer.getBuffer().toString());
         Document doc = XMLUtils.newDocument(new InputSource(reader));
  
  
  
  1.15      +1 -1      xml-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- MessageElement.java	2001/05/04 19:24:46	1.14
  +++ MessageElement.java	2001/05/05 16:48:33	1.15
  @@ -105,7 +105,7 @@
           }
         this.namespaceURI = namespace;
         this.name = localPart;
  -      //this.context = context;
  +      setDeserializationContext(context);
   
         if (attributes == null) {
           this.attributes = new AttributesImpl();
  
  
  
  1.12      +1 -1      xml-axis/java/src/org/apache/axis/message/RPCParam.java
  
  Index: RPCParam.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCParam.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- RPCParam.java	2001/05/05 13:47:13	1.11
  +++ RPCParam.java	2001/05/05 16:48:33	1.12
  @@ -150,7 +150,7 @@
               //     but haven't run them through a deserializer yet.
               StringWriter xml = new StringWriter();
               try {
  -               SerializationContext xmlContext = new SerializationContext(xml);
  +               SerializationContext xmlContext = new SerializationContext(xml, context.getMessageContext());
                  ((ElementRecorder)value).outputChildren(xmlContext);
               } catch (Exception e) {
                  if (DEBUG_LOG) e.printStackTrace();
  
  
  
  1.3       +4 -1      xml-axis/java/src/org/apache/axis/message/SAXAdapter.java
  
  Index: SAXAdapter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SAXAdapter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SAXAdapter.java	2001/05/02 19:54:13	1.2
  +++ SAXAdapter.java	2001/05/05 16:48:33	1.3
  @@ -1,6 +1,7 @@
   package org.apache.axis.message;
   
   import org.xml.sax.*;
  +import org.apache.axis.MessageContext;
   
   /** This class is an adapter for the Axis SAX-event system
    * which uses a SAX parser to parse on its own thread, synchronizing
  @@ -14,8 +15,10 @@
       private XMLReader _parser;
       InputSource inputSource;
   
  -    public SAXAdapter(XMLReader parser, InputSource inputSource)
  +    public SAXAdapter(XMLReader parser, InputSource inputSource,
  +                      MessageContext msgContext)
       {
  +        super(msgContext);
           _parser = new org.apache.xerces.parsers.SAXParser();
           _parser.setContentHandler(this);
           
  
  
  
  1.8       +2 -2      xml-axis/java/src/org/apache/axis/message/SOAPSAXHandler.java
  
  Index: SOAPSAXHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPSAXHandler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SOAPSAXHandler.java	2001/05/04 19:24:47	1.7
  +++ SOAPSAXHandler.java	2001/05/05 16:48:33	1.8
  @@ -152,10 +152,10 @@
       // Body factory. Only doing rpc bodies for right now...
       ElementFactory bodyFactory = new BodyFactory();
   
  -    public SOAPSAXHandler()
  +    public SOAPSAXHandler(MessageContext msgContext)
       {
           envelope = new SOAPEnvelope(this);
  -        this.context = new DeserializationContext(this);
  +        this.context = new DeserializationContext(this,msgContext);
   
           // just testing...
           headerRegistry.registerFactory("urn:myNS", "Debug", DebugHeader.getFactory());
  
  
  
  1.3       +4 -1      xml-axis/java/src/org/apache/axis/message/ThreadedSAXAdapter.java
  
  Index: ThreadedSAXAdapter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/ThreadedSAXAdapter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ThreadedSAXAdapter.java	2001/04/27 15:24:30	1.2
  +++ ThreadedSAXAdapter.java	2001/05/05 16:48:33	1.3
  @@ -1,6 +1,7 @@
   package org.apache.axis.message;
   
   import org.xml.sax.*;
  +import org.apache.axis.MessageContext;
   
   /** This class is an adapter for the Axis SAX-event system
    * which uses a SAX parser to parse on its own thread, synchronizing
  @@ -45,8 +46,10 @@
           }
       }
       
  -    public ThreadedSAXAdapter(XMLReader parser, InputSource inputSource)
  +    public ThreadedSAXAdapter(XMLReader parser, InputSource inputSource,
  +                              MessageContext msgContext)
       {
  +        super(msgContext);
           _parser = new org.apache.xerces.parsers.SAXParser();
           _parser.setContentHandler(this);
           //elementHandler = new SAXOutputter(new PrintWriter(System.out));
  
  
  
  1.3       +4 -2      xml-axis/java/test/encoding/TestSer.java
  
  Index: TestSer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/encoding/TestSer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestSer.java	2001/05/05 13:47:48	1.2
  +++ TestSer.java	2001/05/05 16:48:33	1.3
  @@ -1,5 +1,6 @@
   package test.encoding;
   
  +import org.apache.axis.MessageContext;
   import org.apache.axis.message.*;
   import org.apache.axis.encoding.*;
   import org.apache.axis.utils.QName;
  @@ -21,6 +22,7 @@
       }
   
       public void testData() throws Exception {
  +        MessageContext msgContext = new MessageContext();
           SOAPEnvelope msg = new SOAPEnvelope();
           RPCParam arg1 = new RPCParam("urn:myNamespace", "testParam", "this is a string");
           
  @@ -33,7 +35,7 @@
           msg.addBodyElement(body);
           
           Writer stringWriter = new StringWriter();
  -        SerializationContext context = new SerializationContext(stringWriter);
  +        SerializationContext context = new SerializationContext(stringWriter, msgContext);
           
           TypeMappingRegistry reg = context.getTypeMappingRegistry();
           QName dataQName = new QName("typeNS", "Data");
  @@ -46,7 +48,7 @@
           
           StringReader reader = new StringReader(msgString);
           
  -        SAXAdapter adapter = new SAXAdapter(new SAXParser(), new InputSource(reader));
  +        SAXAdapter adapter = new SAXAdapter(new SAXParser(), new InputSource(reader), msgContext);
           reg = adapter.getContext().getTypeMappingRegistry();
           reg.addDeserializerFactory(dataQName, Data.class, DataSer.getFactory());
           
  
  
  
  1.2       +4 -2      xml-axis/java/test/encoding/TestString.java
  
  Index: TestString.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/encoding/TestString.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestString.java	2001/05/04 01:26:36	1.1
  +++ TestString.java	2001/05/05 16:48:33	1.2
  @@ -1,5 +1,6 @@
   package test.encoding;
   
  +import org.apache.axis.MessageContext;
   import org.apache.axis.message.*;
   import org.apache.axis.encoding.*;
   import org.apache.axis.utils.QName;
  @@ -21,6 +22,7 @@
       }
   
       private void runtest(String value, String expected) throws Exception {
  +        MessageContext msgContext = new MessageContext();
           SOAPEnvelope msg = new SOAPEnvelope();
           RPCParam input = new RPCParam("urn:myNamespace", "testParam", value);
           
  @@ -28,7 +30,7 @@
           msg.addBodyElement(body);
           
           Writer stringWriter = new StringWriter();
  -        SerializationContext context = new SerializationContext(stringWriter);
  +        SerializationContext context = new SerializationContext(stringWriter, msgContext);
           
           msg.output(context);
           
  @@ -36,7 +38,7 @@
           
           StringReader reader = new StringReader(msgString);
           
  -        SAXAdapter adapter = new SAXAdapter(new SAXParser(), new InputSource(reader));
  +        SAXAdapter adapter = new SAXAdapter(new SAXParser(), new InputSource(reader), msgContext);
           SOAPEnvelope env = adapter.getEnvelope();
           RPCElement rpcElem = (RPCElement)env.getFirstBody();
           RPCParam output = rpcElem.getParam("testParam");
  
  
  

Mime
View raw message