Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 shop2020 1
/**
2
 * 
3
 */
4
package in.shop2020.metamodel.definitions;
5
 
6
/**
49 naveen 7
 * Singleton Catalog instance. Provides single point access to all entities and 
8
 * definitions in shop2020 content model
10 shop2020 9
 * 
10
 * @author naveen
11
 *
12
 */
13
public class Catalog {
14
	private static final Catalog catalog = new Catalog();
15
	/**
49 naveen 16
	 * Reference to root of shop2020 category tree
10 shop2020 17
	 */
18
	private Category rootCategory;
19
 
20
	/**
49 naveen 21
	 * Reference to aggregator of all definition objects
10 shop2020 22
	 */
23
	private DefinitionsContainer defsContainer;
24
 
25
	/**
49 naveen 26
	 * Reference to aggregator of all core objects
10 shop2020 27
	 */
28
	private EntityContainer entContainer;
29
 
30
	/**
31
	 * A private Constructor prevents any other class from instantiating
32
	 */
33
	private Catalog() {
34
	}
35
 
36
	/**
37
	 * 
38
	 * @return 	Catalog 	single instance of Catalog
39
	 */
40
	public static final Catalog getInstance() {
41
		return catalog;
42
	}
43
 
44
	/**
45
	 *  
49 naveen 46
	 * @return rootCategory Root Category
47
	 * @throws Exception 
10 shop2020 48
	 */
49 naveen 49
	public Category getRootCategory() throws Exception {
10 shop2020 50
		// lazily de-serialize from disk
49 naveen 51
		if(this.rootCategory == null) {
52
			DefinitionsContainer defs = this.getDefinitionsContainer();
53
			this.rootCategory = defs.getCategory(10000);
54
		}
55
 
10 shop2020 56
		return this.rootCategory;
57
	}
58
 
59
	/**
60
	 * 
49 naveen 61
	 * @return defsContainer Definitions Container
10 shop2020 62
	 */
18 naveen 63
	public DefinitionsContainer getDefinitionsContainer() {		
17 naveen 64
		if(this.defsContainer == null) {
65
			this.defsContainer = new DefinitionsContainer();
66
		}
10 shop2020 67
		return this.defsContainer;
68
	}
69
 
70
	/**
71
	 * 
49 naveen 72
	 * @return EntityContainer Core object's container
10 shop2020 73
	 */
18 naveen 74
	public EntityContainer getEntityContainer() {		
17 naveen 75
		if(this.entContainer == null) {
76
			this.entContainer = new EntityContainer();
77
		}
10 shop2020 78
		return this.entContainer;
79
	}
80
}