public void setThreadEventNotifier(ThreadEventNotifier threadEventNotifier) { this.threadEventNotifier = threadEventNotifier; threadEventNotifier.addThreadCleanupListener(this); }
public synchronized void cleanupThread() { if (_threadEventNotifier == null) _threadEventNotifier = (ThreadEventNotifier) getService( "hivemind.ThreadEventNotifier", ThreadEventNotifier.class, null); _threadEventNotifier.fireThreadCleanup(); }
public Object getServiceImplementationForCurrentThread() { PooledService pooled = (PooledService) _activeService.get(); if (pooled == null) { pooled = obtainPooledService(); pooled.activate(); _notifier.addThreadCleanupListener(pooled); _activeService.set(pooled); } return pooled.getService(); }
public void threadDidCleanup() { clear(); try { ContextAwareConnection connection = getConnection(); if (connection != null) connection.close(); } catch (RepositoryException e) { throw new ElmoPersistException(e); } threadEventNotifier.addThreadCleanupListener(this); }
private Object constructInstanceForCurrentThread() { try { Object core = constructCoreServiceImplementation(); if (core instanceof RegistryShutdownListener) _log.error(ServiceModelMessages.registryCleanupIgnored(getServicePoint())); _notifier.addThreadCleanupListener(new CleanupListener(core)); // Once more ... with bean services, its possible that // the factory generated bean does not implement the (synthetic) service // interface, so create a bridge to it. if (!_serviceInterface.isInstance(core)) core = constructBridgeProxy(core); _activeService.set(core); return core; } catch (Exception ex) { throw new ApplicationRuntimeException(ServiceModelMessages.unableToConstructService( getServicePoint(), ex), ex); } }