Source Code Cross Referenced for ExpressoThread.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:        package com.jcorporate.expresso.core.registry;
002:
003:        /**
004:         * Provides a thread with an Expresso Thread Context already set for you.
005:         * <p>If your architecture allows you to do it, then deriving from
006:         * <tt>ExpressoThread</tt> instead of <tt>Thread</tt> allows you to have
007:         * a predefined environment with a build RequestRegistry.
008:         * <p>You create an ExpressoThread which takes a snapshot of the credentials
009:         * of the thread in which it was created.  Then when it runs() the
010:         * original credentials are applied to the new thread.</p>
011:         * <p><b>Note:</b> To get the benefits of this class, you must call
012:         * super.run() inside your own run method before proceeding.</p>
013:         * <p>If you are using a <tt>Runnable<tt> interface, you may use the code:
014:         * <code><pre>
015:         *    ExpressoThread et = new ExpressoThread(myRunnableInstance);
016:         *    et.start();
017:         * </pre></code>
018:         * which will get the RequestRegistry set before the runnable instance begins.
019:         * </p>
020:         *
021:         * @author Michael Rimov
022:         */
023:        public class ExpressoThread extends Thread {
024:            /**
025:             * The actual context that gets transferred from one thread to another.
026:             */
027:            private final ExpressoThreadContext context;
028:
029:            /**
030:             * Default constructor.
031:             */
032:            public ExpressoThread() {
033:                super ();
034:                context = new ExpressoThreadContext();
035:            }
036:
037:            /**
038:             * Protected getter to allow for future extension.
039:             *
040:             * @return ExpressoThreadContext the thread context created in
041:             *         the constructor.
042:             */
043:            protected ExpressoThreadContext getThreadContext() {
044:                return context;
045:            }
046:
047:            /**
048:             * Constructor.
049:             * See {@link Thread#Thread(Runnable)}
050:             *
051:             * @param target Runnable
052:             */
053:            public ExpressoThread(Runnable target) {
054:                super (target);
055:                context = new ExpressoThreadContext();
056:            }
057:
058:            /**
059:             * Constructor.
060:             * See {@link Thread#Thread(String)}
061:             *
062:             * @param name Runnable
063:             */
064:            public ExpressoThread(String name) {
065:                super (name);
066:                context = new ExpressoThreadContext();
067:            }
068:
069:            /**
070:             * Constructor.
071:             * See {@link Thread#Thread(String)}
072:             *
073:             * @param group  Parent ThreadGroup
074:             * @param target Runnable
075:             */
076:            public ExpressoThread(ThreadGroup group, Runnable target) {
077:                super (group, target);
078:                context = new ExpressoThreadContext();
079:            }
080:
081:            /**
082:             * Constructor.
083:             * See {@link Thread#Thread(Runnable,String)}
084:             *
085:             * @param name   the Thread Name
086:             * @param target Runnable the target to execute.
087:             */
088:            public ExpressoThread(Runnable target, String name) {
089:                super (target, name);
090:                context = new ExpressoThreadContext();
091:            }
092:
093:            /**
094:             * Constructor.
095:             * See {@link Thread#Thread(ThreadGroup,String)}
096:             *
097:             * @param group Parent ThreadGroup
098:             * @param name  the Thread Name
099:             */
100:            public ExpressoThread(ThreadGroup group, String name) {
101:                super (group, name);
102:                context = new ExpressoThreadContext();
103:            }
104:
105:            /**
106:             * Constructor.
107:             * See {@link Thread#Thread(ThreadGroup,Runnable,String)}
108:             *
109:             * @param group  Parent ThreadGroup
110:             * @param target Runnable the target to execute.
111:             * @param name   the Thread Name
112:             */
113:            public ExpressoThread(ThreadGroup group, Runnable target,
114:                    String name) {
115:                super (group, target, name);
116:                context = new ExpressoThreadContext();
117:            }
118:
119:            /**
120:             * Constructor.
121:             * See {@link Thread#Thread(ThreadGroup,Runnable,String,long)}
122:             *
123:             * @param group     Parent ThreadGroup
124:             * @param target    Runnable the target to execute.
125:             * @param name      the Thread Name
126:             * @param stackSize the size of the stack
127:             */
128:            public ExpressoThread(ThreadGroup group, Runnable target,
129:                    String name, long stackSize) {
130:                super (group, target, name, stackSize);
131:                context = new ExpressoThreadContext();
132:            }
133:
134:            /**
135:             * Call super.run() from your own threads running inside Expresso to
136:             */
137:            public void run() {
138:                getThreadContext().applyToCurrentThread();
139:                super.run();
140:            }
141:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.