Source Code Cross Referenced for ResourceContext.java in  » Web-Server » Jigsaw » org » w3c » tools » resources » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Jigsaw » org.w3c.tools.resources 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // ResourceContext.java
002:        // $Id: ResourceContext.java,v 1.9 2000/08/16 21:37:53 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996, 1997.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.tools.resources;
007:
008:        import java.util.Hashtable;
009:
010:        /**
011:         * The resource context.
012:         */
013:        public class ResourceContext {
014:
015:            /**
016:             * debug flag
017:             */
018:            public static boolean debug = false;
019:
020:            /**
021:             * Our parent context, if any.
022:             */
023:            protected ResourceContext parent = null;
024:            /**
025:             * The set of registered modules.
026:             */
027:            public Hashtable modules = null;
028:
029:            /**
030:             * Our Resource Space.
031:             */
032:            protected ResourceSpace space = null;
033:
034:            /**
035:             * The server of that resource context.
036:             */
037:            protected ServerInterface server = null;
038:
039:            /**
040:             * The ResourceReference of our resource.
041:             */
042:            protected ResourceReference reference = null;
043:
044:            /**
045:             * The ResourceReference of the resource container.
046:             */
047:            protected ResourceReference container = null;
048:
049:            /**
050:             * Get the container of the resource.
051:             * @return A ResourceReference instance.
052:             */
053:            public ResourceReference getContainer() {
054:                return container;
055:            }
056:
057:            /**
058:             * Get the ResourceReference of the resource.
059:             * @return a ResourceReference instance.
060:             */
061:            public ResourceReference getResourceReference() {
062:                return reference;
063:            }
064:
065:            /**
066:             * Set the ResourceReference of the resource.
067:             * @param reference The ResourceReference to set.
068:             */
069:            public void setResourceReference(ResourceReference reference) {
070:                this .reference = reference;
071:                reference.updateContext(this );
072:            }
073:
074:            /**
075:             * Get our Resource Space.
076:             * @return A ResourceSpace instance.
077:             */
078:            public ResourceSpace getSpace() {
079:                return space;
080:            }
081:
082:            /**
083:             * Set the Resource Space.
084:             * @param space Our Resource Space.
085:             */
086:            public void setSpace(ResourceSpace space) {
087:                this .space = space;
088:            }
089:
090:            /**
091:             * Get the server this context is attached to.
092:             * @return An ServerInterface instance 
093:             * (guaranteed not to be <strong>null</strong>.)
094:             */
095:
096:            public ServerInterface getServer() {
097:                return server;
098:            }
099:
100:            /**
101:             * Get that context's ancestor.
102:             * @return A ResourceContext instance, or <strong>null</strong>.
103:             */
104:
105:            public ResourceContext getParent() {
106:                return parent;
107:            }
108:
109:            /**
110:             * Register a module within that resource context.
111:             * @param name The module's name.
112:             * @param impl The module's implementation.
113:             */
114:
115:            public synchronized void registerModule(String name, Object impl) {
116:                if (modules == null)
117:                    modules = new Hashtable(7);
118:                modules.put(name, impl);
119:            }
120:
121:            /**
122:             * Lookup a module within that resource context.
123:             * @param name Name of the module to look for.
124:             * @param inherited Also look within the contexts hierarchy for an 
125:             * inherited module having that name.
126:             */
127:
128:            public Object getModule(String name, boolean inherited) {
129:                Object impl = ((modules == null) ? null : modules.get(name));
130:                if (inherited && (parent != null) && (impl == null))
131:                    impl = parent.getModule(name, true);
132:                return impl;
133:            }
134:
135:            /**
136:             * Lookup a module within that context, and up the hierarchy of contexts.
137:             * @param name The module's name.
138:             * @return An object <em>implementing</em> that module.
139:             */
140:
141:            public Object getModule(String name) {
142:                return getModule(name, true);
143:            }
144:
145:            public String toString() {
146:                String tostring = "\nResourceContext : ";
147:                if (parent == null)
148:                    tostring += "\n\tparent    : null";
149:                tostring += "\n\tcontainer : " + container;
150:                tostring += "\n\tspace     : " + space;
151:                tostring += "\n\tserver    : " + server;
152:                return tostring;
153:            }
154:
155:            /**
156:             * Create a ResourceContext from a container.
157:             * @param container The resource container.
158:             */
159:            public ResourceContext(ContainerResource container) {
160:                this .parent = container.getContext();
161:                this .container = container.getResourceReference();
162:                this .space = (parent != null) ? parent.space : null;
163:                this .server = (parent != null) ? parent.server : null;
164:                if ((this .container == null) && debug) {
165:                    System.out.println("[1] container has no Reference");
166:                    org.w3c.util.Trace.showTrace();
167:                }
168:            }
169:
170:            /**
171:             * Create a ResourceContext from a container ResourceReference.
172:             * @param container The resource reference of the container. 
173:             * Must be an instance of ContainerResource.
174:             */
175:            public ResourceContext(ResourceReference rr_container) {
176:                try {
177:                    Resource res = rr_container.lock();
178:                    this .parent = res.getContext();
179:                    this .container = rr_container;
180:                    this .space = (parent != null) ? parent.space : null;
181:                    this .server = (parent != null) ? parent.server : null;
182:                } catch (InvalidResourceException ex) {
183:                    //should be valid
184:                    ex.printStackTrace();
185:                } finally {
186:                    rr_container.unlock();
187:                }
188:            }
189:
190:            /**
191:             * Create a ResourceContext from the parent context.
192:             * @param parent The parent resource context.
193:             */
194:            public ResourceContext(ResourceContext parent) {
195:                this .parent = parent;
196:                this .container = parent.getResourceReference();
197:                this .space = parent.space;
198:                this .server = parent.server;
199:                if ((this .container == null) && debug) {
200:                    System.out.println("[2] parent context has no reference");
201:                    org.w3c.util.Trace.showTrace();
202:                }
203:            }
204:
205:            /**
206:             * Create a ResourceContext.
207:             * @param space The ResourceSpace.
208:             * @param server The server.
209:             */
210:            public ResourceContext(ResourceSpace space, ServerInterface server) {
211:                this .server = server;
212:                this .space = space;
213:                this .container = null;
214:                this .parent = null;
215:            }
216:
217:            /**
218:             * Create a ResourceContext.
219:             * @param server The server.
220:             */
221:            public ResourceContext(ServerInterface server) {
222:                this.server = server;
223:                this.space = null;
224:                this.container = null;
225:                this.parent = null;
226:            }
227:
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.