本文整理汇总了Java中org.springframework.oxm.jaxb.Jaxb2Marshaller类的典型用法代码示例。如果您正苦于以下问题:Java Jaxb2Marshaller类的具体用法?Java Jaxb2Marshaller怎么用?Java Jaxb2Marshaller使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Jaxb2Marshaller类属于org.springframework.oxm.jaxb包,在下文中一共展示了Jaxb2Marshaller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lukeMooselikeharvestsExportJaxbMarshaller
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入依赖的package包/类
@Bean(name = "lukeMooselikeharvestsExportMarshaller")
public Jaxb2Marshaller lukeMooselikeharvestsExportJaxbMarshaller() {
final Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setMarshallerProperties(getMarshallerDefaultProperties());
marshaller.setContextPath("fi.riista.integration.luke_export.mooselikeharvests");
marshaller.setSchema(new ClassPathResource("/xsd/luke/export-mooselikeharvests-v1.xsd"));
return activateLoggingValidation(marshaller);
}
示例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;
}
示例3: 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;
}
示例4: init
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入依赖的package包/类
@PostConstruct
private void init() {
interceptors.add(loggingInterceptor);
interceptors.add(faultInterceptor);
setInterceptors(interceptors.toArray(new ClientInterceptor[0]));
marshaller = new Jaxb2Marshaller();
marshaller.setContextPath(OTAPingRQ.class.getPackage().getName());
setMarshaller(marshaller);
setUnmarshaller(marshaller);
}
示例5: responseBodyArgMismatch
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入依赖的package包/类
@Test
public void responseBodyArgMismatch() throws ServletException, IOException {
initServlet(new ApplicationContextInitializer<GenericWebApplicationContext>() {
@Override
public void initialize(GenericWebApplicationContext wac) {
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(RequestMappingHandlerAdapter.class);
adapterDef.getPropertyValues().add("messageConverters", messageConverter);
wac.registerBeanDefinition("handlerAdapter", adapterDef);
}
}, RequestBodyArgMismatchController.class);
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();
getServlet().service(request, response);
assertEquals(400, response.getStatus());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:ServletAnnotationControllerHandlerMethodTests.java
示例6: castorMarshaller
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入依赖的package包/类
@Bean
public Jaxb2Marshaller castorMarshaller() {
Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
jaxb2Marshaller.setPackagesToScan("org.sitenv.service.ccda.smartscorecard.cofiguration");
Map<String,Object> map = new HashMap<>();
map.put("jaxb.formatted.output", true);
jaxb2Marshaller.setMarshallerProperties(map);
return jaxb2Marshaller;
}
示例7: 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;
}
示例8: GOClient
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入依赖的package包/类
@Builder
private GOClient(
@NonNull final GOClientConfig config,
final GOClientLogger goClientLogger)
{
this.config = config;
this.goClientLogger = goClientLogger != null ? goClientLogger : SLF4JGOClientLogger.instance;
final HttpComponentsMessageSender messageSender = createMessageSender(config.getAuthUsername(), config.getAuthPassword());
final Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setPackagesToScan(de.metas.shipper.gateway.go.schema.ObjectFactory.class.getPackage().getName());
webServiceTemplate = new WebServiceTemplate();
webServiceTemplate.setDefaultUri(config.getUrl());
webServiceTemplate.setMessageSender(messageSender);
webServiceTemplate.setMarshaller(marshaller);
webServiceTemplate.setUnmarshaller(marshaller);
}
示例9: webServiceTemplate
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入依赖的package包/类
/**
* Instancia un nuevo bean del Tipo {@link WebServiceTemplate}, utilizado
* para realizar llamadas del tipo SOAP.
*
* @return {@link WebServiceTemplate} para realizar llamadas
*/
@Bean
public WebServiceTemplate webServiceTemplate() {
if (!isEnabled()) {
return null;
}
final WebServiceTemplate wst = new WebServiceTemplate();
Jaxb2Marshaller marshaller = getJaxb2Marshaller();
wst.setMarshaller(marshaller);
wst.setUnmarshaller(marshaller);
wst.setFaultMessageResolver(new KarakuFaultMessageResolver(marshaller));
return wst;
}
示例10: getJaxb2Marshaller
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入依赖的package包/类
private Jaxb2Marshaller getJaxb2Marshaller() {
if (!isEnabled()) {
return null;
}
Pattern pattern = Pattern.compile(properties.get(
KARAKU_WS_CLIENT_PACKAGES_TO_SCAN,
DEFAULT_PACKAGES_TO_SCAN_EXPRESSION));
Package[] packages = Package.getPackages();
List<String> packagesFound = new ArrayList<String>();
for (Package pa : packages) {
Matcher matcher = pattern.matcher(pa.getName());
if (matcher.matches()) {
log.trace("Found a package to add to the marshaller: "
+ pa.getName());
packagesFound.add(pa.getName());
}
}
addSpecificPackages(packagesFound);
return instanciateMarshaller(packagesFound);
}
示例11: testExceptionSimple
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testExceptionSimple() throws Throwable
{
// Cannot use configured because of aspects.
Jaxb2Marshaller exceptionMarshaller = new Jaxb2Marshaller();
exceptionMarshaller.setPackagesToScan(new String[] { "com.genologics.ri.exception" });
exceptionMarshaller.setMarshallerProperties(context.getBean("genologicsJaxbMarshallerProperties", Map.class));
Jaxb2Marshaller original = marshaller;
try
{
marshaller = exceptionMarshaller;
fetchMarshalAndCompare(com.genologics.ri.exception.Exception.class);
}
finally
{
marshaller = original;
}
}
示例12: testExceptionSimple
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testExceptionSimple() throws Throwable
{
// Cannot use configured because of aspects.
Jaxb2Marshaller exceptionMarshaller = new Jaxb2Marshaller();
exceptionMarshaller.setPackagesToScan(new String[] { "com.genologics.ri.exception" });
exceptionMarshaller.setMarshallerProperties(context.getBean("genologicsJaxbMarshallerProperties", Map.class));
Jaxb2Marshaller original = marshaller;
try
{
marshaller = exceptionMarshaller;
fetchMarshalAndSerialize(com.genologics.ri.exception.Exception.class);
}
finally
{
marshaller = original;
}
}
示例13: GenologicsAPIPaginatedBatchTest
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入依赖的package包/类
public GenologicsAPIPaginatedBatchTest() throws MalformedURLException
{
pageFiles = new File[] {
new File("src/test/xml/multipagefetch-1.xml"),
new File("src/test/xml/multipagefetch-2.xml"),
new File("src/test/xml/multipagefetch-3.xml")
};
context = new ClassPathXmlApplicationContext("/org/cruk/genologics/api/genologics-client-context.xml");
marshaller = context.getBean("genologicsJaxbMarshaller", Jaxb2Marshaller.class);
Samples page1 = (Samples)marshaller.unmarshal(new StreamSource(pageFiles[0]));
response1 = new ResponseEntity<Samples>(page1, HttpStatus.OK);
Samples page2 = (Samples)marshaller.unmarshal(new StreamSource(pageFiles[1]));
response2 = new ResponseEntity<Samples>(page2, HttpStatus.OK);
Samples page3 = (Samples)marshaller.unmarshal(new StreamSource(pageFiles[2]));
response3 = new ResponseEntity<Samples>(page3, HttpStatus.OK);
}
示例14: getMessaging
import org.springframework.oxm.jaxb.Jaxb2Marshaller; //导入依赖的package包/类
/**
* Enten returnerer denne et Messaging objekt, eller så kaster den en RuntimeException
*/
public static Messaging getMessaging(final Jaxb2Marshaller jaxb2Marshaller, final WebServiceMessage message) {
SoapHeader soapHeader = ((SoapMessage) message).getSoapHeader();
if (soapHeader == null) {
throw new RuntimeException("The ebMS header is missing (no SOAP header found in SOAP request)");
}
Iterator<SoapHeaderElement> soapHeaderElementIterator = soapHeader.examineHeaderElements(MESSAGING_QNAME);
if (!soapHeaderElementIterator.hasNext()) {
throw new RuntimeException("The ebMS header is missing in SOAP header");
}
SoapHeaderElement incomingSoapHeaderElement = soapHeaderElementIterator.next();
try {
return (Messaging) jaxb2Marshaller.unmarshal(incomingSoapHeaderElement.getSource());
} catch (Exception e) {
throw new RuntimeException("The ebMs header failed to unmarshall");
}
}
示例15: 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;
}