You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/10/09 10:34:34 UTC
svn commit: r583073 - in /activemq/camel/trunk:
camel-core/src/main/java/org/apache/camel/impl/
camel-core/src/main/java/org/apache/camel/spi/
components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/
Author: jstrachan
Date: Tue Oct 9 01:34:33 2007
New Revision: 583073
URL: http://svn.apache.org/viewvc?rev=583073&view=rev
Log:
further improvements for CAMEL-165
Added:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SerializationBinding.java (with props)
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Binding.java (with props)
activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbBinding.java (with props)
Modified:
activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbUnmarshaller.java
Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SerializationBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SerializationBinding.java?rev=583073&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SerializationBinding.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SerializationBinding.java Tue Oct 9 01:34:33 2007
@@ -0,0 +1,36 @@
+/**
+ *
+ * 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.camel.impl;
+
+import org.apache.camel.spi.Binding;
+import org.apache.camel.spi.Marshaller;
+import org.apache.camel.spi.Unmarshaller;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class SerializationBinding implements Binding {
+
+ public Marshaller createMarshaller() {
+ return new SerializationMarshaller();
+ }
+
+ public Unmarshaller createUnmarshaller() {
+ return new SerializationUnmarshaller();
+ }
+}
Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/SerializationBinding.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Binding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Binding.java?rev=583073&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Binding.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Binding.java Tue Oct 9 01:34:33 2007
@@ -0,0 +1,36 @@
+/**
+ *
+ * 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.camel.spi;
+
+/**
+ * Represents a binding of an input/output stream to objects such as Java Serialization or
+ * using JAXB2 to encode/decode objects using XML
+ *
+ * @version $Revision: 1.1 $
+ */
+public interface Binding {
+ /**
+ * Creates a marshaller of objects into a binary stream
+ */
+ Marshaller createMarshaller();
+
+ /**
+ * Creates an unmarshaller of objects from a binary stream
+ */
+ Unmarshaller createUnmarshaller();
+}
Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Binding.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbBinding.java?rev=583073&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbBinding.java (added)
+++ activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbBinding.java Tue Oct 9 01:34:33 2007
@@ -0,0 +1,80 @@
+/**
+ *
+ * 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.camel.converter.jaxb;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spi.Binding;
+import org.apache.camel.spi.Marshaller;
+import org.apache.camel.spi.Unmarshaller;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class JaxbBinding implements Binding {
+ private JAXBContext context;
+ private boolean prettyPrint = true;
+
+ public JaxbBinding() {
+ }
+
+ public JaxbBinding(JAXBContext context) {
+ this.context = context;
+ }
+
+ public Marshaller createMarshaller() {
+ try {
+ javax.xml.bind.Marshaller marshaller = getContext().createMarshaller();
+ marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, prettyPrint ? Boolean.TRUE : Boolean.FALSE);
+ return new JaxbMarshaller(marshaller);
+ }
+ catch (JAXBException e) {
+ throw new RuntimeCamelException(e);
+ }
+ }
+
+ public Unmarshaller createUnmarshaller() {
+ try {
+ javax.xml.bind.Unmarshaller unmarshaller = getContext().createUnmarshaller();
+ return new JaxbUnmarshaller(unmarshaller);
+ }
+ catch (JAXBException e) {
+ throw new RuntimeCamelException(e);
+ }
+ }
+
+ // Properties
+ //-------------------------------------------------------------------------
+ public JAXBContext getContext() throws JAXBException {
+ if (context == null) {
+ context = createContext();
+ }
+ return context;
+ }
+
+ public void setContext(JAXBContext context) {
+ this.context = context;
+ }
+
+ protected JAXBContext createContext() throws JAXBException {
+ return JAXBContext.newInstance();
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbBinding.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbUnmarshaller.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbUnmarshaller.java?rev=583073&r1=583072&r2=583073&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbUnmarshaller.java (original)
+++ activemq/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbUnmarshaller.java Tue Oct 9 01:34:33 2007
@@ -37,7 +37,6 @@
this.unmarshaller = unmarshaller;
}
-
public Object unmarshal(InputStream stream) throws IOException, ClassNotFoundException {
try {
return unmarshaller.unmarshal(stream);