Source Code Cross Referenced for ClientConnectionManager.java in  » Collaboration » JacORB » org » jacorb » orb » giop » 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 » Collaboration » JacORB » org.jacorb.orb.giop 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jacorb.orb.giop;
002:
003:        /*
004:         *        JacORB - a free Java ORB
005:         *
006:         *   Copyright (C) 1997-2004 Gerald Brose.
007:         *
008:         *   This library is free software; you can redistribute it and/or
009:         *   modify it under the terms of the GNU Library General Public
010:         *   License as published by the Free Software Foundation; either
011:         *   version 2 of the License, or (at your option) any later version.
012:         *
013:         *   This library is distributed in the hope that it will be useful,
014:         *   but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         *   Library General Public License for more details.
017:         *
018:         *   You should have received a copy of the GNU Library General Public
019:         *   License along with this library; if not, write to the Free
020:         *   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         */
022:
023:        import java.util.HashMap;
024:        import java.util.Iterator;
025:        import java.util.Map;
026:
027:        import org.apache.avalon.framework.configuration.Configurable;
028:        import org.apache.avalon.framework.configuration.Configuration;
029:        import org.apache.avalon.framework.configuration.ConfigurationException;
030:        import org.apache.avalon.framework.logger.Logger;
031:        import org.jacorb.orb.ORB;
032:        import org.omg.CORBA.BAD_PARAM;
033:        import org.omg.ETF.Factories;
034:
035:        /**
036:         * This class manages connections.
037:         *
038:         * @author Gerald Brose, FU Berlin
039:         * @version $Id: ClientConnectionManager.java,v 1.32 2006/07/26 07:38:56 alphonse.bendt Exp $
040:         */
041:
042:        public class ClientConnectionManager implements  Configurable {
043:            private final org.jacorb.orb.ORB orb;
044:
045:            /** connection mgmt. */
046:            private final Map connections = new HashMap();
047:
048:            private RequestListener request_listener;
049:
050:            private MessageReceptorPool receptor_pool;
051:
052:            private final TransportManager transport_manager;
053:            private final GIOPConnectionManager giop_connection_manager;
054:
055:            /** the configuration object  */
056:            private Logger logger;
057:
058:            public ClientConnectionManager(ORB orb,
059:                    TransportManager transport_manager,
060:                    GIOPConnectionManager giop_connection_manager) {
061:                this .orb = orb;
062:                this .transport_manager = transport_manager;
063:                this .giop_connection_manager = giop_connection_manager;
064:            }
065:
066:            /**
067:             * configure this connection manager
068:             */
069:
070:            public void configure(Configuration myConfiguration)
071:                    throws ConfigurationException {
072:                // Moved from the constructor to facilitate logging.
073:                receptor_pool = new MessageReceptorPool("client",
074:                        "ClientMessageReceptor", myConfiguration);
075:
076:                org.jacorb.config.Configuration configuration = (org.jacorb.config.Configuration) myConfiguration;
077:                logger = configuration.getNamedLogger("jacorb.orb.giop");
078:
079:                request_listener = new NoBiDirClientRequestListener(logger);
080:            }
081:
082:            public void setRequestListener(RequestListener listener) {
083:                request_listener = listener;
084:            }
085:
086:            public synchronized ClientConnection getConnection(
087:                    org.omg.ETF.Profile profile) {
088:                /* look for an existing connection */
089:
090:                ClientConnection clientConnection = (ClientConnection) connections
091:                        .get(profile);
092:
093:                if (clientConnection == null) {
094:                    int tag = profile.tag();
095:                    Factories factories = transport_manager.getFactories(tag);
096:                    if (factories == null) {
097:                        throw new BAD_PARAM(
098:                                "No transport plugin for profile tag " + tag);
099:                    }
100:                    GIOPConnection connection = giop_connection_manager
101:                            .createClientGIOPConnection(profile, factories
102:                                    .create_connection(null), request_listener,
103:                                    null);
104:
105:                    clientConnection = new ClientConnection(connection, orb,
106:                            this , profile, true);
107:
108:                    if (logger.isInfoEnabled()) {
109:                        logger.info("ClientConnectionManager: created new "
110:                                + clientConnection.getGIOPConnection()
111:                                        .toString());
112:                    }
113:
114:                    receptor_pool.connectionCreated(connection);
115:                    connections.put(profile, clientConnection);
116:                } else {
117:                    if (logger.isInfoEnabled()) {
118:                        logger.info("ClientConnectionManager: found "
119:                                + clientConnection.getGIOPConnection()
120:                                        .toString());
121:                    }
122:                }
123:
124:                clientConnection.incClients();
125:
126:                return clientConnection;
127:            }
128:
129:            /**
130:             * Only used by Delegate for client-initiated connections.
131:             */
132:            public synchronized void releaseConnection(
133:                    ClientConnection connection) {
134:                if (connection.decClients()) {
135:                    if (logger.isDebugEnabled()) {
136:                        logger.debug("ClientConnectionManager: releasing "
137:                                + connection.getGIOPConnection().toString());
138:                    }
139:                    connection.close();
140:                    connections.remove(connection.getRegisteredProfile());
141:                } else {
142:                    // not sure if this should be a warning or even an error
143:                    if (logger.isDebugEnabled()) {
144:                        logger.debug("ClientConnectionManager: cannot release "
145:                                + connection.getGIOPConnection().toString()
146:                                + " (still has " + connection.numClients()
147:                                + " client(s))");
148:                    }
149:                }
150:            }
151:
152:            /**
153:             * Only used by ClientConnection to unregister server-side of
154:             * BiDir connection.
155:             */
156:            public synchronized void removeConnection(
157:                    ClientConnection connection) {
158:                connections.remove(connection.getRegisteredProfile());
159:            }
160:
161:            public synchronized void addConnection(GIOPConnection connection,
162:                    org.omg.ETF.Profile profile) {
163:                if (!connections.containsKey(profile)) {
164:                    ClientConnection clientConnection = new ClientConnection(
165:                            connection, orb, this , profile, false);
166:
167:                    //this is a bit of a hack: the bidirectional client
168:                    //connections have to persist until their underlying GIOP
169:                    //connection is closed. Therefore, we set the initial
170:                    //client count to 1, so the connection will be kept even
171:                    //if there are currently no associated Delegates.
172:
173:                    clientConnection.incClients();
174:
175:                    connections.put(profile, clientConnection);
176:                }
177:            }
178:
179:            public synchronized void shutdown() {
180:                /* release all open connections */
181:
182:                for (Iterator i = connections.values().iterator(); i.hasNext();) {
183:                    ((ClientConnection) i.next()).close();
184:                }
185:
186:                if (logger.isDebugEnabled()) {
187:                    logger
188:                            .debug("ClientConnectionManager shut down (all connections released)");
189:                }
190:
191:                connections.clear();
192:                receptor_pool.shutdown();
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.