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


001:        /* The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
002:         *
003:         * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
004:         *
005:         * Redistribution and use in source and binary forms, with or without
006:         * modification, are permitted provided that the following conditions
007:         * are met:
008:         *
009:         * 1. Redistributions of source code must retain the above copyright
010:         *    notice, this list of conditions and the following disclaimer.
011:         *
012:         * 2. Redistributions in binary form must reproduce the above copyright
013:         *    notice, this list of conditions and the following disclaimer in
014:         *    the documentation and/or other materials provided with the
015:         *    distribution.
016:         *
017:         * 3. The end-user documentation included with the redistribution,
018:         *    if any, must include the following acknowledgment:
019:         *       "This product includes software developed by Jcorporate Ltd.
020:         *        (http://www.jcorporate.com/)."
021:         *    Alternately, this acknowledgment may appear in the software itself,
022:         *    if and wherever such third-party acknowledgments normally appear.
023:         *
024:         * 4. "Jcorporate" and product names such as "Expresso" must
025:         *    not be used to endorse or promote products derived from this
026:         *    software without prior written permission. For written permission,
027:         *    please contact info@jcorporate.com.
028:         *
029:         * 5. Products derived from this software may not be called "Expresso",
030:         *    or other Jcorporate product names; nor may "Expresso" or other
031:         *    Jcorporate product names appear in their name, without prior
032:         *    written permission of Jcorporate Ltd.
033:         *
034:         * 6. No product derived from this software may compete in the same
035:         *    market space, i.e. framework, without prior written permission
036:         *    of Jcorporate Ltd. For written permission, please contact
037:         *    partners@jcorporate.com.
038:         *
039:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
040:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
041:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
042:         * DISCLAIMED.  IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
043:         * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
044:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
045:         * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
046:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
047:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
048:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
049:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
050:         * SUCH DAMAGE.
051:         * ====================================================================
052:         *
053:         * This software consists of voluntary contributions made by many
054:         * individuals on behalf of the Jcorporate Ltd. Contributions back
055:         * to the project(s) are encouraged when you make modifications.
056:         * Please send them to support@jcorporate.com. For more information
057:         * on Jcorporate Ltd. and its products, please see
058:         * <http://www.jcorporate.com/>.
059:         *
060:         * Portions of this software are based upon other open source
061:         * products and are subject to their respective licenses.
062:         */
063:
064:        package com.jcorporate.expresso.core.registry;
065:
066:        import com.jcorporate.expresso.core.security.User;
067:
068:        /**
069:         * Thread context is closely tied with the RequestRegistry.  What it does
070:         * is glean the RequestRegistry from one thread and allow that information
071:         * to be passed to another.
072:         * <p>Typical Usage:
073:         * <code><pre>
074:         * //Sets the internal members
075:         * ExpressoThreadContext context = new ExpressoThreadContext();
076:         * <p/>
077:         * //Sample thread
078:         * Thread myThread = new MyThread();
079:         * myThread.setThreadContext(context);
080:         * <p/>
081:         * .....
082:         * <p/>
083:         * Then in 'MyThread'....
084:         * <p/>
085:         * void run() {
086:         *      context.applySettingsToCurrentThread();
087:         *      ....
088:         * }
089:         * </pre></code>
090:         * </p>
091:         * <p>If you change the API for the RequestRegistry by adding more items
092:         * , then you need to change this class as well to allow transport of the
093:         * request registry between threads.</p>
094:         *
095:         * @author Michael Rimov
096:         */
097:        public class ExpressoThreadContext {
098:            /**
099:             * The Security credentials of the user who's permissions are being
100:             * used for this thread.
101:             */
102:            private User user;
103:
104:            /**
105:             * The data context that is being used for defaults for this thread.
106:             */
107:            private String dataContext;
108:
109:            /**
110:             * Default constructor.
111:             */
112:            public ExpressoThreadContext() {
113:                super ();
114:                setDataContext(RequestRegistry.getDataContext());
115:                setUser(RequestRegistry.getUser());
116:            }
117:
118:            /**
119:             * Takes the settings that were in the thread that this object
120:             * resided in when it was created and applies it to the thread that
121:             * it is currently running in.
122:             */
123:            public void applyToCurrentThread() {
124:                new MutableRequestRegistry(getDataContext(), getUser());
125:            }
126:
127:            /**
128:             * Protected setter.  Sets the user for the thread context.
129:             *
130:             * @param user User
131:             */
132:            protected void setUser(User user) {
133:                this .user = user;
134:            }
135:
136:            /**
137:             * Sets the data context.  Protected.
138:             *
139:             * @param dataContext String
140:             */
141:            protected void setDataContext(String dataContext) {
142:                this .dataContext = dataContext;
143:            }
144:
145:            /**
146:             * Retreive the user.
147:             *
148:             * @return User
149:             */
150:            public User getUser() {
151:                return user;
152:            }
153:
154:            /**
155:             * Retrieve the data context.
156:             *
157:             * @return String
158:             */
159:            public String getDataContext() {
160:                return dataContext;
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.