Source Code Cross Referenced for ChainedThreadingProfile.java in  » ESB » mule » org » mule » config » 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 » ESB » mule » org.mule.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: ChainedThreadingProfile.java 10489 2008-01-23 17:53:38Z dfeist $
003:         * --------------------------------------------------------------------------------------
004:         * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
005:         *
006:         * The software in this package is published under the terms of the CPAL v1.0
007:         * license, a copy of which has been included with this distribution in the
008:         * LICENSE.txt file.
009:         */
010:
011:        package org.mule.config;
012:
013:        import org.mule.api.config.ThreadingProfile;
014:        import org.mule.api.context.WorkManager;
015:
016:        import edu.emory.mathcs.backport.java.util.concurrent.RejectedExecutionHandler;
017:        import edu.emory.mathcs.backport.java.util.concurrent.ThreadFactory;
018:        import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
019:
020:        /**
021:         * This was written (perhaps too far in advance) with an eye to how we will manage default values
022:         * in a dynamic environment.  Since very little has been decided in that direction the correct
023:         * behaviour is unclear - changing the default value of "dyanamic"
024:         * {@link org.mule.config.ChainedThreadingProfile#ChainedThreadingProfile(ThreadingProfile)}
025:         * will switch behaviour between dynamic and static chaining.
026:         *
027:         * <p>Note that within Spring, as far as I understand things, object creation is always ordered
028:         * so that dependencies are correctly resolved.  In that case, in a static scenario (or in a
029:         * dynamic one that rebuilds the instances) dyanmic and static behaviour should be identical.</p>
030:         *
031:         * <p>Also, the "lazy" chaining is an optimisation - all hierarchies should be grounded in a final
032:         * default which is {@link ImmutableThreadingProfile} and, as such, return reliable
033:         * values (lazy would be necessary if this is not the case, since we must avoid evaluating
034:         * incomplete delegates).</p>
035:         */
036:        public class ChainedThreadingProfile implements  ThreadingProfile {
037:
038:            private Integer maxThreadsActive;
039:            private Integer maxThreadsIdle;
040:            private Integer maxBufferSize;
041:            private Long threadTTL;
042:            private Long threadWaitTimeout;
043:            private Integer poolExhaustedAction;
044:            private Boolean doThreading;
045:
046:            private WorkManagerFactory workManagerFactory = new ImmutableThreadingProfile.DefaultWorkManagerFactory();
047:            private RejectedExecutionHandler rejectedExecutionHandler;
048:            private ThreadFactory threadFactory;
049:
050:            private ThreadingProfile delegate;
051:
052:            /**
053:             * Generate a mutable threading profile with fixed default values taken from
054:             * {@link #DEFAULT_THREADING_PROFILE}
055:             */
056:            public ChainedThreadingProfile() {
057:                // the default is itself constant, so dynanmic=true irrelevant
058:                this (DEFAULT_THREADING_PROFILE);
059:            }
060:
061:            /**
062:             * Generate a mutable threading profile with dynamic default values taken from the
063:             * given delegate.
064:             *
065:             * @param delegate
066:             */
067:            public ChainedThreadingProfile(ThreadingProfile delegate) {
068:                this (delegate, true);
069:            }
070:
071:            /**
072:             * Generate a mutable threading profile.  Default values are taken from the "delegate"
073:             * argument.  If dynamic is true then changes in the delegate instance are reflected in
074:             * this instance.
075:             * 
076:             * @param delegate Source of default values.
077:             * @param dynamic If true, changes in delegate are reflected in this instance
078:             */
079:            public ChainedThreadingProfile(ThreadingProfile delegate,
080:                    boolean dynamic) {
081:                if (!dynamic) {
082:                    // for static dependencies, we delegate to a fixed copy
083:                    delegate = new ImmutableThreadingProfile(delegate);
084:                }
085:                this .delegate = delegate;
086:            }
087:
088:            public int getMaxThreadsActive() {
089:                return null != maxThreadsActive ? maxThreadsActive.intValue()
090:                        : delegate.getMaxThreadsActive();
091:            }
092:
093:            public int getMaxThreadsIdle() {
094:                return null != maxThreadsIdle ? maxThreadsIdle.intValue()
095:                        : delegate.getMaxThreadsIdle();
096:            }
097:
098:            public long getThreadTTL() {
099:                return null != threadTTL ? threadTTL.longValue() : delegate
100:                        .getThreadTTL();
101:            }
102:
103:            public long getThreadWaitTimeout() {
104:                return null != threadWaitTimeout ? threadWaitTimeout
105:                        .longValue() : delegate.getThreadWaitTimeout();
106:            }
107:
108:            public int getPoolExhaustedAction() {
109:                return null != poolExhaustedAction ? poolExhaustedAction
110:                        .intValue() : delegate.getPoolExhaustedAction();
111:            }
112:
113:            public RejectedExecutionHandler getRejectedExecutionHandler() {
114:                return rejectedExecutionHandler;
115:            }
116:
117:            public ThreadFactory getThreadFactory() {
118:                return threadFactory;
119:            }
120:
121:            public void setMaxThreadsActive(int maxThreadsActive) {
122:                this .maxThreadsActive = new Integer(maxThreadsActive);
123:            }
124:
125:            public void setMaxThreadsIdle(int maxThreadsIdle) {
126:                this .maxThreadsIdle = new Integer(maxThreadsIdle);
127:            }
128:
129:            public void setThreadTTL(long threadTTL) {
130:                this .threadTTL = new Long(threadTTL);
131:            }
132:
133:            public void setThreadWaitTimeout(long threadWaitTimeout) {
134:                this .threadWaitTimeout = new Long(threadWaitTimeout);
135:            }
136:
137:            public void setPoolExhaustedAction(int poolExhaustPolicy) {
138:                this .poolExhaustedAction = new Integer(poolExhaustPolicy);
139:            }
140:
141:            public void setRejectedExecutionHandler(
142:                    RejectedExecutionHandler rejectedExecutionHandler) {
143:                this .rejectedExecutionHandler = rejectedExecutionHandler;
144:            }
145:
146:            public void setThreadFactory(ThreadFactory threadFactory) {
147:                this .threadFactory = threadFactory;
148:            }
149:
150:            public int getMaxBufferSize() {
151:                return null != maxBufferSize ? maxBufferSize.intValue()
152:                        : delegate.getMaxBufferSize();
153:            }
154:
155:            public void setMaxBufferSize(int maxBufferSize) {
156:                this .maxBufferSize = new Integer(maxBufferSize);
157:            }
158:
159:            public WorkManagerFactory getWorkManagerFactory() {
160:                return workManagerFactory;
161:            }
162:
163:            public void setWorkManagerFactory(
164:                    WorkManagerFactory workManagerFactory) {
165:                this .workManagerFactory = workManagerFactory;
166:            }
167:
168:            public WorkManager createWorkManager(String name) {
169:                return workManagerFactory.createWorkManager(this , name);
170:            }
171:
172:            public ThreadPoolExecutor createPool() {
173:                return createPool(null);
174:            }
175:
176:            public ThreadPoolExecutor createPool(String name) {
177:                return ImmutableThreadingProfile.createPool(name, this );
178:            }
179:
180:            public boolean isDoThreading() {
181:                return null != doThreading ? doThreading.booleanValue()
182:                        : delegate.isDoThreading();
183:            }
184:
185:            public void setDoThreading(boolean doThreading) {
186:                this .doThreading = Boolean.valueOf(doThreading);
187:            }
188:
189:            public String toString() {
190:                return "ThreadingProfile{" + "maxThreadsActive="
191:                        + maxThreadsActive + ", maxThreadsIdle="
192:                        + maxThreadsIdle + ", maxBufferSize=" + maxBufferSize
193:                        + ", threadTTL=" + threadTTL + ", poolExhaustedAction="
194:                        + poolExhaustedAction + ", threadWaitTimeout="
195:                        + threadWaitTimeout + ", doThreading=" + doThreading
196:                        + ", workManagerFactory=" + workManagerFactory
197:                        + ", rejectedExecutionHandler="
198:                        + rejectedExecutionHandler + ", threadFactory="
199:                        + threadFactory + "}";
200:            }
201:
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.