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


Java Jaxb2Marshaller.setClassesToBeBound方法代码示例

本文整理汇总了Java中org.springframework.oxm.jaxb.Jaxb2Marshaller.setClassesToBeBound方法的典型用法代码示例。如果您正苦于以下问题:Java Jaxb2Marshaller.setClassesToBeBound方法的具体用法?Java Jaxb2Marshaller.setClassesToBeBound怎么用?Java Jaxb2Marshaller.setClassesToBeBound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.oxm.jaxb.Jaxb2Marshaller的用法示例。


在下文中一共展示了Jaxb2Marshaller.setClassesToBeBound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMarshaller

import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
@Bean
public Jaxb2Marshaller getMarshaller() {
	Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
	jaxb2Marshaller.setClassesToBeBound(Kml.class);

	final Map<String,Object> map = new HashMap<>();
	map.put("jaxb.formatted.output", true);

	jaxb2Marshaller.setMarshallerProperties(map);
	return jaxb2Marshaller;
}
 
开发者ID:ghillert,项目名称:gps-vehicle-simulator,代码行数:12,代码来源:GpsSimulatorApplication.java

示例2: jaxb2Marshaller

import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
@Bean
public Jaxb2Marshaller jaxb2Marshaller() {
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setClassesToBeBound(
            com.marklogic.spring.batch.core.AdaptedJobExecution.class,
            com.marklogic.spring.batch.core.AdaptedJobInstance.class,
            com.marklogic.spring.batch.core.AdaptedJobParameters.class,
            com.marklogic.spring.batch.core.AdaptedStepExecution.class,
            com.marklogic.spring.batch.core.AdaptedExecutionContext.class);
    marshaller.setAdapters(
            new ExecutionContextAdapter(),
            new JobExecutionAdapter(),
            new JobInstanceAdapter(),
            new JobParametersAdapter(),
            new StepExecutionAdapter());
    //marshaller.setMarshallerProperties(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    return marshaller;
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:19,代码来源:JaxbConfiguration.java

示例3: xmlWriter

import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
@Bean("writer2")
public ItemWriter<Permanent> xmlWriter() {
       StaxEventItemWriter<Permanent> xmlFileWriter = new StaxEventItemWriter<>();

       String exportFilePath = "./src/main/resources/emps.xml";
       xmlFileWriter.setResource(new FileSystemResource(exportFilePath));
       xmlFileWriter.setRootTagName("employees");

       Jaxb2Marshaller empMarshaller = new Jaxb2Marshaller();
       empMarshaller.setClassesToBeBound(Permanent.class);
       xmlFileWriter.setMarshaller(empMarshaller);
       System.out.println("marshalling");;
       return xmlFileWriter;
   }
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:15,代码来源:BatchConfig.java

示例4: setMarshallerUnmarshallerClass

import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
/**
 * 设置需要进行Marshaller或Unmarshaller的Java类
 * @param clazzs 用于进行Marshaller或Unmarshaller操作的Java类数组
 */
public void setMarshallerUnmarshallerClass(Class<?>[] clazzs){
	Jaxb2Marshaller marshaller=new Jaxb2Marshaller();
	marshaller.setClassesToBeBound(clazzs);
	this.setMarshaller(marshaller);
	this.setUnmarshaller(marshaller);
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:11,代码来源:WebServiceClientTools.java

示例5: 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

示例6: 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

示例7: testXmlOnly

import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
@Test
public void testXmlOnly() throws Exception {

	Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
	marshaller.setClassesToBeBound(Person.class);

	standaloneSetup(new PersonController()).setSingleView(new MarshallingView(marshaller)).build()
		.perform(get("/person/Corea"))
			.andExpect(status().isOk())
			.andExpect(content().contentType(MediaType.APPLICATION_XML))
			.andExpect(xpath("/person/name/text()").string(equalTo("Corea")));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:ViewResolutionTests.java

示例8: testContentNegotiation

import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
@Test
public void testContentNegotiation() throws Exception {

	Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
	marshaller.setClassesToBeBound(Person.class);

	List<View> viewList = new ArrayList<View>();
	viewList.add(new MappingJackson2JsonView());
	viewList.add(new MarshallingView(marshaller));

	ContentNegotiationManager manager = new ContentNegotiationManager(
			new HeaderContentNegotiationStrategy(), new FixedContentNegotiationStrategy(MediaType.TEXT_HTML));

	ContentNegotiatingViewResolver cnViewResolver = new ContentNegotiatingViewResolver();
	cnViewResolver.setDefaultViews(viewList);
	cnViewResolver.setContentNegotiationManager(manager);
	cnViewResolver.afterPropertiesSet();

	MockMvc mockMvc =
		standaloneSetup(new PersonController())
			.setViewResolvers(cnViewResolver, new InternalResourceViewResolver())
			.build();

	mockMvc.perform(get("/person/Corea"))
		.andExpect(status().isOk())
		.andExpect(model().size(1))
		.andExpect(model().attributeExists("person"))
		.andExpect(forwardedUrl("person/show"));

	mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_JSON))
		.andExpect(status().isOk())
		.andExpect(content().contentType(MediaType.APPLICATION_JSON))
		.andExpect(jsonPath("$.person.name").value("Corea"));

	mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_XML))
		.andExpect(status().isOk())
		.andExpect(content().contentType(MediaType.APPLICATION_XML))
		.andExpect(xpath("/person/name/text()").string(equalTo("Corea")));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:40,代码来源:ViewResolutionTests.java

