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

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

Introduction

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

Prototype

@Nullable
public Class<?>[] getClassesToBeBound() 

Source Link

Document

Return the list of Java classes to be recognized by a newly created JAXBContext.

Usage

From source file:org.cruk.genologics.api.impl.GenologicsAPIImpl.java

/**
 * Set the Jaxb marshaller./*from  w  ww.j  av a 2s.  c om*/
 *
 * <p>This operation also immediately scans the classes managed by the marshaller
 * to find those supporting classes for retrieving lists of links to a given entity
 * and classes that allow batch fetch and update of entities.
 * </p>
 *
 * @param jaxbMarshaller The Jaxb marshaller.
 */
@Required
public void setJaxbMarshaller(Jaxb2Marshaller jaxbMarshaller) {
    entityToListClassMap = new HashMap<Class<? extends Locatable>, Class<?>>();
    entityToBatchRetrieveClassMap = new HashMap<Class<? extends Locatable>, Class<?>>();

    for (Class<?> possibleClass : jaxbMarshaller.getClassesToBeBound()) {
        GenologicsQueryResult queryAnno = possibleClass.getAnnotation(GenologicsQueryResult.class);
        GenologicsBatchRetrieveResult batchAnno = possibleClass
                .getAnnotation(GenologicsBatchRetrieveResult.class);

        if (queryAnno != null) {
            Class<? extends Locatable> entityClass = queryAnno.entityClass().asSubclass(Locatable.class);

            @SuppressWarnings("rawtypes")
            Class<? extends Batch> listClass = possibleClass.asSubclass(Batch.class);

            entityToListClassMap.put(entityClass, listClass);

            if (logger.isDebugEnabled()) {
                logger.debug("Results class {} mapped as query results for {}", getShortClassName(listClass),
                        getShortClassName(entityClass));
            }
        }

        if (batchAnno != null) {
            Class<? extends Locatable> entityClass = batchAnno.entityClass().asSubclass(Locatable.class);

            @SuppressWarnings("rawtypes")
            Class<? extends BatchUpdate> detailsClass = possibleClass.asSubclass(BatchUpdate.class);

            entityToBatchRetrieveClassMap.put(entityClass, detailsClass);

            if (logger.isDebugEnabled()) {
                logger.debug("Batch retrieve class {} mapped as entity holder for {}",
                        getShortClassName(detailsClass), getShortClassName(entityClass));
            }
        }
    }
}