1 4 5 9 10 25 package org.openlaszlo.remote.soap.encoding; 26 27 import org.openlaszlo.iv.flash.util.FlashBuffer; 28 import org.openlaszlo.iv.flash.api.action.Actions; 29 import org.openlaszlo.iv.flash.api.action.Program; 30 import org.apache.axis.Constants; 31 import org.apache.axis.components.logger.LogFactory; 32 import org.apache.axis.encoding.DeserializationContext; 33 import org.apache.axis.encoding.Deserializer; 34 import org.apache.axis.encoding.DeserializerImpl; 35 import org.apache.axis.encoding.DeserializerTarget; 36 import org.apache.axis.message.SOAPHandler; 37 import org.apache.axis.utils.ClassUtils; 38 import org.apache.axis.utils.JavaUtils; 39 import org.apache.axis.utils.Messages; 40 import org.apache.axis.wsdl.symbolTable.SchemaUtils; 41 import org.apache.commons.logging.Log; 42 import org.apache.axis.soap.SOAPConstants; 43 import org.apache.axis.MessageContext; 44 45 import org.apache.axis.utils.DOM2Writer; 46 47 import org.xml.sax.Attributes ; 48 import org.xml.sax.SAXException ; 49 50 import javax.xml.namespace.QName ; 51 import java.io.StringWriter ; 52 import java.util.ArrayList ; 53 import java.util.HashMap ; 54 import java.util.Iterator ; 55 import java.util.Map ; 56 import java.util.StringTokenizer ; 57 58 import org.apache.axis.message.MessageElement; 59 import org.apache.log4j.Logger; 60 import org.openlaszlo.iv.flash.util.FlashBuffer; 61 62 63 public class SWFObjectDeserializer extends DeserializerImpl 64 { 65 public static Logger mLogger = 66 Logger.getLogger(SWFObjectDeserializer.class); 67 68 static int BUFSIZE = 8192; 69 70 String mClassName = ""; 71 String mClassNameSpace = ""; 72 73 HashMap mMembers = new HashMap (); 74 75 public void onStartElement(String namespace, String localName, 76 String prefix, Attributes attributes, 77 DeserializationContext context) 78 throws SAXException { 79 80 if (mLogger.isDebugEnabled()) { 81 mLogger.debug("Enter: SWFObjectDeserializer::onStartChild" 82 + "( namespace: " + namespace 83 + ", localname: " + localName 84 + ", prefix: " + prefix 85 + ")"); 86 } 87 88 QName itemType = 90 context.getTypeFromAttributes(namespace, localName, attributes); 91 92 if (itemType == null) { 93 mLogger.debug("itemType is null"); 96 } else { 97 mClassName = itemType.getLocalPart(); 98 mClassNameSpace = itemType.getNamespaceURI(); 99 } 100 } 101 102 103 public SOAPHandler onStartChild(String namespace, String localName, 104 String prefix, Attributes attributes, 105 DeserializationContext context) 106 throws SAXException 107 { 108 if (mLogger.isDebugEnabled()) { 109 mLogger.debug("Enter: SWFObjectDeserializer::onStartChild" 110 + "( namespace: " + namespace 111 + ", localname: " + localName 112 + ", prefix: " + prefix 113 + ")"); 114 } 115 116 QName itemType = 118 context.getTypeFromAttributes(namespace, localName, attributes); 119 120 Deserializer dSer = null; 122 if (itemType != null && (context.getCurElement().getHref() == null)) { 123 dSer = context.getDeserializerForType(itemType); 124 } 125 126 127 if (dSer == null) { 128 dSer = new SWFObjectDeserializer(); 129 } 130 131 dSer.registerValueTarget(new DeserializerTarget(this, localName)); 134 135 addChildDeserializer(dSer); 138 139 return (SOAPHandler)dSer; 140 } 141 142 143 public void setChildValue(Object value, Object hint) throws SAXException 144 { 145 mMembers.put(hint, value); 146 } 147 148 public void valueComplete() throws SAXException { 149 150 if (mLogger.isDebugEnabled()) { 151 mLogger.debug("Enter: SWFObjectDeserializer::valueComplete()"); 152 } 153 154 if (targets != null && !isHref) { 163 164 if (componentsReady()) { 165 166 FlashBuffer fbuf = new FlashBuffer(BUFSIZE); 167 Program program = new Program( fbuf ); 168 169 Iterator iter = mMembers.entrySet().iterator(); 171 String keys = ""; 172 while (iter.hasNext()) { 173 Map.Entry entry = (Map.Entry )iter.next(); 174 String k = (String )entry.getKey(); 175 Program v = (Program)entry.getValue(); 176 program.push(k); 177 fbuf.writeFOB(v.body()); 179 } 180 181 program.push("__LZclassnamespace"); 182 program.push(mClassNameSpace); 183 program.push("__LZclassname"); 184 program.push(mClassName); 185 program.push(mMembers.size() + 2); 186 program.body().writeByte(Actions.InitObject); 187 188 program.push(1); 192 program.push("_root"); 193 program.getVar(); 194 program.push("LzSOAPService"); 195 program.body().writeByte(Actions.GetMember); 196 program.push("__LZnormObj"); 197 program.callMethod(); 198 199 value = program; 200 } 201 202 } 203 204 super.valueComplete(); 205 206 } 207 } 208 | Popular Tags |