KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > context > SimpleContext


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.context;
14
15 import java.util.Map JavaDoc;
16
17 import info.magnolia.cms.core.HierarchyManager;
18 import info.magnolia.cms.core.search.QueryManager;
19 import info.magnolia.cms.security.AccessManager;
20 import info.magnolia.cms.security.User;
21
22
23 /**
24  * Simple context delegatin methods to the threads locale context. This context should never get used as the threads
25  * locale context, but is useable in other contextes like for passing it to a command.
26  * @author Philipp Bracher
27  * @version $Revision: 6341 $ ($Author: philipp $)
28  */

29 public class SimpleContext extends AbstractMapBasedContext {
30
31     /**
32      * The context used to get hierarchy managers or similar.
33      */

34     private Context ctx;
35     
36     /**
37      * Using the threads locale context for getting hierarchy managers or similar
38      */

39     public SimpleContext() {
40         this(MgnlContext.getInstance());
41     }
42     
43     /**
44      * Decorate a map
45      */

46     public SimpleContext(Map JavaDoc map) {
47         super(map);
48         this.ctx = MgnlContext.getInstance();
49     }
50     
51
52     /**
53      * Use the passed context to get hierarchy managers or similar form
54      */

55     public SimpleContext(Context ctx) {
56         this.ctx = ctx;
57     }
58
59     /**
60      * Delegate to the inner context
61      */

62     public AccessManager getAccessManager(String JavaDoc repositoryId, String JavaDoc workspaceId) {
63         return this.ctx.getAccessManager(repositoryId, workspaceId);
64     }
65
66     /**
67      * Delegate to the inner context
68      */

69     public HierarchyManager getHierarchyManager(String JavaDoc repositoryId, String JavaDoc workspaceId) {
70         return this.ctx.getHierarchyManager(repositoryId, workspaceId);
71     }
72
73     /**
74      * Delegate to the inner context
75      */

76     public User getUser() {
77         return this.ctx.getUser();
78     }
79
80     /**
81      * Delegate to the inner context
82      */

83     public QueryManager getQueryManager(String JavaDoc repositoryId, String JavaDoc workspaceId) {
84         return this.ctx.getQueryManager(repositoryId, workspaceId);
85     }
86
87 }
88
Popular Tags