Skip to content

Commit 3293446

Browse files
committed
SWS-717 - Impossible to add custom error handling during JAXB marshalling/unmarshalling.
1 parent 9f9e06d commit 3293446

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

core/src/main/java/org/springframework/ws/server/endpoint/adapter/method/jaxb/AbstractJaxb2PayloadMethodProcessor.java

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2005-2010 the original author or authors.
2+
* Copyright 2005-2011 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -174,16 +174,41 @@ private JAXBException convertToJaxbException(Exception ex) {
174174
}
175175
}
176176

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 {
179187
return jaxbContext.createMarshaller();
180188
}
181189

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 {
184204
return jaxbContext.createUnmarshaller();
185205
}
186206

207+
private Unmarshaller createUnmarshaller(Class<?> clazz) throws JAXBException {
208+
return createUnmarshaller(getJaxbContext(clazz));
209+
}
210+
211+
187212
private JAXBContext getJaxbContext(Class<?> clazz) throws JAXBException {
188213
Assert.notNull(clazz, "'clazz' must not be null");
189214
JAXBContext jaxbContext = jaxbContexts.get(clazz);

0 commit comments

Comments
 (0)