Java XML JAXB Context clearContextCache()

Here you can find the source of clearContextCache()

Description

clear Context Cache

License

Apache License

Declaration

public synchronized static void clearContextCache() 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.lang.ref.SoftReference;

import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.JAXBContext;

public class Main {
    private static final Map<Class<?>, SoftReference<JAXBContext>> contextCache = new HashMap<>();

    /**/* w  w  w  .j ava2  s  . c  om*/
     * @since 3.6
     */
    public synchronized static void clearContextCache() {
        for (SoftReference<JAXBContext> i : contextCache.values())
            i.clear();

        contextCache.clear();
    }

    /**
     * @since 3.6
     */
    public synchronized static void clearContextCache(final Class<?> bind) {
        SoftReference<JAXBContext> ref = contextCache.get(bind);
        if (ref != null) {
            ref.clear();
            contextCache.remove(bind);
        }
    }
}

Related

  1. createContext(final Class bind)
  2. createJaxbContextFor(Object obj, Class[] classes)
  3. createRIContext(Class clss[], String defaultNS)
  4. fromXML(JAXBContext context, String requestXML)