|  | 
| 1 | 1 | /* | 
| 2 |  | - * Copyright 2005-2010 the original author or authors. | 
|  | 2 | + * Copyright 2005-2011 the original author or authors. | 
| 3 | 3 |  * | 
| 4 | 4 |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
| 5 | 5 |  * you may not use this file except in compliance with the License. | 
| 6 | 6 |  * You may obtain a copy of the License at | 
| 7 | 7 |  * | 
| 8 |  | - *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 8 | + *     http://www.apache.org/licenses/LICENSE-2.0 | 
| 9 | 9 |  * | 
| 10 | 10 |  * Unless required by applicable law or agreed to in writing, software | 
| 11 | 11 |  * distributed under the License is distributed on an "AS IS" BASIS, | 
| @@ -174,16 +174,41 @@ private JAXBException convertToJaxbException(Exception ex) { | 
| 174 | 174 |         } | 
| 175 | 175 |     } | 
| 176 | 176 | 
 | 
| 177 |  | -    private Marshaller createMarshaller(Class<?> clazz) throws JAXBException { | 
| 178 |  | -        JAXBContext jaxbContext = getJaxbContext(clazz); | 
|  | 177 | +    /** | 
|  | 178 | +     * Creates a new {@link Marshaller} to be used for marshalling objects to XML. Defaults to | 
|  | 179 | +     * {@link javax.xml.bind.JAXBContext#createMarshaller()}, but can be overridden in subclasses for further | 
|  | 180 | +     * customization. | 
|  | 181 | +     * | 
|  | 182 | +     * @param jaxbContext the JAXB context to create a marshaller for | 
|  | 183 | +     * @return the marshaller | 
|  | 184 | +     * @throws JAXBException in case of JAXB errors | 
|  | 185 | +     */ | 
|  | 186 | +    protected Marshaller createMarshaller(JAXBContext jaxbContext) throws JAXBException { | 
| 179 | 187 |         return jaxbContext.createMarshaller(); | 
| 180 | 188 |     } | 
| 181 | 189 | 
 | 
| 182 |  | -    private Unmarshaller createUnmarshaller(Class<?> clazz) throws JAXBException { | 
| 183 |  | -        JAXBContext jaxbContext = getJaxbContext(clazz); | 
|  | 190 | +    private Marshaller createMarshaller(Class<?> clazz) throws JAXBException { | 
|  | 191 | +        return createMarshaller(getJaxbContext(clazz)); | 
|  | 192 | +    } | 
|  | 193 | + | 
|  | 194 | +    /** | 
|  | 195 | +     * Creates a new {@link Unmarshaller} to be used for unmarshalling XML to objects. Defaults to | 
|  | 196 | +     * {@link javax.xml.bind.JAXBContext#createUnmarshaller()}, but can be overridden in subclasses for further | 
|  | 197 | +     * customization. | 
|  | 198 | +     * | 
|  | 199 | +     * @param jaxbContext the JAXB context to create a unmarshaller for | 
|  | 200 | +     * @return the unmarshaller | 
|  | 201 | +     * @throws JAXBException in case of JAXB errors | 
|  | 202 | +     */ | 
|  | 203 | +    protected Unmarshaller createUnmarshaller(JAXBContext jaxbContext) throws JAXBException { | 
| 184 | 204 |         return jaxbContext.createUnmarshaller(); | 
| 185 | 205 |     } | 
| 186 | 206 | 
 | 
|  | 207 | +    private Unmarshaller createUnmarshaller(Class<?> clazz) throws JAXBException { | 
|  | 208 | +        return createUnmarshaller(getJaxbContext(clazz)); | 
|  | 209 | +    } | 
|  | 210 | + | 
|  | 211 | + | 
| 187 | 212 |     private JAXBContext getJaxbContext(Class<?> clazz) throws JAXBException { | 
| 188 | 213 |         Assert.notNull(clazz, "'clazz' must not be null"); | 
| 189 | 214 |         JAXBContext jaxbContext = jaxbContexts.get(clazz); | 
|  | 
0 commit comments