Java ConcurrentMap get(Class clazz)

Here you can find the source of get(Class clazz)

Description

get

License

Apache License

Declaration

private static Logger get(Class<?> clazz) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Main {
    @SuppressWarnings("rawtypes")
    private static final ConcurrentMap<Class, Logger> loggers = new ConcurrentHashMap<Class, Logger>();

    private static Logger get(Class<?> clazz) {
        if (clazz == null) {
            return null;
        }//from w w w  .  ja v  a  2  s. c o m
        Logger logger = loggers.get(clazz);
        if (logger == null) {
            logger = LoggerFactory.getLogger(clazz);
            loggers.put(clazz, logger);
        }
        return logger;
    }

    private static Logger get(Object obj) {
        if (obj == null) {
            return null;
        }
        Class<?> clazz = obj.getClass();
        Logger logger = loggers.get(clazz);
        if (logger == null) {
            logger = LoggerFactory.getLogger(clazz);
            loggers.put(clazz, logger);
        }
        return logger;
    }
}

Related

  1. createConcurrentMap()
  2. createConcurrentMap(int initial_capacity, float load_factor, int concurrency_level)
  3. extractKeySize(String sslCipherSuite)
  4. fileReaderDecrement(ConcurrentMap readers, Long fileNum)
  5. fileReaderIncrement(ConcurrentMap readers, Long fileNum)
  6. getCache(String cacheName)
  7. getConcurrentMap(int... size)
  8. getContextPath()
  9. getFilesystem(String id)