Source Code Cross Referenced for ConnectionBase.java in  » Collaboration » JacORB » org » jacorb » orb » etf » 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.etf 
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.etf;
021:
022:        import java.io.ByteArrayOutputStream;
023:        import java.io.IOException;
024:        import java.net.InetAddress;
025:        import java.net.UnknownHostException;
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:
033:        /**
034:         * This an abstract base implementation of the ETF::Connection interface.
035:         *
036:         * @author Nicolas Noffke
037:         * @author Andre Spiegel
038:         * @version $Id: ConnectionBase.java,v 1.3 2006/06/26 08:09:30 alphonse.bendt Exp $
039:         */
040:
041:        public abstract class ConnectionBase extends
042:                org.omg.ETF._ConnectionLocalBase implements  Configurable {
043:            protected boolean connected = false;
044:
045:            /**
046:             * Optionally initialised to be used in the dumping of messages.
047:             * See property <code>jacorb.debug.dump_outgoing_messages</code>.
048:             * Default is off.
049:             */
050:            protected ByteArrayOutputStream b_out = null;
051:
052:            /**
053:             * Time out after a close connection has been received.
054:             * See property <code>jacorb.connection.timeout_after_closeconnection</code>.
055:             * Default 20000 milliseconds.
056:             */
057:            protected int finalTimeout = 20000;
058:
059:            /**
060:             * The Profile of the target / server side of the connection.
061:             */
062:            protected ProfileBase profile = null;
063:
064:            /** shared with sub classes */
065:            protected Logger logger;
066:            protected org.jacorb.config.Configuration configuration;
067:            protected String connection_info;
068:            protected ORB orb;
069:
070:            protected ConnectionBase() {
071:                super ();
072:            }
073:
074:            /**
075:             * Initialise this instance as a copy of another. Intended for use within subclass
076:             * constructors.
077:             */
078:            protected ConnectionBase(ConnectionBase other) {
079:                this .b_out = other.b_out;
080:                this .connection_info = other.connection_info;
081:                this .finalTimeout = other.finalTimeout;
082:                this .profile = other.profile;
083:            }
084:
085:            public void configure(Configuration config)
086:                    throws ConfigurationException {
087:                configuration = (org.jacorb.config.Configuration) config;
088:                orb = configuration.getORB();
089:
090:                logger = configuration.getNamedLogger(configuration
091:                        .getLoggerName(getClass()));
092:
093:                if (configuration.getAttribute(
094:                        "jacorb.debug.dump_outgoing_messages", "off").equals(
095:                        "on")) {
096:                    b_out = new ByteArrayOutputStream();
097:                }
098:
099:                finalTimeout = configuration.getAttributeAsInteger(
100:                        "jacorb.connection.timeout_after_closeconnection",
101:                        20000);
102:            }
103:
104:            protected abstract void setTimeout(int timeout);
105:
106:            protected abstract int getTimeout();
107:
108:            public org.omg.ETF.Profile get_server_profile() {
109:                return profile;
110:            }
111:
112:            public synchronized boolean is_connected() {
113:                return connected;
114:            }
115:
116:            /**
117:             * This is used to tell the transport that a CloseConnection has
118:             * been sent, and that it should set a timeout in case the client
119:             * doesn't close its side of the connection right away.
120:             *
121:             * This should only be called on the thread that listens on the
122:             * socket because timeouts are not applied until read() is called
123:             * the next time.
124:             */
125:            public void turnOnFinalTimeout() {
126:                setTimeout(finalTimeout);
127:            }
128:
129:            protected org.omg.CORBA.COMM_FAILURE to_COMM_FAILURE(IOException ex) {
130:                if (logger.isDebugEnabled()) {
131:                    logger.debug("Caught exception", ex);
132:                }
133:
134:                return new org.omg.CORBA.COMM_FAILURE("IOException: "
135:                        + ex.toString());
136:            }
137:
138:            /**
139:             * Wait for the given time_out period for incoming data on this
140:             * connection. It shall return false if this call times out and
141:             * no data is available. It may not throw a  TIMEOUT  exception.
142:             * If data can already be read or arrives before the end of the
143:             * time out, this function shall return true, immediately.
144:             */
145:            public boolean wait_next_data(long time_out) {
146:                throw new org.omg.CORBA.NO_IMPLEMENT();
147:            }
148:
149:            /**
150:             * A boolean flag describing whether this connection supports the
151:             * Bidirectional GIOP mechanism as described by GIOP-1.2 in CORBA 2.3.1
152:             * (OMG Document: formal/99-10-07). It shall return true if it does,
153:             * and false if it does not.
154:             */
155:            public boolean supports_callback() {
156:                return true;
157:            }
158:
159:            /**
160:             * A flag directing the ORB to use either the Handle class to perform
161:             * data queries with a time_out, or the transport layer (through this
162:             * connection). The instance shall return true, if the Handle should
163:             * signal time outs for read operations. Then the ORB may not call
164:             * wait_next_data. Otherwise, a false shall be returned, and the
165:             * function wait_next_data shall be implemented by this class.
166:             */
167:            public boolean use_handle_time_out() {
168:                // We have neither mechanism in JacORB.
169:                // I wonder if we should.  AS.
170:                return false;
171:            }
172:
173:            protected final String getLocalhost() {
174:                String localhost;
175:
176:                try {
177:                    localhost = InetAddress.getLocalHost().getHostAddress();
178:                } catch (UnknownHostException uhe) {
179:                    if (logger.isDebugEnabled()) {
180:                        logger
181:                                .debug("Unable to resolve local host - using default 127.0.0.1");
182:                    }
183:
184:                    localhost = "127.0.0.1";
185:                }
186:                return localhost;
187:            }
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.