Example usage for org.springframework.oxm.jaxb Jaxb2Marshaller setPackagesToScan

List of usage examples for org.springframework.oxm.jaxb Jaxb2Marshaller setPackagesToScan

Introduction

In this page you can find the example usage for org.springframework.oxm.jaxb Jaxb2Marshaller setPackagesToScan.

Prototype

public void setPackagesToScan(@Nullable String... packagesToScan) 

Source Link

Document

Set the packages to search for classes with JAXB2 annotations in the classpath.

Usage

From source file:no.digipost.api.xml.Marshalling.java

public static Jaxb2Marshaller createNewMarshaller() {
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setPackagesToScan(new String[] { packageName(StandardBusinessDocument.class),
            packageName(Envelope.class), packageName(org.w3.soap.Envelope.class),
            packageName(org.w3.xmldsig.Reference.class), packageName(Messaging.class),
            packageName(NonRepudiationInformation.class), packageName(SDPKvittering.class),
            packageName(XAdESSignatures.class), packageName(QualifyingProperties.class) });
    marshaller.setSchemas(Schemas.allSchemaResources());
    return marshaller;
}

From source file:org.muhia.app.psi.integ.config.ke.obopay.ObopayBulkApiClientConfiguration.java

@Bean(name = "obopayBulkApiMarshaller")
public Jaxb2Marshaller marshaller() {
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setPackagesToScan(properties.getBulkpaymentMarshallerPackagesToscan().split(","));
    return marshaller;
}

From source file:org.muhia.app.psi.integ.config.ke.obopay.ObopayBulkApiClientConfiguration.java

@Bean(name = "obopayBulkApiUnmarshaller")
public Jaxb2Marshaller unmarshaller() {
    Jaxb2Marshaller unmarshaller = new Jaxb2Marshaller();
    unmarshaller.setPackagesToScan(properties.getBulkpaymentUnmarshallerPackagesToscan().split(","));
    return unmarshaller;
}

From source file:org.agatom.springatom.data.xml.OXMLConfiguration.java

/**
 * <p>getJaxbMarshaller.</p>
 *
 * @return a {@link org.springframework.oxm.jaxb.Jaxb2Marshaller} object.
 *//*w w  w  . java  2 s . c  o  m*/
@Bean(name = "jaxbMarshaller")
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public Jaxb2Marshaller getJaxbMarshaller() {
    final Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
    jaxb2Marshaller.setLazyInit(this.environment.getProperty("springatom.oxm.lazyInit", Boolean.class));
    jaxb2Marshaller.setPackagesToScan(
            StringUtils.split(this.environment.getProperty("springatom.oxm.packagesToScan"), ","));
    jaxb2Marshaller.setCheckForXmlRootElement(true);
    jaxb2Marshaller.setProcessExternalEntities(true);
    return jaxb2Marshaller;
}

From source file:com.zergiu.tvman.jobs.TestTVRageShowLoader.java

/**
 * @param string/* ww  w .  j av a2  s  . c o m*/
 * @return
 */
private TVRageShowLoaderJob createShowLoader(final String resourcePath) {
    showLoader = new TVRageShowLoaderJob() {

        /* (non-Javadoc)
         * @see com.zergiu.tvman.shows.tvrage.TVRageShowLoaderJob#getShow(org.quartz.JobExecutionContext)
         */
        @Override
        protected TVShow getShow(JobExecutionContext context) {
            return show;
        }

        /* (non-Javadoc)
         * @see com.zergiu.tvman.shows.tvrage.TVRageShowLoaderJob#getShowDataStream(java.lang.String)
         */
        @Override
        protected InputStream getShowDataStream(String urlString) throws IOException {
            return TestTVRageShowLoader.class.getResourceAsStream(resourcePath);
        }

        @Override
        protected Unmarshaller getUnmarshaller() {
            Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
            marshaller.setPackagesToScan(new String[] { "com.zergiu.tvman.shows.tvrage.entities" });

            return marshaller;
        }

    };
    return showLoader;
}

From source file:org.muhia.app.psi.integ.config.ke.crba.CreditReferenceBureauAuthorityClientConfiguration.java

@Bean(name = "transunionMarshaller")
public Jaxb2Marshaller marshaller() {
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    //        marshaller.setContextPaths(properties.getCrbaTransunionMarshallerContext().split(","));
    marshaller.setPackagesToScan(properties.getCrbaTransunionMarshallerContext().split(","));

    return marshaller;
}

From source file:org.muhia.app.psi.integ.config.ke.crba.CreditReferenceBureauAuthorityClientConfiguration.java

@Bean(name = "transunionUnmarshaller")
public Jaxb2Marshaller unmarshaller() {
    Jaxb2Marshaller unmarshaller = new Jaxb2Marshaller();
    /*/*from w w w  . java2 s  .  c om*/
    TODO: Find out what contextPath means and how to configure
     */
    //        unmarshaller.setContextPaths(properties.getCrbaTransunionUnmarshallerContext().split(","));
    unmarshaller.setPackagesToScan(properties.getCrbaTransunionUnmarshallerContext().split(","));

    return unmarshaller;
}

From source file:py.una.pol.karaku.configuration.KarakuWSClientConfiguration.java

/**
 * Crea un nuevo marhsaller.//from  w  ww.  j  a  v a2 s  .  com
 * 
 * @param packagesFound
 *            lista de paquetes.
 * @return
 */
private Jaxb2Marshaller instanciateMarshaller(List<String> packagesFound) {

    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    String[] packages = packagesFound.toArray(new String[0]);
    log.info("Add packages to the marshaller {}: ", new Object[] { packages });
    marshaller.setPackagesToScan(packages);
    return marshaller;
}

From source file:com.neiljbrown.brighttalk.channels.reportingapi.client.spring.AppConfig.java

/**
 * Creates and configures a {@link Marshaller} to be used for both marshalling and unmarshalling HTTP request and
 * response bodies./*from  w w  w  .  ja  va2  s  . c  o  m*/
 * <p>
 * The created Marshaller is configured with a custom JAXB {@link javax.xml.bind.ValidationEventHandler} which
 * supports logging not fatal validation errors that occur on unmarshalling, and optionally classifying them as fatal
 * errors depending on the class of causal ('linked') exception.
 * 
 * @return The created {@link Marshaller}.
 */
@Bean
public Marshaller marshaller() {
    Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
    CustomValidationEventHandler eventHandler = new CustomValidationEventHandler();
    eventHandler.setFatalLinkedExceptions(this.marshallingErrorFatalExceptions);
    jaxb2Marshaller.setValidationEventHandler(eventHandler);
    Package apiResourcesRootPackage = ChannelResource.class.getPackage();
    jaxb2Marshaller.setPackagesToScan(new String[] { apiResourcesRootPackage.getName() });
    return jaxb2Marshaller;
}

From source file:org.cruk.genologics.api.jaxb.JaxbAnnotationTest.java

@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/*from  w  w  w  .  java2 s.c o  m*/
            .setMarshallerProperties(context.getBean("genologicsJaxbMarshallerProperties", Map.class));

    Jaxb2Marshaller original = marshaller;
    try {
        marshaller = exceptionMarshaller;
        fetchMarshalAndCompare(com.genologics.ri.exception.Exception.class);
    } finally {
        marshaller = original;
    }
}