View Javadoc
1   package org.kuali.ole.ncip.converter;
2   
3   import javax.xml.bind.JAXBContext;
4   import javax.xml.bind.JAXBException;
5   import java.util.HashMap;
6   import java.util.Map;
7   
8   /**
9    * Created with IntelliJ IDEA.
10   * User: pvsubrah
11   * Date: 5/22/13
12   * Time: 10:36 AM
13   * To change this template use File | Settings | File Templates.
14   */
15  public class JAXBContextFactory {
16      private static Map<Class, JAXBContext> map = new HashMap<Class, JAXBContext>();
17  
18      public synchronized static JAXBContext getJAXBContextForClass(Class clazz) {
19          if (!map.containsKey(clazz)) {
20              try {
21                  map.put(clazz, JAXBContext.newInstance(clazz));
22              } catch (JAXBException e) {
23                  e.printStackTrace();
24              }
25          }
26          return map.get(clazz);
27      }
28  }