List of usage examples for java.lang ThreadLocal ThreadLocal
public ThreadLocal()
From source file:biz.c24.io.spring.batch.processor.C24ValidatingItemProcessor.java
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { validators = new ThreadLocal<ValidationManager>(); }
From source file:org.openedit.entermedia.generators.XsltGenerator.java
protected ThreadLocal getTransformers() { if (fieldTransformers == null) { fieldTransformers = new ThreadLocal(); }// w w w .j av a 2 s . c om return fieldTransformers; }
From source file:monasca.api.infrastructure.persistence.vertica.AlarmStateHistoryVerticaRepoImpl.java
@Inject public AlarmStateHistoryVerticaRepoImpl(@Named("vertica") DBI vertica, Utils utils, PersistUtils persistUtils) { this.vertica = vertica; this.utils = utils; this.persistUtils = persistUtils; this.simpleDateFormatter = new ThreadLocal<>(); }
From source file:org.kuali.rice.krad.service.impl.SerializerServiceBase.java
public SerializerServiceBase() { evaluators = new ThreadLocal<>(); currentPathTracker = new ThreadLocal<>(); pathToSerializationState = new ThreadLocal<>(); xstream = new XStream(new ProxyAndStateAwareJavaReflectionProvider()); xstream.setMarshallingStrategy(new PathTrackerSmugglingMarshallingStrategy(currentPathTracker)); xstream.registerConverter(new ProxyConverter(xstream.getMapper(), xstream.getReflectionProvider())); try {/* w w w .j a v a 2 s. c o m*/ Class<?> objListProxyClass = Class.forName("org.apache.ojb.broker.core.proxy.ListProxyDefaultImpl"); xstream.addDefaultImplementation(ArrayList.class, objListProxyClass); xstream.addDefaultImplementation(AutoPopulatingList.class, objListProxyClass); } catch (Exception ex) { // Do nothing - this will blow if the OJB class does not exist, which it won't in some installs } xstream.registerConverter(new AutoPopulatingListConverter(xstream.getMapper())); xstream.registerConverter(new DateTimeConverter()); }
From source file:org.jbpm.JbpmContext.java
/** * resets static members for test isolation. */ static void reset() { currentContextsStack = new ThreadLocal(); }
From source file:org.ehoffman.aopalliance.extensions.scope.SpringTestScope.java
private void initialize() { values = new NamedThreadLocal<HashMap<String, Object>>("value") { @Override/* w ww . j a v a 2 s. com*/ protected HashMap<String, Object> initialValue() { return new HashMap<String, Object>(); } }; destroyCallbacks = new ThreadLocal<Map<String, Runnable>>() { @Override protected Map<String, Runnable> initialValue() { final HashMap<String, Runnable> destroyCallbackMap = new HashMap<String, Runnable>(); destroyCallbackMaps.add(destroyCallbackMap); return destroyCallbackMap; } }; dependencies = new ThreadLocal<Map<String, List<String>>>() { @Override protected Map<String, List<String>> initialValue() { return new HashMap<String, List<String>>(); } }; count = new ThreadLocal<Integer>() { @Override protected Integer initialValue() { return 0; } }; }
From source file:org.apache.lens.cube.metadata.UpdatePeriod.java
private static DateFormat getWeeklyFormat() { if (weeklyFormat == null) { weeklyFormat = new ThreadLocal<DateFormat>() { @Override/* w w w .j ava 2 s . c o m*/ protected SimpleDateFormat initialValue() { return new SimpleDateFormat(WEEKLY.formatStr()); } }; } return weeklyFormat.get(); }
From source file:org.apache.kylin.common.KylinConfig.java
public static void destroyInstance() { synchronized (KylinConfig.class) { logger.info("Destroy KylinConfig"); dumpStackTrace();//w w w .ja v a 2 s . c om SYS_ENV_INSTANCE = null; THREAD_ENV_INSTANCE = new ThreadLocal<>(); } }
From source file:org.apache.hive.service.cli.thrift.ThriftCLIService.java
public ThriftCLIService(CLIService service, String serviceName) { super(serviceName); this.cliService = service; currentServerContext = new ThreadLocal<ServerContext>(); serverEventHandler = new TServerEventHandler() { @Override// www. j a v a 2s.com public ServerContext createContext(TProtocol input, TProtocol output) { return new ThriftCLIServerContext(); } @Override public void deleteContext(ServerContext serverContext, TProtocol input, TProtocol output) { ThriftCLIServerContext context = (ThriftCLIServerContext) serverContext; SessionHandle sessionHandle = context.getSessionHandle(); if (sessionHandle != null) { LOG.info("Session disconnected without closing properly, close it now"); try { cliService.closeSession(sessionHandle); } catch (HiveSQLException e) { LOG.warn("Failed to close session: " + e, e); } } } @Override public void preServe() { } @Override public void processContext(ServerContext serverContext, TTransport input, TTransport output) { currentServerContext.set(serverContext); } }; }
From source file:com.agapple.asyncload.impl.pool.AsyncLoadThreadPool.java
@Override public void execute(Runnable command) { if (command instanceof AsyncLoadFuture) { AsyncLoadFuture afuture = (AsyncLoadFuture) command; boolean flag = afuture.getConfig().getNeedThreadLocalSupport(); if (flag) { Thread thread = Thread.currentThread(); if (ReflectionUtils.getField(threadLocalField, thread) == null) { // ThreadLocal, new ThreadLocal<Boolean>(); // runnerThreadLocalMap }/* w w w . j a v a 2 s . c om*/ if (ReflectionUtils.getField(inheritableThreadLocalField, thread) == null) { // ThreadLocal, new InheritableThreadLocal<Boolean>(); // ?ThreadLocal } } } super.execute(command);// ?? }