Here you can find the source of getJaxbContext(String contextPath)
Parameter | Description |
---|---|
contextPath | the JAXB context path |
Parameter | Description |
---|---|
JAXBException | if the context could not be retrieved |
public static synchronized JAXBContext getJaxbContext(String contextPath) throws JAXBException
//package com.java2s; import java.util.HashMap; import java.util.Map; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; public class Main { private static final Map JAXB_CONTEXT_MAP = new HashMap(); /**//from ww w. j a v a 2 s . co m * Returns a JAXB context for the given context path. Contexts are * cached in a hash map. * @param contextPath the JAXB context path * @return the jaxb context for the given context path * @throws JAXBException if the context could not be retrieved */ public static synchronized JAXBContext getJaxbContext(String contextPath) throws JAXBException { JAXBContext ctx = (JAXBContext) JAXB_CONTEXT_MAP.get(contextPath); if (ctx == null) { ctx = JAXBContext.newInstance(contextPath); JAXB_CONTEXT_MAP.put(contextPath, ctx); } return ctx; } }