Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;

public class Main {
    @SuppressWarnings("rawtypes")
    private static Map<Class, JAXBContext> map = new ConcurrentHashMap<Class, JAXBContext>();

    private static <T> JAXBContext getContext(Class<T> c) throws JAXBException {

        if (!map.containsKey(c)) {
            System.out.println("-" + c.getSimpleName());
            map.put(c, JAXBContext.newInstance(c));
        }

        return (JAXBContext) map.get(c);
    }
}