Java XML JAXB Context getContext(Class clazz)

Here you can find the source of getContext(Class clazz)

Description

get Context

License

Open Source License

Declaration

private static JAXBContext getContext(Class<?> clazz) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import com.google.common.collect.Maps;
import javax.xml.bind.*;

import java.util.Map;

public class Main {
    private static final Map<Class<?>, JAXBContext> CONTEXTS = Maps.newHashMap();

    private static JAXBContext getContext(Class<?> clazz) {
        JAXBContext context = CONTEXTS.get(clazz);
        if (context == null) {
            try {
                context = JAXBContext.newInstance(clazz);
            } catch (JAXBException e) {
                throw new RuntimeException("Failed to create JAXBContext for type " + clazz, e);
            }/*w ww .j av  a2s  .  co m*/
            CONTEXTS.put(clazz, context);
        }
        return context;
    }
}

Related

  1. getContext()
  2. getContext()
  3. getContext()
  4. getContext()
  5. getContext(Class c)
  6. getContext(final Class theClass)
  7. getContext(String uddiVersion)
  8. getContextFor(final Class clazz)
  9. getContextForNamespace(String namespace)