示例9: unmarshallXmlSuccessTest

import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
/**
 * Unmarshall xml success test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void unmarshallXmlSuccessTest() throws Exception {
	final Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
	jaxb2Marshaller.setClassesToBeBound(SimpleXml.class);
	final SimpleXml simpleXml = (SimpleXml) xmlAgent.unmarshallXml(jaxb2Marshaller, XmlAgentImplITest.class.getResource("/simplexml.xml").toString());
	assertEquals(new SimpleXml("abc123"), simpleXml);
}
 
开发者ID:Hack23,项目名称:cia,代码行数:14,代码来源:XmlAgentImplITest.java

示例10: unmarshallXmlMissingNamespaceSuccessTest

import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
/**
 * Unmarshall xml missing namespace success test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void unmarshallXmlMissingNamespaceSuccessTest() throws Exception {
	final Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
	jaxb2Marshaller.setClassesToBeBound(SimpleXml.class);
	final SimpleXml simpleXml = (SimpleXml) xmlAgent.unmarshallXml(jaxb2Marshaller, XmlAgentImplITest.class.getResource("/simplexml-missing-namespace.xml").toString(),"com.hack23.cia.service.external.common.impl.test",null,null);
	assertEquals(new SimpleXml("abc123"), simpleXml);
}
 
开发者ID:Hack23,项目名称:cia,代码行数:14,代码来源:XmlAgentImplITest.java

示例11: unmarshallXmlMissingNamespaceAndReplaceSuccessTest

import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
/**
 * Unmarshall xml missing namespace and replace success test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void unmarshallXmlMissingNamespaceAndReplaceSuccessTest() throws Exception {
	final Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
	jaxb2Marshaller.setClassesToBeBound(SimpleXml.class);
	final SimpleXml simpleXml = (SimpleXml) xmlAgent.unmarshallXml(jaxb2Marshaller, XmlAgentImplITest.class.getResource("/simplexml-missing-namespace.xml").toString(),"com.hack23.cia.service.external.common.impl.test","abc123","ABC123");
	assertEquals(new SimpleXml("ABC123"), simpleXml);
}
 
开发者ID:Hack23,项目名称:cia,代码行数:14,代码来源:XmlAgentImplITest.java

示例12: taxiiStatusMarshaller

import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
@Bean
public Jaxb2Marshaller taxiiStatusMarshaller() {
    Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
    jaxb2Marshaller.setClassesToBeBound(TaxiiStatus.class);
    jaxb2Marshaller.setMarshallerProperties(ImmutableMap.of(
            javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, true));
    return jaxb2Marshaller;
}
 
开发者ID:CiscoCTA,项目名称:taxii-log-adapter,代码行数:9,代码来源:PersistenceConfiguration.java

示例13: testCustomizeFaultObjectExceptionSoapFault

import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
/**
 * Test method for
 * {@link py.una.pol.karaku.services.server.EndpointExceptionResolver#customizeFault(java.lang.Object, java.lang.Exception, org.springframework.ws.soap.SoapFault)}
 * .
 * 
 * @throws SecurityException
 * @throws NoSuchMethodException
 */
