This is an automated email from the ASF dual-hosted git repository.
veithen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
The following commit(s) were added to refs/heads/master by this push:
new 1fbcee6325 Remove MessageFormatterEx
1fbcee6325 is described below
commit 1fbcee6325ae905ea55f8c9cba37687428c4f7d3
Author: Andreas Veithen
AuthorDate: Mon Nov 21 00:57:31 2022 +
Remove MessageFormatterEx
Instead declare getDataSource as a default method on MessageFormatter.
---
.../org/apache/axis2/kernel/MessageFormatter.java | 23 ++
.../org/apache/axis2/format/BinaryFormatter.java | 3 +-
.../apache/axis2/format/MessageFormatterEx.java| 44
.../axis2/format/MessageFormatterExAdapter.java| 83 --
.../apache/axis2/format/PlainTextFormatter.java| 3 +-
.../axis2/transport/mail/MailTransportSender.java | 11 +--
6 files changed, 28 insertions(+), 139 deletions(-)
diff --git a/modules/kernel/src/org/apache/axis2/kernel/MessageFormatter.java
b/modules/kernel/src/org/apache/axis2/kernel/MessageFormatter.java
index 5271b3239e..f5148e1642 100644
--- a/modules/kernel/src/org/apache/axis2/kernel/MessageFormatter.java
+++ b/modules/kernel/src/org/apache/axis2/kernel/MessageFormatter.java
@@ -19,13 +19,19 @@
package org.apache.axis2.kernel;
+import org.apache.axiom.blob.Blobs;
+import org.apache.axiom.blob.MemoryBlob;
+import org.apache.axiom.blob.MemoryBlobOutputStream;
import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.util.activation.BlobDataSource;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import java.io.OutputStream;
import java.net.URL;
+import javax.activation.DataSource;
+
/**
*
* MessageFormatter implementations are used by Axis2 to support serialization
@@ -81,4 +87,21 @@ public interface MessageFormatter {
*/
public String formatSOAPAction(MessageContext messageContext,
OMOutputFormat format,
String soapAction);
+
+/**
+ * Get the formatted message as a {@link DataSource} object.
+ *
+ * @param messageContext
+ * @param format
+ * @param soapAction
+ * @return
+ * @throws AxisFault
+ */
+default DataSource getDataSource(MessageContext messageContext,
OMOutputFormat format, String soapAction) throws AxisFault {
+MemoryBlob blob = Blobs.createMemoryBlob();
+MemoryBlobOutputStream out = blob.getOutputStream();
+writeTo(messageContext, format, out, false);
+out.close();
+return new BlobDataSource(blob, getContentType(messageContext, format,
soapAction));
+}
}
diff --git
a/modules/transport/base/src/main/java/org/apache/axis2/format/BinaryFormatter.java
b/modules/transport/base/src/main/java/org/apache/axis2/format/BinaryFormatter.java
index ae59ff6622..a183c3f034 100644
---
a/modules/transport/base/src/main/java/org/apache/axis2/format/BinaryFormatter.java
+++
b/modules/transport/base/src/main/java/org/apache/axis2/format/BinaryFormatter.java
@@ -32,10 +32,11 @@ import org.apache.axiom.om.OMText;
import org.apache.axiom.util.activation.DataHandlerUtils;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.kernel.MessageFormatter;
import org.apache.axis2.kernel.http.util.URLTemplatingUtil;
import org.apache.axis2.transport.base.BaseConstants;
-public class BinaryFormatter implements MessageFormatterEx {
+public class BinaryFormatter implements MessageFormatter {
private Blob getBlob(MessageContext messageContext) {
OMElement firstChild =
messageContext.getEnvelope().getBody().getFirstElement();
if
(BaseConstants.DEFAULT_BINARY_WRAPPER.equals(firstChild.getQName())) {
diff --git
a/modules/transport/base/src/main/java/org/apache/axis2/format/MessageFormatterEx.java
b/modules/transport/base/src/main/java/org/apache/axis2/format/MessageFormatterEx.java
deleted file mode 100644
index 0653bb05ab..00
---
a/modules/transport/base/src/main/java/org/apache/axis2/format/MessageFormatterEx.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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
- * speci