Project

General

Profile

Download (1.66 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2009 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9
package eu.etaxonomy.cdm.remote.json.processor;
10

    
11
import java.util.HashSet;
12
import java.util.Set;
13

    
14
import org.apache.log4j.Logger;
15

    
16
import eu.etaxonomy.cdm.model.common.CdmBase;
17
import net.sf.json.CycleSetAcess;
18

    
19
/**
20
 * @author a.kohlbecker
21
 * @since 30.03.2009
22
 * @deprecated class is not beeing used but kept as reference
23
 */
24
@Deprecated
25
public class CdmBeanProcessingRegistry extends CycleSetAcess {
26

    
27
	private static final Logger logger = Logger.getLogger(CdmBeanProcessingRegistry.class);
28

    
29
	protected static ThreadLocal<Set<CdmBase>> processedBeans = new ThreadLocal<Set<CdmBase>>(){
30
		      @Override
31
            protected synchronized Set<CdmBase> initialValue() {
32
		         return new HashSet<>();
33
		      }
34
		   };
35

    
36
	protected static boolean isBeingProcessed(Object bean) {
37
		if(logger.isDebugEnabled()){
38
			logger.debug("looking for: " + bean.getClass() + " with hash: " + bean.hashCode());
39
		}
40
		return processedBeans.get().contains(bean);
41
	}
42

    
43
	protected static void register(CdmBase bean){
44
		if(logger.isDebugEnabled()){
45
			logger.debug("registering: " + bean.getClass() + " with hash: " + bean.hashCode());
46
		}
47
		processedBeans.get().add(bean);
48
	}
49

    
50
	protected static void unregister(CdmBase bean){
51
		if(logger.isDebugEnabled()){
52
			logger.debug("un-registering: " + bean.getClass() + " with hash: " + bean.hashCode());
53
		}
54
		processedBeans.get().remove(bean);
55
	}
56

    
57
}
    (1-1/1)