Source Code Cross Referenced for DataContext.java in  » J2EE » Expresso » com » jcorporate » expresso » kernel » 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 » J2EE » Expresso » com.jcorporate.expresso.kernel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:         * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
003:         *
004:         * Copyright (c) 1995-2003 Jcorporate Ltd. All rights reserved.
005:         *
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions
008:         * are met:
009:         *
010:         * 1. Redistributions of source code must retain the above copyright
011:         *    notice, this list of conditions and the following disclaimer.
012:         *
013:         * 2. Redistributions in binary form must reproduce the above copyright
014:         *    notice, this list of conditions and the following disclaimer in
015:         *    the documentation and/or other materials provided with the
016:         *    distribution.
017:         *
018:         * 3. The end-user documentation included with the redistribution,
019:         *    if any, must include the following acknowledgment:
020:         *       "This product includes software developed by Jcorporate Ltd.
021:         *        (http://www.jcorporate.com/)."
022:         *    Alternately, this acknowledgment may appear in the software itself,
023:         *    if and wherever such third-party acknowledgments normally appear.
024:         *
025:         * 4. "Jcorporate" and product names such as "Expresso" must
026:         *    not be used to endorse or promote products derived from this
027:         *    software without prior written permission. For written permission,
028:         *    please contact info@jcorporate.com.
029:         *
030:         * 5. Products derived from this software may not be called "Expresso",
031:         *    or other Jcorporate product names; nor may "Expresso" or other
032:         *    Jcorporate product names appear in their name, without prior
033:         *    written permission of Jcorporate Ltd.
034:         *
035:         * 6. No product derived from this software may compete in the same
036:         *    market space, i.e. framework, without prior written permission
037:         *    of Jcorporate Ltd. For written permission, please contact
038:         *    partners@jcorporate.com.
039:         *
040:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
041:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
042:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
043:         * DISCLAIMED.  IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
044:         * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
045:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
046:         * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
047:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
048:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
049:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
050:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
051:         * SUCH DAMAGE.
052:         * ====================================================================
053:         *
054:         * This software consists of voluntary contributions made by many
055:         * individuals on behalf of the Jcorporate Ltd. Contributions back
056:         * to the project(s) are encouraged when you make modifications.
057:         * Please send them to support@jcorporate.com. For more information
058:         * on Jcorporate Ltd. and its products, please see
059:         * <http://www.jcorporate.com/>.
060:         *
061:         * Portions of this software are based upon other open source
062:         * products and are subject to their respective licenses.
063:         */
064:        package com.jcorporate.expresso.kernel;
065:
066:        import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
067:        import com.jcorporate.expresso.kernel.exception.ConfigurationException;
068:        import org.apache.log4j.Logger;
069:
070:        import java.util.Collections;
071:        import java.util.Map;
072:
073:        /**
074:         * This class is the code equivilant of the original &lt;context&gt; tag in
075:         * the older expresso-config files.  It is basically a container used to
076:         * map components to their underlying data sources.
077:         * <p>Each data context will have at most one Persistence engine.  It could
078:         * be JDBC, or in the future, EJB, or even CSV files for persistence.</p>
079:         * <p>Each data context can use other data contexts for security.  This is
080:         * set via the <code>securityContext</code> property.
081:         *
082:         * @author Michael Rimov
083:         * @since Expresso 5.1
084:         */
085:        public class DataContext extends ContainerComponentBase implements 
086:                ComponentLifecycle {
087:            static Logger log = Logger.getLogger(DataContext.class);
088:
089:            private Map setupValues;
090:
091:            private Map customProperties;
092:
093:            private String securityContext;
094:
095:            private Boolean hasSetupTables = Boolean.TRUE;
096:
097:            private String contextDescription = "Default Context";
098:            private boolean mailDebug;
099:
100:            /**
101:             * The default constructor.  Should do nothing.
102:             */
103:            public DataContext() {
104:
105:            }
106:
107:            /**
108:             * Retrieve a 'setup value'. This is a String property identical to the
109:             * old Setup table, but any setup values here are context-wide... as opposed
110:             * to Setup values for the root container have runtime scope.
111:             *
112:             * @param key the key of the context.
113:             * @return java.lang.String, the value of the property
114:             */
115:            public synchronized String getSetupValue(String key) {
116:                return (String) setupValues.get(key);
117:            }
118:
119:            /**
120:             * Sets the particular setup value to the specified string.
121:             *
122:             * @param key    the key of the setup value
123:             * @param object the value of the setup value.
124:             */
125:            public synchronized void setSetupValue(String key, String object) {
126:                setupValues.put(key, object);
127:            }
128:
129:            /**
130:             * Retrieves a map of all setup values for this data context.  The setup
131:             * values map is read only and will not allow any modifications.
132:             *
133:             * @return java.util.Map that is unmodifiable.
134:             */
135:            public synchronized Map getSetupValues() {
136:                return Collections.unmodifiableMap(setupValues);
137:            }
138:
139:            /**
140:             * Sets the security context for this data context.  The security context
141:             * is the context used for any of the traditional 'setup tables'
142:             *
143:             * @param newValue The name of the Security Context to map to
144:             */
145:            public synchronized void setSecurityContext(String newValue) {
146:                securityContext = newValue;
147:            }
148:
149:            /**
150:             * Retrieve the name of the security context to use for objects in this
151:             * data context.
152:             *
153:             * @return java.lang.String
154:             */
155:            public synchronized String getSecurityContext() {
156:                String returnValue = this .securityContext;
157:                if (securityContext == null || securityContext.length() == 0) {
158:                    returnValue = this .getMetaData().getName();
159:                }
160:
161:                return returnValue;
162:            }
163:
164:            /**
165:             * Implementation of the ExpressoComponent initialize() component lifecycle
166:             * event.
167:             */
168:            public synchronized void initialize() {
169:                if (log.isDebugEnabled()) {
170:                    log.debug("Initialing DataContext Container");
171:                }
172:                setupValues = new ConcurrentReaderHashMap(1);
173:            }
174:
175:            /**
176:             * This is the implementation of the ExpressoComponent configure() component
177:             * event lifecycle.
178:             *
179:             * @param newConfig The 'read only' configuration bean that provides all
180:             *                  the seutp values.
181:             * @throws ConfigurationException upon error.
182:             */
183:            public synchronized void configure(Configuration newConfig)
184:                    throws ConfigurationException {
185:                Map newSetupValues = newConfig
186:                        .getMappedProperties("SetupValue");
187:                if (newSetupValues != null) {
188:                    this .setupValues = new ConcurrentReaderHashMap(
189:                            newSetupValues);
190:                }
191:
192:                Map customProperties = newConfig
193:                        .getMappedProperties("CustomProperty");
194:                if (customProperties != null) {
195:                    this .customProperties = new ConcurrentReaderHashMap(
196:                            customProperties);
197:                }
198:
199:                this .setContextDescription((String) newConfig
200:                        .get("ContextDescription"));
201:                this .setSecurityContext((String) newConfig
202:                        .get("SecurityContext"));
203:                this .setHasSetupTables((Boolean) newConfig
204:                        .get("HasSetupTables"));
205:                this .setMailDebug((Boolean) newConfig.get("MailDebug"));
206:            }
207:
208:            /**
209:             * Reconfiguration implementation of the Expresso event lifecycles.
210:             *
211:             * @param newConfig The 'read only' configuration bean that provides all
212:             *                  the seutp values.
213:             * @throws ConfigurationException upon error
214:             */
215:            public synchronized void reconfigure(Configuration newConfig)
216:                    throws ConfigurationException {
217:                setupValues = null;
218:                customProperties = null;
219:                securityContext = null;
220:                contextDescription = null;
221:                setHasSetupTables(null);
222:
223:                configure(newConfig);
224:            }
225:
226:            /**
227:             * Destroy event of the ComponentLifecycle interface.  The underlying
228:             * container implementation does the acutal destroying of all subcomponents
229:             * before this component is itself destroyed.
230:             */
231:            public synchronized void destroy() {
232:                if (log.isDebugEnabled()) {
233:                    log.debug("Destroying DataContext Container name: "
234:                            + this .getMetaData().getName());
235:                }
236:                setupValues = null;
237:                securityContext = null;
238:            }
239:
240:            /**
241:             * Sets the 'Has Setup Tables' parameter.  This may disappear in the future
242:             * since it merely designates that the ExpressoSchema should be included
243:             * in this particular data context.
244:             *
245:             * @param hasSetupTables Boolean value if it does.
246:             */
247:            public synchronized void setHasSetupTables(Boolean hasSetupTables) {
248:                this .hasSetupTables = hasSetupTables;
249:            }
250:
251:            /**
252:             * Returns a boolean value equivilant to the tranditional javabean
253:             * naming convention.
254:             *
255:             * @return boolean true if this context has setup tables in it.
256:             */
257:            public synchronized boolean isSetupTables() {
258:                return hasSetupTables.booleanValue();
259:            }
260:
261:            /**
262:             * Returns a Boolean object value equivilant to the tranditional javabean
263:             * naming convention.
264:             *
265:             * @return Boolean.
266:             */
267:            public synchronized Boolean getHasSetupTables() {
268:                return hasSetupTables;
269:            }
270:
271:            /**
272:             * Sets the context description.
273:             *
274:             * @param contextDescription The name of the context
275:             */
276:            public synchronized void setContextDescription(
277:                    String contextDescription) {
278:                this .contextDescription = contextDescription;
279:            }
280:
281:            /**
282:             * Retrieves the context description
283:             *
284:             * @return java.lang.String
285:             */
286:            public synchronized String getContextDescription() {
287:                return contextDescription;
288:            }
289:
290:            /**
291:             * Custom Properties Map that was identical to that of the customProperties
292:             * in the old Expresso 5 config file.  It is recommended that you no longer
293:             * use this.
294:             *
295:             * @return java.util.Map
296:             */
297:            public synchronized Map getCustomProperties() {
298:                return customProperties;
299:            }
300:
301:            /**
302:             * Retrieves the custom property by key.
303:             *
304:             * @param key the key of the property name to look up
305:             * @return java.lang.String, the value of the key.
306:             */
307:            public synchronized String getCustomProperty(String key) {
308:                return (String) customProperties.get(key);
309:            }
310:
311:            /**
312:             * Sets whether emailings performed from the system should be debugged or
313:             * not.
314:             *
315:             * @param mailDebug boolean if mail should be debugged
316:             */
317:            public void setMailDebug(Boolean mailDebug) {
318:                this .mailDebug = mailDebug.booleanValue();
319:            }
320:
321:            public void setMailDebug(boolean mailDebug) {
322:                this .mailDebug = mailDebug;
323:            }
324:
325:            public boolean isMailDebug() {
326:                return mailDebug;
327:            }
328:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.