You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2007/04/16 21:07:55 UTC
svn commit: r529361 - in
/webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/serializer:
ByteArraySerializer.java SerializerRegistry.java
Author: danj
Date: Mon Apr 16 12:07:54 2007
New Revision: 529361
URL: http://svn.apache.org/viewvc?view=rev&rev=529361
Log:
Fix for MUSE-221 - add support for base64Binary and byte types. We only allow generation
of byte[], not single bytes. All WSDLs run through wsdl2java should have minOccurs=2+
and maxOccurs=2+
Added:
webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/serializer/ByteArraySerializer.java
Modified:
webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/serializer/SerializerRegistry.java
Added: webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/serializer/ByteArraySerializer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/serializer/ByteArraySerializer.java?view=auto&rev=529361
==============================================================================
--- webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/serializer/ByteArraySerializer.java (added)
+++ webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/serializer/ByteArraySerializer.java Mon Apr 16 12:07:54 2007
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.muse.core.serializer;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.xml.XmlUtils;
+
+/**
+ *
+ * ByteSerializer transforms bytes to XML and back.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class ByteArraySerializer implements Serializer
+{
+ public Object fromXML(Element xml)
+ {
+ String text = XmlUtils.extractText(xml);
+ return text == null ? null : text.getBytes();
+ }
+
+ public Class getSerializableType()
+ {
+ return byte[].class;
+ }
+
+ public Element toXML(Object obj, QName qname)
+ {
+ return XmlUtils.createElement(qname, new String((byte[])obj));
+ }
+}
Modified: webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/serializer/SerializerRegistry.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/serializer/SerializerRegistry.java?view=diff&rev=529361&r1=529360&r2=529361
==============================================================================
--- webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/serializer/SerializerRegistry.java (original)
+++ webservices/muse/trunk/modules/muse-core/src/org/apache/muse/core/serializer/SerializerRegistry.java Mon Apr 16 12:07:54 2007
@@ -103,6 +103,13 @@
registerSerializer(QName.class, new QNameSerializer());
registerSerializer(Element.class, new ElementSerializer());
registerSerializer(XmlSerializable.class, new XmlSerializableSerializer());
+
+ //
+ // edge case: allow for byte array parameters so users
+ // can send a bunch of data with no formatting. we do
+ // NOT permit individual byte parameters
+ //
+ _serializers.put(byte[].class, new ByteArraySerializer());
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org