当前位置: 首页>>代码示例>>Java>>正文


Java Jaxb2Marshaller.afterPropertiesSet方法代码示例

本文整理汇总了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;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:17,代码来源:JaxbConfig.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:MarshallingMessageConverterTests.java

示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:38,代码来源:ServletAnnotationControllerTests.java

示例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);
	}
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:31,代码来源:EndpointExceptionResolver.java

示例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);
	}
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:31,代码来源:EndpointExceptionResolver.java

示例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);
	}
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:31,代码来源:EndpointExceptionResolver.java

示例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);
	}
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:31,代码来源:EndpointExceptionResolver.java


注:本文中的org.springframework.oxm.jaxb.Jaxb2Marshaller.afterPropertiesSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。