Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://svn.apache.org/repos/asf/activemq/camel/trunk@583073 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
Showing
4 changed files
with
152 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
camel-core/src/main/java/org/apache/camel/impl/SerializationBinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
camel-core/src/main/java/org/apache/camel/spi/Binding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
80 changes: 80 additions & 0 deletions
80
components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbBinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters