KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > beans > config > LocalStore


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.beans.config;
14
15 import info.magnolia.cms.core.Content;
16 import info.magnolia.cms.core.HierarchyManager;
17
18 import javax.jcr.PathNotFoundException;
19 import javax.jcr.RepositoryException;
20
21 import org.apache.log4j.Logger;
22
23
24 /**
25  * @author Sameer Charles
26  * @version 2.0
27  */

28 public class LocalStore {
29
30     private static Logger log = Logger.getLogger(LocalStore.class);
31
32     private Content localStore;
33
34     private String JavaDoc configPath;
35
36     protected static LocalStore getInstance(String JavaDoc path) {
37         LocalStore store = new LocalStore();
38         store.configPath = path;
39         store.init();
40         return store;
41     }
42
43     private void init() {
44         log.info("Config : Initializing LocalStore for - " + configPath); //$NON-NLS-1$
45
HierarchyManager configHierarchyManager = ContentRepository.getHierarchyManager(ContentRepository.CONFIG);
46         try {
47             localStore = configHierarchyManager.getContent(configPath);
48             log.info("Config : LocalStore initialized for -" + configPath); //$NON-NLS-1$
49
}
50         catch (PathNotFoundException e) {
51             log.error("Config : No LocalStore defined for - " + configPath); //$NON-NLS-1$
52
}
53         catch (RepositoryException re) {
54             log.error("Config : Failed to initialize LocalStore for - " + configPath); //$NON-NLS-1$
55
log.error(re.getMessage(), re);
56         }
57     }
58
59     protected Content getStore() {
60         return localStore;
61     }
62 }
63
Popular Tags