From a61521f09c9ccc10cfa16fd03e810f9110cd43e6 Mon Sep 17 00:00:00 2001
From: cjmamo <823038+cjmamo@users.noreply.github.com>
Date: Tue, 12 Nov 2024 17:57:59 +0100
Subject: [PATCH] refactor!: remove deprecated SmooksComponent,
SmooksProcessor, and SmooksDataFormat since these classes were migrated to
the Apache Camel codebase (#253)
Refs: https://github.com/smooks/smooks-camel-cartridge/issues/211
---
README.adoc | 10 +-
.../camel/component/SmooksComponent.java | 77 ----
.../camel/component/SmooksEndpoint.java | 84 -----
.../camel/converters/SinkConverter.java | 156 ---------
.../camel/converters/SourceConverter.java | 114 ------
.../camel/dataformat/SmooksDataFormat.java | 171 ---------
.../camel/processor/SmooksProcessor.java | 330 ------------------
.../org/apache/camel/component/smooks | 1 -
.../camel/component/SmooksComponentTest.java | 96 -----
.../camel/converters/CoordinateConverter.java | 76 ----
.../camel/converters/CustomerConverter.java | 83 -----
.../camel/converters/SinkConverterTest.java | 87 -----
.../camel/converters/SourceConverterTest.java | 80 -----
.../cartridges/camel/dataformat/Customer.java | 145 --------
.../dataformat/SmooksCSVDataFormatTest.java | 160 ---------
.../dataformat/SmooksDataFormatTest.java | 167 ---------
.../camel/processor/SmooksProcessorTest.java | 249 -------------
.../SmooksProcessor_BeanRouting_Test.java | 145 --------
...mooksProcessor_CharacterEncoding_Test.java | 95 -----
...ksProcessor_File_In_StringResult_Test.java | 89 -----
.../SmooksProcessor_JavaResult_Test.java | 140 --------
.../processor/SmooksProcessor_Null_Test.java | 77 ----
.../SmooksProcessor_StringResult_Test.java | 93 -----
.../gender/Gender.java | 2 +-
.../gender/GenderTypeConverterFactory.java | 2 +-
src/test/resources/EBCDIC-input-message | 1 -
....smooks.api.converter.TypeConverterFactory | 2 +-
src/test/resources/bean_routing_01.xml | 65 ----
.../resources/csv-smooks-marshal-config.xml | 70 ----
.../resources/csv-smooks-unmarshal-config.xml | 57 ---
src/test/resources/data/order.edi | 4 -
src/test/resources/edi-mapping-model.dfdl.xsd | 61 ----
.../resources/edi-to-xml-smooks-config.xml | 60 ----
.../camel/dataformat/customer-expected.xml | 49 ---
.../cartridges/camel/dataformat/customer.xml | 49 ---
.../camel/dataformat/smooks-config.xml | 62 ----
src/test/resources/xml/expected-order.xml | 76 ----
37 files changed, 8 insertions(+), 3277 deletions(-)
delete mode 100644 src/main/java/org/smooks/cartridges/camel/component/SmooksComponent.java
delete mode 100644 src/main/java/org/smooks/cartridges/camel/component/SmooksEndpoint.java
delete mode 100644 src/main/java/org/smooks/cartridges/camel/converters/SinkConverter.java
delete mode 100644 src/main/java/org/smooks/cartridges/camel/converters/SourceConverter.java
delete mode 100644 src/main/java/org/smooks/cartridges/camel/dataformat/SmooksDataFormat.java
delete mode 100644 src/main/java/org/smooks/cartridges/camel/processor/SmooksProcessor.java
delete mode 100644 src/main/resources/META-INF/services/org/apache/camel/component/smooks
delete mode 100644 src/test/java/org/smooks/cartridges/camel/component/SmooksComponentTest.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/converters/CoordinateConverter.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/converters/CustomerConverter.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/converters/SinkConverterTest.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/converters/SourceConverterTest.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/dataformat/Customer.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/dataformat/SmooksCSVDataFormatTest.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/dataformat/SmooksDataFormatTest.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/processor/SmooksProcessorTest.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/processor/SmooksProcessor_BeanRouting_Test.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/processor/SmooksProcessor_CharacterEncoding_Test.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/processor/SmooksProcessor_File_In_StringResult_Test.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/processor/SmooksProcessor_JavaResult_Test.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/processor/SmooksProcessor_Null_Test.java
delete mode 100644 src/test/java/org/smooks/cartridges/camel/processor/SmooksProcessor_StringResult_Test.java
rename src/test/java/org/smooks/cartridges/camel/{dataformat => routing}/gender/Gender.java (97%)
rename src/test/java/org/smooks/cartridges/camel/{dataformat => routing}/gender/GenderTypeConverterFactory.java (97%)
delete mode 100644 src/test/resources/EBCDIC-input-message
delete mode 100644 src/test/resources/bean_routing_01.xml
delete mode 100644 src/test/resources/csv-smooks-marshal-config.xml
delete mode 100644 src/test/resources/csv-smooks-unmarshal-config.xml
delete mode 100644 src/test/resources/data/order.edi
delete mode 100644 src/test/resources/edi-mapping-model.dfdl.xsd
delete mode 100644 src/test/resources/edi-to-xml-smooks-config.xml
delete mode 100644 src/test/resources/org/smooks/cartridges/camel/dataformat/customer-expected.xml
delete mode 100644 src/test/resources/org/smooks/cartridges/camel/dataformat/customer.xml
delete mode 100644 src/test/resources/org/smooks/cartridges/camel/dataformat/smooks-config.xml
delete mode 100644 src/test/resources/xml/expected-order.xml
diff --git a/README.adoc b/README.adoc
index f5275f5..8cca48d 100644
--- a/README.adoc
+++ b/README.adoc
@@ -46,7 +46,7 @@ Using Smooks in Camel can be done in three ways:
=== SmooksComponent
-WARNING: SmooksComponent is deprecated and superseded by the https://camel.apache.org/components/next/smooks-component.html[Camel Smooks Component].
+WARNING: SmooksComponent is removed in v4 of the cartridge and superseded by the https://camel.apache.org/components/next/smooks-component.html[Camel Smooks Component].
The `+SmooksComponent+` is a Camel https://camel.apache.org/component.html[Component] which can used when you want to process the Camel Message Body using Smooks. You can do this by adding a route in your Camel route configuration:
@@ -69,7 +69,7 @@ An Apache Component can take options that are specified after the Smooks configu
=== SmooksDataFormat
-WARNING: SmooksDataFormat is deprecated and superseded by the https://camel.apache.org/components/next/dataformats/smooks-dataformat.html[Camel Smooks Data Format].
+WARNING: SmooksDataFormat is removed in v4 of the cartridge and superseded by the https://camel.apache.org/components/next/dataformats/smooks-dataformat.html[Camel Smooks Data Format].
`+SmooksDataFormat+` is a Camel DataFormat which is capable of transforming from one data format to another and back again. You would use this when you are only interested in transforming from one format to another and not interested in other Smooks features.
@@ -86,7 +86,7 @@ from("direct:unmarshal")
=== SmooksProcessor
-WARNING: SmooksProcessor is deprecated and superseded by the https://camel.apache.org/components/next/smooks-component.html[Camel Smooks Component].
+WARNING: SmooksProcessor is removed in v4 of the cartridge and superseded by the https://camel.apache.org/components/next/smooks-component.html[Camel Smooks Component].
Using `+SmooksProcessor+` gives you full control over Smooks, for example if you want to programmatically create the underlying Smooks instance youβd use `+SmooksProcessor+`. When using `+SmooksProcessor+`, you can pass a Smooks instance to its constructor and prior to that programmatically configure Smooks.
@@ -118,7 +118,7 @@ from("file://input?noop=true")
.to("mock:result");
----
-TIP: See the https://github.com/smooks/smooks-examples/tree/v2/camel[Apache Camel examples] in the examples page.
+TIP: See the https://github.com/smooks/smooks-examples/tree/v4/camel[Apache Camel examples] in the examples page.
== Maven Coordinates
@@ -128,7 +128,7 @@ TIP: See the https://github.com/smooks/smooks-examples/tree/v2/camel[Apache Came
org.smooks.cartridgessmooks-camel-cartridge
- 3.0.0
+ 4.0.0
----
// end::smooks-camel-cartridge[]
diff --git a/src/main/java/org/smooks/cartridges/camel/component/SmooksComponent.java b/src/main/java/org/smooks/cartridges/camel/component/SmooksComponent.java
deleted file mode 100644
index 80d39ac..0000000
--- a/src/main/java/org/smooks/cartridges/camel/component/SmooksComponent.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * smooks-camel-cartridge
- * %%
- * Copyright (C) 2020 Smooks
- * %%
- * Licensed under the terms of the Apache License Version 2.0, or
- * the GNU Lesser General Public License version 3.0 or later.
- *
- * SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-or-later
- *
- * ======================================================================
- *
- * Licensed 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.
- *
- * ======================================================================
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * =========================LICENSE_END==================================
- */
-package org.smooks.cartridges.camel.component;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.support.DefaultComponent;
-import org.smooks.cartridges.camel.processor.SmooksProcessor;
-
-import java.util.Map;
-
-/**
- * Smook Camel Component.
- *
- *
- * @author Christian Mueller
- * @author Daniel Bevenius
- */
-@Deprecated(forRemoval = true, since = "2.0.0")
-public class SmooksComponent extends DefaultComponent {
- protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception {
- SmooksProcessor smooksProcessor = new SmooksProcessor(remaining, getCamelContext());
- configureSmooksProcessor(smooksProcessor, uri, remaining, parameters);
- return new SmooksEndpoint(uri, this, smooksProcessor);
- }
-
- protected void configureSmooksProcessor(SmooksProcessor smooksProcessor, String uri, String remaining,
- Map parameters) throws Exception {
- setProperties(smooksProcessor, parameters);
- }
-
-}
diff --git a/src/main/java/org/smooks/cartridges/camel/component/SmooksEndpoint.java b/src/main/java/org/smooks/cartridges/camel/component/SmooksEndpoint.java
deleted file mode 100644
index 2241b3b..0000000
--- a/src/main/java/org/smooks/cartridges/camel/component/SmooksEndpoint.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * smooks-camel-cartridge
- * %%
- * Copyright (C) 2020 Smooks
- * %%
- * Licensed under the terms of the Apache License Version 2.0, or
- * the GNU Lesser General Public License version 3.0 or later.
- *
- * SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-or-later
- *
- * ======================================================================
- *
- * Licensed 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.
- *
- * ======================================================================
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * =========================LICENSE_END==================================
- */
-package org.smooks.cartridges.camel.component;
-
-import org.apache.camel.Component;
-import org.apache.camel.Service;
-import org.apache.camel.support.ProcessorEndpoint;
-import org.smooks.api.SmooksException;
-import org.smooks.cartridges.camel.processor.SmooksProcessor;
-
-/**
- * SmooksEndpoint is a wrapper around a {@link SmooksProcessor} instance and
- * adds lifecycle support by implementing Service. This enables a SmooksEndpoint
- * to be stopped and started.
- *
- *
- * @author Daniel Bevenius
- */
-@Deprecated(forRemoval = true, since = "2.0.0")
-public class SmooksEndpoint extends ProcessorEndpoint implements Service {
- private final SmooksProcessor smooksProcessor;
-
- public SmooksEndpoint(String endpointUri, Component component, SmooksProcessor processor) {
- super(endpointUri, component, processor);
- this.smooksProcessor = processor;
- }
-
- public void start() {
- try {
- smooksProcessor.start();
- } catch (Exception e) {
- throw new SmooksException(e.getMessage(), e);
- }
- }
-
- public void stop() {
- try {
- smooksProcessor.stop();
- } catch (Exception e) {
- throw new SmooksException(e.getMessage(), e);
- }
- }
-
-}
diff --git a/src/main/java/org/smooks/cartridges/camel/converters/SinkConverter.java b/src/main/java/org/smooks/cartridges/camel/converters/SinkConverter.java
deleted file mode 100644
index 4e468ba..0000000
--- a/src/main/java/org/smooks/cartridges/camel/converters/SinkConverter.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * smooks-camel-cartridge
- * %%
- * Copyright (C) 2020 Smooks
- * %%
- * Licensed under the terms of the Apache License Version 2.0, or
- * the GNU Lesser General Public License version 3.0 or later.
- *
- * SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-or-later
- *
- * ======================================================================
- *
- * Licensed 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.
- *
- * ======================================================================
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * =========================LICENSE_END==================================
- */
-package org.smooks.cartridges.camel.converters;
-
-import org.apache.camel.Converter;
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.apache.camel.spi.TypeConverterRegistry;
-import org.smooks.io.sink.DOMSink;
-import org.smooks.io.sink.JavaSink;
-import org.smooks.io.sink.StringSink;
-import org.smooks.io.source.StringSource;
-import org.w3c.dom.Node;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-/**
- * ResultConverter converts from different {@link Result} types.
- *
- * @author Daniel Bevenius
- */
-@Converter(generateLoader = true)
-@Deprecated(forRemoval = true, since = "2.0.0")
-public class SinkConverter {
- public static final String SMOOKS_RESULT_KEY = "SmooksResultKeys";
-
- private SinkConverter() {
- }
-
- @Converter
- public static Node toDocument(DOMSink domSink) {
- return domSink.getNode();
- }
-
- @SuppressWarnings("rawtypes")
- @Converter
- public static List toList(JavaSink.ResultMap javaResult, Exchange exchange) {
- String resultKey = (String) exchange.getProperty(SMOOKS_RESULT_KEY);
- if (resultKey != null) {
- return (List) getResultsFromJavaSink(javaResult, resultKey);
- } else {
- return (List) getSingleObjectFromJavaSink(javaResult);
- }
- }
-
- @SuppressWarnings("rawtypes")
- @Converter
- public static Integer toInteger(JavaSink.ResultMap result) {
- return (Integer) getSingleObjectFromJavaSink(result);
- }
-
- @SuppressWarnings("rawtypes")
- @Converter
- public static Double toDouble(JavaSink.ResultMap sink) {
- return (Double) getSingleObjectFromJavaSink(sink);
- }
-
- @Converter
- public static String toString(StringSink sink) {
- return sink.getResult();
- }
-
-
- @SuppressWarnings("rawtypes")
- public static Map toMap(JavaSink.ResultMap resultBeans, Exchange exchange) {
- Message outMessage = exchange.getOut();
- outMessage.setBody(resultBeans);
-
- @SuppressWarnings("unchecked")
- Set> entrySet = resultBeans.entrySet();
- for (Entry entry : entrySet) {
- outMessage.setBody(entry.getValue(), entry.getValue().getClass());
- }
- return resultBeans;
- }
-
- @SuppressWarnings("rawtypes")
- private static Object getResultsFromJavaSink(JavaSink.ResultMap resultMap, String resultKey) {
- return resultMap.get(resultKey);
- }
-
- private static Object getSingleObjectFromJavaSink(@SuppressWarnings("rawtypes") JavaSink.ResultMap resultMap) {
- if (resultMap.size() == 1) {
- return resultMap.values().iterator().next();
- }
- return null;
- }
-
- @Converter
- public static StringSource toStringSource(StringSink stringSink) {
- String result = stringSink.getResult();
- if (result != null) {
- return new StringSource(result);
- }
-
- return null;
- }
-
-
- @SuppressWarnings("rawtypes")
- @Converter(fallback = true)
- public static T convertTo(Class type, Exchange exchange, Object value, TypeConverterRegistry registry) {
- if (value instanceof JavaSink.ResultMap) {
- for (Object mapValue : ((Map) value).values()) {
- if (type.isInstance(mapValue)) {
- return type.cast(mapValue);
- }
- }
- }
-
- return null;
- }
-}
diff --git a/src/main/java/org/smooks/cartridges/camel/converters/SourceConverter.java b/src/main/java/org/smooks/cartridges/camel/converters/SourceConverter.java
deleted file mode 100644
index fd18a5f..0000000
--- a/src/main/java/org/smooks/cartridges/camel/converters/SourceConverter.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * smooks-camel-cartridge
- * %%
- * Copyright (C) 2020 Smooks
- * %%
- * Licensed under the terms of the Apache License Version 2.0, or
- * the GNU Lesser General Public License version 3.0 or later.
- *
- * SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-or-later
- *
- * ======================================================================
- *
- * Licensed 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.
- *
- * ======================================================================
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * =========================LICENSE_END==================================
- */
-package org.smooks.cartridges.camel.converters;
-
-import org.apache.camel.Converter;
-import org.apache.camel.component.file.GenericFile;
-import org.smooks.api.SmooksException;
-import org.smooks.api.io.Source;
-import org.smooks.io.sink.JavaSink;
-import org.smooks.io.source.JavaSource;
-import org.smooks.io.source.JavaSourceWithoutEventStream;
-import org.smooks.io.source.ReaderSource;
-import org.smooks.io.source.StreamSource;
-import org.smooks.io.source.StringSource;
-import org.smooks.io.source.URLSource;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.Reader;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- * SourceConverter is a Camel {@link Converter} that converts from different
- * formats to {@link Source} instances.
- *
- * @author Daniel Bevenius
- */
-@Converter(generateLoader = true)
-@Deprecated(forRemoval = true, since = "2.0.0")
-public class SourceConverter {
- private SourceConverter() {
- }
-
- @Converter
- public static JavaSourceWithoutEventStream toJavaSourceWithoutEventStream(Object payload) {
- return new JavaSourceWithoutEventStream(payload);
- }
-
- @Converter
- public static JavaSource toJavaSource(Object payload) {
- return new JavaSource(payload);
- }
-
- @Converter
- public static Source toStreamSource(InputStream in) {
- return new StreamSource<>(in);
- }
-
- @Converter
- public static Source toReaderSource(Reader reader) {
- return new ReaderSource<>(reader);
- }
-
- @Converter
- public static JavaSource toJavaSource(JavaSink result) {
- return new JavaSource(result.getResultMap().values());
- }
-
- @Converter
- public static Source toStringSource(String string) {
- return new StringSource(string);
- }
-
- @Converter
- public static Source toURISource(GenericFile genericFile) {
- String systemId = new javax.xml.transform.stream.StreamSource((File) genericFile.getBody()).getSystemId();
- try {
- return new URLSource(new URL(systemId));
- } catch (MalformedURLException e) {
- throw new SmooksException(e);
- }
- }
-}
diff --git a/src/main/java/org/smooks/cartridges/camel/dataformat/SmooksDataFormat.java b/src/main/java/org/smooks/cartridges/camel/dataformat/SmooksDataFormat.java
deleted file mode 100644
index af24a08..0000000
--- a/src/main/java/org/smooks/cartridges/camel/dataformat/SmooksDataFormat.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * smooks-camel-cartridge
- * %%
- * Copyright (C) 2020 Smooks
- * %%
- * Licensed under the terms of the Apache License Version 2.0, or
- * the GNU Lesser General Public License version 3.0 or later.
- *
- * SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-or-later
- *
- * ======================================================================
- *
- * Licensed 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.
- *
- * ======================================================================
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * =========================LICENSE_END==================================
- */
-package org.smooks.cartridges.camel.dataformat;
-
-import org.apache.camel.*;
-import org.apache.camel.spi.DataFormat;
-import org.apache.camel.support.processor.MarshalProcessor;
-import org.apache.camel.support.processor.UnmarshalProcessor;
-import org.smooks.Smooks;
-import org.smooks.SmooksFactory;
-import org.smooks.api.ExecutionContext;
-import org.smooks.api.SmooksException;
-import org.smooks.api.io.Sink;
-import org.smooks.cartridges.camel.component.SmooksComponent;
-import org.smooks.cartridges.camel.processor.SmooksProcessor;
-import org.smooks.engine.lookup.ExportsLookup;
-import org.smooks.io.payload.Exports;
-import org.smooks.io.sink.StringSink;
-import org.smooks.io.source.JavaSource;
-import org.smooks.io.source.StreamSource;
-import org.xml.sax.SAXException;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-
-/**
- * SmooksDataFormat is a Camel data format which is a pluggable transformer
- * capable of transforming from one dataformat to another and back again.
- * This means that what is marshaled can be unmarshaled by an instance of this
- * class.
- *
- *
- * A smooks configuration for a SmooksDataFormat should not utilize Smooks
- * features such as routing that might allocated system resources. The reason
- * for this is that there is no functionality in the SmooksDataFormat which will
- * close those resources. If you need to use these Smooks features please take a
- * look at the {@link SmooksComponent} or {@link SmooksProcessor} as they hook
- * into Camels lifecycle manegment and will close resources correctly.
- *
- *
- * @author Christian Mueller
- * @author Daniel Bevenius
- */
-@Deprecated(forRemoval = true, since = "3.0.0")
-public class SmooksDataFormat implements DataFormat, CamelContextAware, Service {
- private Smooks smooks;
- private CamelContext camelContext;
- private final String smooksConfig;
-
- public SmooksDataFormat(final String smooksConfig) throws Exception {
- this.smooksConfig = smooksConfig;
- }
-
- /**
- * Marshals the Object 'fromBody' to an OutputStream 'toStream'
- *
- *
- * The Camel framework will call this method from {@link MarshalProcessor#process(Exchange)}
- * and it will take care of setting the Out Message's body to the bytes written to the toStream
- * OutputStream.
- *
- * @param exchange The Camel {@link Exchange}.
- * @param fromBody The object to be marshalled into the output stream.
- * @param toStream The output stream that will be written to.
- */
- public void marshal(final Exchange exchange, final Object fromBody, final OutputStream toStream) throws Exception {
- final ExecutionContext execContext = smooks.createExecutionContext();
- final TypeConverter typeConverter = exchange.getContext().getTypeConverter();
- final JavaSource source = typeConverter.mandatoryConvertTo(JavaSource.class, exchange, fromBody);
- final StringSink stringSink = new StringSink();
- smooks.filterSource(execContext, source, stringSink);
-
- toStream.write(stringSink.getResult().getBytes(execContext.getContentEncoding()));
- }
-
- /**
- * Unmarshals the fromStream to an Object.
- *
- * The Camel framework will call this method from {@link UnmarshalProcessor#process(Exchange)}
- * and it will take care of setting the returned Object on the Out Message's body.
- *
- * @param exchange The Camel {@link Exchange}.
- * @param fromStream The InputStream that will be unmarshalled into an Object instance.
- */
- public Object unmarshal(final Exchange exchange, final InputStream fromStream) {
- final ExecutionContext execContext = smooks.createExecutionContext();
- final Exports exports = smooks.getApplicationContext().getRegistry().lookup(new ExportsLookup());
- final Sink[] sinks = exports.createSinks();
- smooks.filterSource(execContext, new StreamSource(fromStream), sinks);
- return getResult(exports, sinks, exchange);
- }
-
- protected Object getResult(final Exports exports, final Sink[] sinks, final Exchange exchange) {
- final List