Example usage for java.lang ThreadLocal ThreadLocal

List of usage examples for java.lang ThreadLocal ThreadLocal

Introduction

In this page you can find the example usage for java.lang ThreadLocal ThreadLocal.

Prototype

public ThreadLocal() 

Source Link

Document

Creates a thread local variable.

Usage

From source file:edu.wfu.inotado.jobs.HierarchyPropertyUpdateJob.java

public void init() {
    // initialize to avoid NPE
    paramsLocal = new ThreadLocal<Map<String, Object>>();
    paramsLocal.set(new HashMap<String, Object>());
}

From source file:org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil.java

/**
 * Creates a new boolean thread local variable
 * /*from  www.j av  a2s.  c o  m*/
 * @param initialValue
 * @return {@link ThreadLocal}
 */
private static ThreadLocal<Boolean> newBooleanThreadLocal(final Boolean initialValue) {
    ThreadLocal<Boolean> threadLocal = new ThreadLocal<Boolean>() {
        @Override
        protected Boolean initialValue() {
            return initialValue;
        }
    };

    return threadLocal;
}

From source file:podd.util.db.impl.HibernateSessionFactoryImpl.java

public HibernateSessionFactoryImpl(String configurationFileURL) {
    map = new ThreadLocal<Session>();
    LOG.debug("HibernateSessionFactoryUtil.static - loading config");
    final Configuration configuration = new Configuration().setProperties(Environment.getProperties());
    factory = configuration.configure(configurationFileURL).buildSessionFactory();
    LOG.debug("HibernateSessionFactoryUtil.static - end");
}

From source file:edu.wfu.inotado.jobs.CustomPropertyUpdateJob.java

public void init() {
    // initialize to avoid NPE
    propMapLocal = new ThreadLocal<Map<String, Properties>>();
    propMapLocal.set(new HashMap<String, Properties>());
}

From source file:de.codecentric.batch.metrics.BatchMetricsImpl.java

public BatchMetricsImpl() {
    this.serviceKey = new Object();
    this.metricContainer = new ThreadLocal<MetricContainer>();
}

From source file:com.axiomine.largecollections.utilities.KryoUtils.java

public static ThreadLocal<Kryo> getThreadLocalKryos() {
    ThreadLocal<Kryo> kryos = new ThreadLocal<Kryo>() {
        protected Kryo initialValue() {
            Kryo kryo = new Kryo();
            KryoUtils.registerKryoClasses(kryo);
            return kryo;
        };//from w w w .  j  a va  2  s. co m
    };
    return kryos;
}

From source file:it.delli.mwebc.event.listener.EventExecutor.java

public void run() {
    new ThreadLocal<>().set(threadLocal);
    synchronized (event.getPage()) {
        if (forwardMethod != null) {
            if (event.getWidget() != null) {
                log.info("Executing forward method " + eventListener.getClass().getName() + "."
                        + forwardMethod.getName() + " for event " + event.getName() + " on widget "
                        + event.getWidget().getClass().getName() + " (" + event.getWidget().getId() + ")");
            } else {
                log.info("Executing forward method " + eventListener.getClass().getName() + "."
                        + forwardMethod.getName() + " for event " + event.getName());
            }/*from w ww  . j  a v a2 s  . co m*/
            try {
                forwardMethod.invoke(eventListener, event);
            } catch (Exception e) {
                if (event.getWidget() != null) {
                    log.error("Exception in executing of forward method " + eventListener.getClass().getName()
                            + "." + forwardMethod.getName() + " for event " + event.getName() + " on widget "
                            + event.getWidget().getClass().getName() + " (" + event.getWidget().getId() + ")",
                            e);
                } else {
                    log.error("Exception in executing of forward method " + eventListener.getClass().getName()
                            + "." + forwardMethod.getName() + " for event " + event.getName(), e);
                }
                log.error("Exception in forward method execution", e);
            }
            if (event.getWidget() != null) {
                log.info("Notifying end of execution of forward method " + eventListener.getClass().getName()
                        + "." + forwardMethod.getName() + " for event " + event.getName() + " on widget "
                        + event.getWidget().getClass().getName() + " (" + event.getWidget().getId() + ")");
            } else {
                log.info("Notifying end of execution of forward method " + eventListener.getClass().getName()
                        + "." + forwardMethod.getName() + " for event " + event.getName());
            }
        } else {
            log.info("Forward method does not exist in event listener " + eventListener.getClass().getName()
                    + " for event " + event.getName());
            log.info("Notifying end of failed execution for event " + event.getName());
        }
        event.getPage().notify();
    }
}

From source file:com.jaspersoft.jasperserver.api.metadata.common.service.impl.HibernateDaoImpl.java

public HibernateDaoImpl() {
    operationDate = new ThreadLocal();
}

From source file:org.alfresco.encryption.MACUtils.java

/**
 * Default constructor for IOC
 */
public MACUtils() {
    threadMac = new ThreadLocal<Mac>();
}

From source file:com.liusoft.util.db.Hibernate.java

/**
 * ???Hibernate//w w  w.  ja va2  s  .co  m
 * @param cfg_path
 */
private Hibernate(String cfg_path) {
    sessions = new ThreadLocal();
    transactions = new ThreadLocal();
    Configuration cfg = new Configuration().configure(new File(cfg_path));
    sessionFactory = cfg.buildSessionFactory();
    this.hibernate_cfg = cfg_path;
}