Source Code Cross Referenced for GIOPConnectionManager.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:        /*
002:         *        JacORB - a free Java ORB
003:         *
004:         *   Copyright (C) 1997-2004 Gerald Brose.
005:         *
006:         *   This library is free software; you can redistribute it and/or
007:         *   modify it under the terms of the GNU Library General Public
008:         *   License as published by the Free Software Foundation; either
009:         *   version 2 of the License, or (at your option) any later version.
010:         *
011:         *   This library is distributed in the hope that it will be useful,
012:         *   but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *   Library General Public License for more details.
015:         *
016:         *   You should have received a copy of the GNU Library General Public
017:         *   License along with this library; if not, write to the Free
018:         *   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
019:         */
020:        package org.jacorb.orb.giop;
021:
022:        import java.util.ArrayList;
023:        import java.util.Iterator;
024:        import java.util.LinkedList;
025:        import java.util.List;
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.util.ObjectUtil;
032:
033:        /**
034:         * @author Nicolas Noffke
035:         * @version $Id: GIOPConnectionManager.java,v 1.14 2006/06/28 12:41:43 alphonse.bendt Exp $
036:         */
037:
038:        public class GIOPConnectionManager implements  Configurable {
039:            /** the configuration object  */
040:            private org.jacorb.config.Configuration configuration = null;
041:
042:            /** configuration properties */
043:            private Logger logger = null;
044:
045:            //private List client_giop_connections = null;
046:            private final List server_giop_connections;
047:            private int max_server_giop_connections = 0;
048:            private Class statistics_provider_class = null;
049:            private SelectionStrategy selection_strategy = null;
050:            private int wait_for_idle_interval = 0;
051:
052:            public GIOPConnectionManager() {
053:                server_giop_connections = new LinkedList();
054:            }
055:
056:            /**
057:             * configures the GIOPConnectionManager
058:             */
059:
060:            public void configure(Configuration myConfiguration)
061:                    throws ConfigurationException {
062:                this .configuration = (org.jacorb.config.Configuration) myConfiguration;
063:                logger = configuration.getNamedLogger("jacorb.orb.giop.conn");
064:
065:                max_server_giop_connections = configuration
066:                        .getAttributeAsInteger(
067:                                "jacorb.connection.max_server_connections",
068:                                Integer.MAX_VALUE);
069:
070:                selection_strategy = (SelectionStrategy) configuration
071:                        .getAttributeAsObject("jacorb.connection.selection_strategy_class");
072:
073:                wait_for_idle_interval = configuration.getAttributeAsInteger(
074:                        "jacorb.connection.wait_for_idle_interval", 500);
075:
076:                String statisticsProviderClassName = configuration
077:                        .getAttribute(
078:                                "jacorb.connection.statistics_provider_class",
079:                                "");
080:
081:                if (statisticsProviderClassName.length() > 0) {
082:                    try {
083:                        statistics_provider_class = ObjectUtil
084:                                .classForName(statisticsProviderClassName);
085:                    } catch (Exception e) {
086:                        if (logger.isErrorEnabled()) {
087:                            logger
088:                                    .error("Unable to create class from property >jacorb.connection.statistics_provider_class<: "
089:                                            + e.toString());
090:                        }
091:                    }
092:                }
093:
094:            }
095:
096:            public ServerGIOPConnection createServerGIOPConnection(
097:                    org.omg.ETF.Profile profile,
098:                    org.omg.ETF.Connection transport,
099:                    RequestListener request_listener,
100:                    ReplyListener reply_listener) {
101:                //if too many open connections, shut one down
102:                if (server_giop_connections.size() >= max_server_giop_connections) {
103:                    if (selection_strategy == null) {
104:                        if (logger.isErrorEnabled()) {
105:                            logger
106:                                    .error("No. of max server giop connections set, but no SelectionStrategy present");
107:                        }
108:                    } else {
109:                        while (server_giop_connections.size() >= max_server_giop_connections) {
110:                            ServerGIOPConnection to_close = null;
111:
112:                            synchronized (server_giop_connections) {
113:                                to_close = selection_strategy
114:                                        .selectForClose(server_giop_connections);
115:                            }
116:
117:                            if (to_close != null && to_close.tryClose()) {
118:                                break;
119:                            }
120:
121:                            try {
122:                                Thread.sleep(wait_for_idle_interval);
123:                            } catch (InterruptedException e) {
124:                                // ignored
125:                            }
126:                        }
127:                    }
128:                }
129:
130:                ServerGIOPConnection connection = new ServerGIOPConnection(
131:                        profile, transport, request_listener, reply_listener,
132:                        getStatisticsProvider(), this );
133:
134:                try {
135:                    connection.configure(configuration);
136:                } catch (ConfigurationException ce) {
137:                    logger.warn("ConfigurationException", ce);
138:                }
139:
140:                synchronized (server_giop_connections) {
141:                    server_giop_connections.add(connection);
142:                }
143:
144:                if (logger.isDebugEnabled()) {
145:                    logger.debug("GIOPConnectionManager: created new "
146:                            + connection.toString());
147:                }
148:
149:                return connection;
150:            }
151:
152:            public void unregisterServerGIOPConnection(
153:                    ServerGIOPConnection connection) {
154:                synchronized (server_giop_connections) {
155:                    server_giop_connections.remove(connection);
156:                }
157:            }
158:
159:            public GIOPConnection createClientGIOPConnection(
160:                    org.omg.ETF.Profile profile,
161:                    org.omg.ETF.Connection transport,
162:                    RequestListener request_listener,
163:                    ReplyListener reply_listener) {
164:                ClientGIOPConnection connection = new ClientGIOPConnection(
165:                        profile, transport, request_listener, reply_listener,
166:                        null);
167:
168:                try {
169:                    connection.configure(configuration);
170:                } catch (ConfigurationException ce) {
171:                    logger.warn("ConfigurationException", ce);
172:                }
173:                return connection;
174:            }
175:
176:            /**
177:             * Closes all server-side GIOP connections.
178:             */
179:            public void shutdown() {
180:                List connections = null;
181:                synchronized (server_giop_connections) {
182:                    connections = new ArrayList(server_giop_connections);
183:                }
184:
185:                if (logger.isDebugEnabled()) {
186:                    logger.debug("GIOPConnectionManager.shutdown(), "
187:                            + connections.size() + " connections");
188:                }
189:
190:                for (Iterator i = connections.iterator(); i.hasNext();) {
191:                    ServerGIOPConnection connection = (ServerGIOPConnection) i
192:                            .next();
193:                    connection.tryClose();
194:                }
195:
196:            }
197:
198:            private StatisticsProvider getStatisticsProvider() {
199:                StatisticsProvider result = null;
200:                if (statistics_provider_class != null) {
201:                    try {
202:                        result = (StatisticsProvider) statistics_provider_class
203:                                .newInstance();
204:                    } catch (Exception e) {
205:                        if (logger.isErrorEnabled()) {
206:                            logger
207:                                    .error("Unable to create instance from Class >"
208:                                            + statistics_provider_class + '<');
209:                        }
210:                    }
211:                }
212:                return result;
213:            }
214:
215:        }// GIOPConnectionManager
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.