public void closeEntityManagers(long ownerId) {
		List<ScopedEntityManager> ems;
		if (ownerId==0) {
			// close all instances, entire app context was destroyed
			ems = new ArrayList<ScopedEntityManager>();
			synchronized(this) {
				for(List<ScopedEntityManager> list : emList.values())
					ems.addAll(list);
				emList.clear();				
			}
		} else {
			// close instances owned by this thread, httprequest context was destroyed 
			Long tid = Long.valueOf(ownerId);
			synchronized(this) {
				ems = emList.remove(tid);
			}
		}
		if (ems!=null) {
			for(int idx=ems.size()-1; idx>=0; idx--) 
				try { ems.get(idx).lazyClose(); } catch(Exception ex){}
		}		
	}