@Test
public void testCustomizeFaultObjectExceptionSoapFault() throws Exception {

	Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
	marshaller.setClassesToBeBound(HTTPExceptionDTO.class);

	EndpointExceptionResolver eer = new EndpointExceptionResolver();
	eer.setMarshaller(marshaller);

	Method m = Endpoint.class.getMethod("call", String.class);

	MethodEndpoint me = new MethodEndpoint(new Endpoint(), m);

	Fault f = new Fault();
	eer.customizeFault(me, new HTTPException("1", "code"), f);

	StringResult result = f.getFaultDetail().getResult();

	// @formatter:off
	String expectedResult = ""
			+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
			+ "<ns2:HTTPException xmlns:ns2=\"http://sigh.med.una.py/2013/schemas/base\">"
			+ "<code>1</code>"
			+ "<summary>code</summary>"
			+ "</ns2:HTTPException>";
	// @formatter:on
	assertEquals(result.toString(), expectedResult);

}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:38,代码来源:EndpointExceptionResolverTest.java

示例14: testResolveFault_HTTPException

import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
/**
 * Test method for
 * {@link py.una.pol.karaku.services.client.KarakuFaultMessageResolver#resolveFault(org.springframework.ws.WebServiceMessage)}
 * .
 */
@Test
public void testResolveFault_HTTPException() throws Exception {

	Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
	marshaller.setClassesToBeBound(HTTPExceptionDTO.class);

	KarakuFaultMessageResolver resolver = new KarakuFaultMessageResolver(
			marshaller);
	// @formatter:off
	SOAPMessage message = getFromString(""
			+ "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"> " +
			"   <SOAP-ENV:Header/> " +
			"   <SOAP-ENV:Body> " +
			"      <SOAP-ENV:Fault> " +
			"         <faultcode>SOAP-ENV:Client</faultcode> " +
			"         <faultstring xml:lang=\"en\">Invalid request</faultstring> " +
			"         <detail> " +
			"            <ns4:HTTPException xmlns:ns4=\"http://sigh.med.una.py/2013/schemas/base\"> " +
			"               <code>1</code>" +
			"               <summary>2</summary>" +
			"            </ns4:HTTPException>" +
			"         </detail>" +
			"      </SOAP-ENV:Fault>" +
			"   </SOAP-ENV:Body>" +
			"</SOAP-ENV:Envelope>");
	// @formatter:on

	SaajSoapMessage ssm = new SaajSoapMessage(message);
	try {
		resolver.resolveFault(ssm);
		fail();
	} catch (HTTPException exception) {
		assertEquals("1", exception.getCode());
		assertEquals("2", exception.getShortDescription());
	}
}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:42,代码来源:KarakuFaultMessageResolverTest.java

示例15: testResolvXteFault_NormalException

import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入方法依赖的package包/类
@Test
public void testResolvXteFault_NormalException() throws Exception {

	Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
	marshaller.setClassesToBeBound(HTTPExceptionDTO.class);

	KarakuFaultMessageResolver resolver = new KarakuFaultMessageResolver(
			marshaller);
	// @formatter:off
	SOAPMessage message = getFromString(""
			+ "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"> " +
			"   <SOAP-ENV:Header/> " +
			"   <SOAP-ENV:Body> " +
			"      <SOAP-ENV:Fault> " +
			"         <faultcode>SOAP-ENV:Client</faultcode> " +
			"         <faultstring xml:lang=\"en\">Invalid request</faultstring> " +
			"      </SOAP-ENV:Fault>" +
			"   </SOAP-ENV:Body>" +
			"</SOAP-ENV:Envelope>");
	// @formatter:on

	SaajSoapMessage ssm = new SaajSoapMessage(message);
	try {
		resolver.resolveFault(ssm);
		fail();
	} catch (SoapFaultClientException exception) {
		assertEquals("Client", exception.getFaultCode().getLocalPart());
		assertEquals("Invalid request", exception.getFaultStringOrReason());
	}
}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:31,代码来源:KarakuFaultMessageResolverTest.java


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