Source Code Cross Referenced for PoolingProfile.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: PoolingProfile.java 10529 2008-01-25 05:58:36Z 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 java.util.Map;
014:
015:        import org.apache.commons.collections.map.CaseInsensitiveMap;
016:
017:        /**
018:         * <code>PoolingProfile</code> is a configuration object used to define the object
019:         * pooling parameters for the service it is associated with.
020:         */
021:
022:        public class PoolingProfile {
023:
024:            /**
025:             * Tells the object pool not to initialise any components on startup.
026:             */
027:            public static final int INITIALISE_NONE = 0;
028:
029:            /**
030:             * Tells the object pool only to initialise one service on startup.
031:             */
032:            public static final int INITIALISE_ONE = 1;
033:
034:            /**
035:             * Tells the object pool to initialise all components on startup.
036:             */
037:            public static final int INITIALISE_ALL = 2;
038:
039:            // Constants used to determine the exhausted action of the pool
040:            public static final int WHEN_EXHAUSTED_FAIL = 0;
041:            /** @deprecated use WHEN_EXHAUSTED_WAIT instead */
042:            public static final int WHEN_EXHAUSTED_BLOCK = 1;
043:            public static final int WHEN_EXHAUSTED_WAIT = 1;
044:            public static final int WHEN_EXHAUSTED_GROW = 2;
045:
046:            /**
047:             * Controls the maximum number of Mule UMOs that can be borrowed from a service
048:             * pool at one time. When non-positive, there is no limit to the number of
049:             * components that may be active at one time. When maxActive is exceeded, the
050:             * pool is said to be exhausted. You can specify this value on the descriptor
051:             * declaration. If none is set this value will be used.
052:             */
053:            public static final int DEFAULT_MAX_POOL_ACTIVE = 5;
054:
055:            /**
056:             * Controls the maximum number of Mule UMOs that can sit idle in the pool at any
057:             * time. When non-positive, there is no limit to the number of Mule UMOs that may
058:             * be idle at one time. You can specify this value on the descriptor declaration.
059:             * If none is set this value will be used. If this value is not set then a system
060:             * default of '5' will be used.
061:             */
062:            public static final int DEFAULT_MAX_POOL_IDLE = 5;
063:
064:            /**
065:             * When the threadPoolExhaustedAction is set to WHEN_EXHAUSTED_WAIT this can
066:             * specify the maximum milliseconds the pool should block before throwing a
067:             * NoSuchElementException
068:             */
069:            public static final long DEFAULT_MAX_POOL_WAIT = 4000;
070:
071:            /**
072:             * Specifies the behaviour of the Mule UMO pool when the pool is exhausted:
073:             * <ul>
074:             * <li>WHEN_EXHAUSTED_FAIL : will throw a NoSuchElementException</li>
075:             * <li>WHEN_EXHAUSTED_WAIT : will block (invoke Object.wait(long) until a new or
076:             * idle object is available.</li>
077:             * <li>WHEN_EXHAUSTED_GROW : will create a new Mule and return it (essentially
078:             * making maxActive meaningless).</li>
079:             * </ul>
080:             * If a positive maxWait value is supplied, it will block for at most that many
081:             * milliseconds, after which a NoSuchElementException will be thrown. If maxWait
082:             * is non-positive, it will block indefinitely.
083:             */
084:            public static final int DEFAULT_POOL_EXHAUSTED_ACTION = WHEN_EXHAUSTED_GROW;
085:
086:            /**
087:             * Determines how components in a pool should be initialised. The possible values
088:             * are:
089:             * <ul>
090:             * <li>INITIALISE_NONE : Will not load any components in the pool on startup</li>
091:             * <li>INITIALISE_ONE : Will load only the first service in the pool on
092:             * startup</li>
093:             * <li>INITIALISE_ALL : Will load all components in the pool on startup</li>
094:             * </ul>
095:             */
096:            public static final int DEFAULT_POOL_INITIALISATION_POLICY = INITIALISE_ONE;
097:
098:            // map pool exhaustion strings to their respective values
099:            public static final Map POOL_EXHAUSTED_ACTIONS = new CaseInsensitiveMap() {
100:                private static final long serialVersionUID = 1L;
101:
102:                // static initializer
103:                {
104:                    // if the values were an actual enum in ObjectPool we could iterate
105:                    // properly.. :/
106:
107:                    Integer value = new Integer(WHEN_EXHAUSTED_WAIT);
108:                    this .put("WHEN_EXHAUSTED_WAIT", value);
109:
110:                    value = new Integer(WHEN_EXHAUSTED_FAIL);
111:                    this .put("WHEN_EXHAUSTED_FAIL", value);
112:
113:                    value = new Integer(WHEN_EXHAUSTED_GROW);
114:                    this .put("WHEN_EXHAUSTED_GROW", value);
115:                }
116:            };
117:
118:            // map pool initialisation policy strings to their respective values
119:            public static final Map POOL_INITIALISATION_POLICIES = new CaseInsensitiveMap() {
120:                private static final long serialVersionUID = 1L;
121:
122:                // static initializer
123:                {
124:                    Integer value = new Integer(INITIALISE_NONE);
125:                    this .put("INITIALISE_NONE", value);
126:
127:                    value = new Integer(INITIALISE_ONE);
128:                    this .put("INITIALISE_ONE", value);
129:
130:                    value = new Integer(INITIALISE_ALL);
131:                    this .put("INITIALISE_ALL", value);
132:                }
133:            };
134:
135:            private int maxActive = DEFAULT_MAX_POOL_ACTIVE;
136:
137:            private int maxIdle = DEFAULT_MAX_POOL_IDLE;
138:
139:            private long maxWait = DEFAULT_MAX_POOL_WAIT;
140:
141:            private int exhaustedAction = DEFAULT_POOL_EXHAUSTED_ACTION;
142:
143:            private int initialisationPolicy = DEFAULT_POOL_INITIALISATION_POLICY;
144:
145:            //    private UMOPoolFactory poolFactory = new CommonsPoolFactory();
146:
147:            public PoolingProfile() {
148:                super ();
149:            }
150:
151:            public PoolingProfile(PoolingProfile pp) {
152:                this .maxActive = pp.getMaxActive();
153:                this .maxIdle = pp.getMaxIdle();
154:                this .maxWait = pp.getMaxWait();
155:                this .exhaustedAction = pp.getExhaustedAction();
156:                this .initialisationPolicy = pp.getInitialisationPolicy();
157:                //        if (pp.getPoolFactory() != null)
158:                //        {
159:                //            poolFactory = pp.getPoolFactory();
160:                //        }
161:            }
162:
163:            public PoolingProfile(int maxActive, int maxIdle, long maxWait,
164:                    int exhaustedAction, int initialisationPolicy) {
165:                this .maxActive = maxActive;
166:                this .maxIdle = maxIdle;
167:                this .maxWait = maxWait;
168:                this .exhaustedAction = exhaustedAction;
169:                this .initialisationPolicy = initialisationPolicy;
170:            }
171:
172:            /**
173:             * @return max number of Mule UMOs that can be idle in a service
174:             */
175:            public int getMaxIdle() {
176:                return maxIdle;
177:            }
178:
179:            /**
180:             * @return max number of Mule UMOs that can be active in a service
181:             */
182:            public int getMaxActive() {
183:                return maxActive;
184:            }
185:
186:            /**
187:             * @return time in miilisconds to wait for a Mule UMO to be available in a
188:             *         service when the pool of Mule UMOs is exhausted and the
189:             *         PoolExhaustedAction is set to WHEN_EXHAUSTED_BLOCK
190:             */
191:            public long getMaxWait() {
192:                return maxWait;
193:            }
194:
195:            /**
196:             * @return the action when the Mule UMO pool is exhaused for a service
197:             */
198:            public int getExhaustedAction() {
199:                return exhaustedAction;
200:            }
201:
202:            public int getInitialisationPolicy() {
203:                return initialisationPolicy;
204:            }
205:
206:            public void setInitialisationPolicy(int policy) {
207:                initialisationPolicy = policy;
208:            }
209:
210:            public void setMaxIdle(int maxIdle) {
211:                this .maxIdle = maxIdle;
212:            }
213:
214:            public void setMaxActive(int maxActive) {
215:                this .maxActive = maxActive;
216:            }
217:
218:            public void setMaxWait(long maxWait) {
219:                this .maxWait = maxWait;
220:            }
221:
222:            public void setExhaustedAction(int exhaustedAction) {
223:                this .exhaustedAction = exhaustedAction;
224:            }
225:
226:            //    public UMOPoolFactory getPoolFactory()
227:            //    {
228:            //        return poolFactory;
229:            //    }
230:            //
231:            //    public void setPoolFactory(UMOPoolFactory poolFactory)
232:            //    {
233:            //        this.poolFactory = poolFactory;
234:            //    }
235:
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.