本文整理汇总了Java中org.springframework.oxm.jaxb.Jaxb2Marshaller.afterPropertiesSet方法的典型用法代码示例。如果您正苦于以下问题:Java Jaxb2Marshaller.afterPropertiesSet方法的具体用法?Java Jaxb2Marshaller.afterPropertiesSet怎么用?Java Jaxb2Marshaller.afterPropertiesSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.oxm.jaxb.Jaxb2Marshaller
的用法示例。
在下文中一共展示了Jaxb2Marshaller.afterPropertiesSet方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activateLoggingValidation
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
private static Jaxb2Marshaller activateLoggingValidation(final Jaxb2Marshaller marshaller) {
// activate
try {
// need to call this to really activate validation
marshaller.afterPropertiesSet();
} catch (Exception e) {
LOG.error("Exception when creating marshaller", e);
}
// log validation message
marshaller.setValidationEventHandler(event -> {
LOG.info(event.getMessage());
return true;
});
return marshaller;
}
示例2: createMarshaller
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
@Before
public void createMarshaller() throws Exception {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setClassesToBeBound(MyBean.class);
marshaller.afterPropertiesSet();
this.converter = new MarshallingMessageConverter(marshaller);
}
示例3: responseBodyArgMismatch
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
@Test
public void responseBodyArgMismatch() throws ServletException, IOException {
@SuppressWarnings("serial") DispatcherServlet servlet = new DispatcherServlet() {
@Override
protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) {
GenericWebApplicationContext wac = new GenericWebApplicationContext();
wac.registerBeanDefinition("controller", new RootBeanDefinition(RequestBodyArgMismatchController.class));
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setClassesToBeBound(A.class, B.class);
try {
marshaller.afterPropertiesSet();
}
catch (Exception ex) {
throw new BeanCreationException(ex.getMessage(), ex);
}
MarshallingHttpMessageConverter messageConverter = new MarshallingHttpMessageConverter(marshaller);
RootBeanDefinition adapterDef = new RootBeanDefinition(AnnotationMethodHandlerAdapter.class);
adapterDef.getPropertyValues().add("messageConverters", messageConverter);
wac.registerBeanDefinition("handlerAdapter", adapterDef);
wac.refresh();
return wac;
}
};
servlet.init(new MockServletConfig());
MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/something");
String requestBody = "<b/>";
request.setContent(requestBody.getBytes("UTF-8"));
request.addHeader("Content-Type", "application/xml; charset=utf-8");
MockHttpServletResponse response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals(400, response.getStatus());
}
示例4: customizeFault
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
@Override
protected void customizeFault(Object endpoint, Exception exception, SoapFault fault)
{
// create the corresponding jaxb element of an EndpointException
if (exception instanceof EndpointException)
{
// get the result inside the fault detail to marshal to
Result result = fault.addFaultDetail().getResult();
//create a new WS entity EndpointException and setting its code and message to be equal to those of actual thrown Exception
CMEndpointExceptionBean endpointException = new CMEndpointExceptionBean();
endpointException.setCode(((EndpointException) exception).getCode());
endpointException.setMessage(exception.getMessage());
JAXBElement<CMEndpointExceptionBean> soapFaultDetails = new ObjectFactory().createEndpointException(endpointException);
// marshal the EndpointException WS entity to the details tag of a SOAP Fault message
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath(jaxb2MarshallerContextPath);
try {
//When setting the marshaller in applicationContext.xml, Spring calls by default afterPropertiesSet() after setting the
//marshaller properties; from Java, I have to do it before marshalling an object
marshaller.afterPropertiesSet();
} catch (Exception e) {
logger.error("Error while setting up Jaxb2Marshaller!");
}
marshaller.marshal(soapFaultDetails, result);
} else {
super.customizeFault(endpoint, exception, fault);
}
}
示例5: customizeFault
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
@Override
protected void customizeFault(Object endpoint, Exception exception, SoapFault fault)
{
// create the corresponding jaxb element of an EndpointException
if (exception instanceof EndpointException)
{
// get the result inside the fault detail to marshal to
Result result = fault.addFaultDetail().getResult();
//create a new WS entity EndpointException and setting its code and message to be equal to those of actual thrown Exception
TSEndpointExceptionBean reportsEndpointExceptionBean = new TSEndpointExceptionBean();
reportsEndpointExceptionBean.setCode(((EndpointException) exception).getCode());
reportsEndpointExceptionBean.setMessage(exception.getMessage());
JAXBElement<TSEndpointExceptionBean> soapFaultDetails = new ObjectFactory().createEndpointException(reportsEndpointExceptionBean);
// marshal the EndpointException WS entity to the details tag of a SOAP Fault message
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath(jaxb2MarshallerContextPath);
try {
//When setting the marshaller in applicationContext.xml, Spring calls by default afterPropertiesSet() after setting the
//marshaller properties; from Java, I have to do it before marshalling an object
marshaller.afterPropertiesSet();
} catch (Exception e) {
logger.error("Error while setting up Jaxb2Marshaller!");
}
marshaller.marshal(soapFaultDetails, result);
} else {
super.customizeFault(endpoint, exception, fault);
}
}
示例6: customizeFault
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
@Override
protected void customizeFault(Object endpoint, Exception exception, SoapFault fault)
{
// create the corresponding jaxb element of an EndpointException
if (exception instanceof EndpointException)
{
// get the result inside the fault detail to marshal to
Result result = fault.addFaultDetail().getResult();
//create a new WS entity EndpointException and setting its code and message to be equal to those of actual thrown Exception
OMEndpointExceptionBean endpointException = new OMEndpointExceptionBean();
endpointException.setCode(((EndpointException) exception).getCode());
endpointException.setMessage(exception.getMessage());
JAXBElement<OMEndpointExceptionBean> soapFaultDetails = new ObjectFactory().createEndpointException(endpointException);
// marshal the EndpointException WS entity to the details tag of a SOAP Fault message
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath(jaxb2MarshallerContextPath);
try {
//When setting the marshaller in applicationContext.xml, Spring calls by default afterPropertiesSet() after setting the
//marshaller properties; from Java, I have to do it before marshalling an object
marshaller.afterPropertiesSet();
} catch (Exception e) {
logger.error("Error while setting up Jaxb2Marshaller!");
}
marshaller.marshal(soapFaultDetails, result);
} else {
super.customizeFault(endpoint, exception, fault);
}
}
示例7: customizeFault
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
@Override
protected void customizeFault(Object endpoint, Exception exception, SoapFault fault)
{
// create the corresponding jaxb element of an EndpointException
if (exception instanceof EndpointException)
{
// get the result inside the fault detail to marshal to
Result result = fault.addFaultDetail().getResult();
//create a new WS entity EndpointException and setting its code and message to be equal to those of actual thrown Exception
AuditEndpointExceptionBean reportsEndpointExceptionBean = new AuditEndpointExceptionBean();
reportsEndpointExceptionBean.setCode(((EndpointException) exception).getCode());
reportsEndpointExceptionBean.setMessage(exception.getMessage());
JAXBElement<AuditEndpointExceptionBean> soapFaultDetails = new ObjectFactory().createEndpointException(reportsEndpointExceptionBean);
// marshal the EndpointException WS entity to the details tag of a SOAP Fault message
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath(jaxb2MarshallerContextPath);
try {
//When setting the marshaller in applicationContext.xml, Spring calls by default afterPropertiesSet() after setting the
//marshaller properties; from Java, I have to do it before marshalling an object
marshaller.afterPropertiesSet();
} catch (Exception e) {
logger.error("Error while setting up Jaxb2Marshaller!");
}
marshaller.marshal(soapFaultDetails, result);
} else {
super.customizeFault(endpoint, exception, fault);
}
}