Source Code Cross Referenced for OutboundConnectionCache.java in  » 6.0-JDK-Modules-com.sun » wsit » com » sun » xml » ws » transport » tcp » connectioncache » spi » transport » 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 » 6.0 JDK Modules com.sun » wsit » com.sun.xml.ws.transport.tcp.connectioncache.spi.transport 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         * 
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         * 
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common Development
008:         * and Distribution License("CDDL") (collectively, the "License").  You
009:         * may not use this file except in compliance with the License. You can obtain
010:         * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011:         * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
012:         * language governing permissions and limitations under the License.
013:         * 
014:         * When distributing the software, include this License Header Notice in each
015:         * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016:         * Sun designates this particular file as subject to the "Classpath" exception
017:         * as provided by Sun in the GPL Version 2 section of the License file that
018:         * accompanied this code.  If applicable, add the following below the License
019:         * Header, with the fields enclosed by brackets [] replaced by your own
020:         * identifying information: "Portions Copyrighted [year]
021:         * [name of copyright owner]"
022:         * 
023:         * Contributor(s):
024:         * 
025:         * If you wish your version of this file to be governed by only the CDDL or
026:         * only the GPL Version 2, indicate your decision by adding "[Contributor]
027:         * elects to include this software in this distribution under the [CDDL or GPL
028:         * Version 2] license."  If you don't indicate a single choice of license, a
029:         * recipient has the option to distribute your version of this file under
030:         * either the CDDL, the GPL Version 2 or to extend the choice of license to
031:         * its licensees as provided above.  However, if you add GPL Version 2 code
032:         * and therefore, elected the GPL Version 2 license, then the option applies
033:         * only if the new code is made subject to such option by the copyright
034:         * holder.
035:         */
036:
037:        package com.sun.xml.ws.transport.tcp.connectioncache.spi.transport;
038:
039:        import java.io.IOException;
040:
041:        /** A concurrent mostly non-blocking connection cache.  Here a Connection is an 
042:         * abstraction of a Socket or SocketChannel: basically some sort of resource 
043:         * that is expensive to acquire, and can be re-used freely.  The cache 
044:         * maintains a loose upper bound on the number of cached connections, and 
045:         * reclaims connections as needed.
046:         * <P>
047:         * This cache places minimal requirements on the Connections that it contains:
048:         * <ol>
049:         * <li>A Connection must implement a close() method.  This is called when idle
050:         * connections are reclaimed.
051:         * <li>A Connection must be usable as a HashMap key.  
052:         * <li>There must be a ContactInfo class that is used to create Connection 
053:         * instances.  The ContactInfo class must support a create() method that 
054:         * returns a Connection.
055:         * <li>The ContactInfo must be usable as a HashMap key.
056:         * <li>All instances created from a ContactInfo are equal; that is, any request
057:         * sent to a particular ContactInfo can used an instance created from that 
058:         * ContactInfo.  For example, in the CORBA case, IP host and port is not always
059:         * sufficient: we may also need the Codeset type that indicates how Strings are
060:         * encoded.  Basically, protocols (like GIOP) that bind session state to a 
061:         * Connection may need more than transport information in the ContactInfo.
062:         * </ol>
063:         * <P>
064:         * Some simple methods are provided for monitoring the state of the cache:
065:         * numbers of busy and idle connections, and the total number of connections in 
066:         * the cache.
067:         */
068:        public interface OutboundConnectionCache<C extends Connection> extends
069:                ConnectionCache<C> {
070:            /** Configured maximum number of connections supported per ContactInfo.
071:             */
072:            int maxParallelConnections();
073:
074:            /** Determine whether a new connection could be created by the
075:             * ConnectionCache or not.
076:             */
077:            boolean canCreateNewConnection(ContactInfo<C> cinfo);
078:
079:            /** Return a Connection corresponding to the given ContactInfo.
080:             * This works as follows:
081:             * <ul>
082:             * <li>Call the finder.  If it returns non-null, use that connection;
083:             * (Note that this may be a new connection, created in the finder)
084:             * <li>otherwise, Use an idle connection, if one is available; 
085:             * <li>otherwise, create a new connection, if not too many connections are 
086:             * open;
087:             * <li>otherwise, use a busy connection.
088:             * </ul>
089:             * Note that creating a new connection requires EITHER:
090:             * <ul>
091:             * <li>there is no existing connection for the ContactInfo 
092:             * <li> OR the total number of connections in the cache is less than the
093:             * HighWaterMark and the number of connections for this ContactInfo
094:             * is less than MaxParallelConnections.  
095:             * </ul>
096:             * We will always return a 
097:             * Connection for a get call UNLESS we have no existing connection and
098:             * an attempt to create a new connection fails.  In this case, the
099:             * IOException thrown by ContactInfo.create is propagated out of this
100:             * method.
101:             * <P>
102:             * It is possible that the cache contains connections that no longer connect
103:             * to their destination.  In this case, it is the responsibility of the 
104:             * client of the cache to close the broken connection as they are detected.
105:             * Connection reclamation may also handle the cleanup, but note that a 
106:             * broken connection with pending responses will never be reclaimed.
107:             * <P>
108:             * Note that the idle and busy connection collections that are
109:             * passed to the finder are unmodifiable collections.  They have iterators 
110:             * that return connections in LRU order, with the least recently used 
111:             * connection first.  This is done to aid a finder that wishes to consider 
112:             * load balancing in its determination of an appropriate connection.
113:             * <P>
114:             */
115:            C get(ContactInfo<C> cinfo, ConnectionFinder<C> finder)
116:                    throws IOException;
117:
118:            /** Behaves the same as get( ContactInfo<C>, ConnectionFinder<C> ) 
119:             * except that no connection finder is provided, so that step is
120:             * ignored. 
121:             */
122:            C get(ContactInfo<C> cinfo) throws IOException;
123:
124:            /** Release a Connection previously obtained from get.  Connections that
125:             * have been released as many times as they have been returned by
126:             * get are idle; otherwise a Connection is busy.  Some number of
127:             * responses (usually 0 or 1) may be expected ON THE SAME CONNECTION
128:             * even for an idle connection.  We maintain a count of the number of 
129:             * outstanding responses we expect for protocols that return the response
130:             * on the same connection on which the request was received.  This is
131:             * necessary to prevent reclamation of a Connection that is idle, but
132:             * still needed to send responses to old requests.
133:             */
134:            void release(C conn, int numResponseExpected);
135:
136:            /** Inform the cache that a response has been received on a particular
137:             * connection.  This must also be called in the event that no response
138:             * is received, but the client times out waiting for a response, and
139:             * decides to abandon the request.
140:             * <P>
141:             * When a Connection is idle, and has no pending responses, it is
142:             * eligible for reclamation.
143:             */
144:            void responseReceived(C conn);
145:        }
ww___w_.___j___ava2__s__._c__o_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.