Here you can find the source of createMarshall(String pkgName)
private static Marshaller createMarshall(String pkgName) throws JAXBException
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; public class Main { private static final HashMap<String, JAXBContext> marshallContexts = new HashMap<String, JAXBContext>(); private static Marshaller createMarshall(String pkgName) throws JAXBException { JAXBContext jaxbCtx = null; if ((jaxbCtx = marshallContexts.get(pkgName)) == null) { jaxbCtx = JAXBContext.newInstance(pkgName); marshallContexts.put(pkgName, jaxbCtx); }// w ww. j a v a 2s .c o m Marshaller marshaller = jaxbCtx.createMarshaller(); return marshaller; } }