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


001:        package org.jacorb.transport;
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.Iterator;
024:        import java.util.List;
025:
026:        import org.apache.avalon.framework.configuration.Configurable;
027:        import org.apache.avalon.framework.configuration.Configuration;
028:        import org.apache.avalon.framework.configuration.ConfigurationException;
029:        import org.apache.avalon.framework.logger.Logger;
030:        import org.jacorb.orb.giop.TransportListener;
031:        import org.omg.CORBA.LocalObject;
032:
033:        /**
034:         * 
035:         * A default implementation of the
036:         * 
037:         * @see org.jacorb.transport.Current interface. Provides access to information
038:         *      about a Transport - the Traits.
039:         * 
040:         * @author Iliyan Jeliazkov
041:         * 
042:         */
043:        public class DefaultCurrentImpl extends LocalObject implements  Current,
044:                TransportListener, Configurable {
045:
046:            private int statistics_provider_index_ = -1;
047:
048:            /**
049:             * ctor
050:             */
051:            public DefaultCurrentImpl() {
052:
053:            }
054:
055:            public void configure(Configuration configuration)
056:                    throws ConfigurationException {
057:
058:                org.jacorb.config.Configuration cfg = (org.jacorb.config.Configuration) configuration;
059:
060:                logger_ = cfg.getNamedLogger("jacorb.transport.current");
061:
062:                // Plug-in a statistics provider, we know how to use
063:                List statsProviderClassNames = cfg
064:                        .getAttributeList("jacorb.connection.statistics_providers");
065:                statsProviderClassNames.add(DefaultStatisticsProvider.class
066:                        .getName());
067:
068:                StringBuffer buff = new StringBuffer();
069:                for (Iterator iter = statsProviderClassNames.iterator(); iter
070:                        .hasNext();) {
071:                    buff.append(iter.next());
072:                    if (iter.hasNext())
073:                        buff.append(',');
074:                }
075:                cfg.setAttribute("jacorb.connection.statistics_providers", buff
076:                        .toString());
077:
078:                statistics_provider_index_ = statsProviderClassNames.size() - 1;
079:            }
080:
081:            //
082:            // TCPConnectionListener interface
083:            //
084:            public void transportSelected(Event event) {
085:
086:                tss_transport_event_.set(event);
087:
088:                if (logger_.isInfoEnabled()) {
089:                    logger_.info("Transport selected " + event);
090:                }
091:            }
092:
093:            /**
094:             * Retrieves the last event for the current thread.
095:             * 
096:             * @return Event
097:             * @throws BadContext
098:             */
099:            protected Event getLatestTransportCurentEvent() throws NoContext {
100:
101:                Event e = (Event) tss_transport_event_.get();
102:                if (e == null) {
103:                    if (logger_.isErrorEnabled()) {
104:                        logger_
105:                                .error("No events were available. Is traits() called outside of an upcall or interceptor?");
106:                    }
107:                    throw new NoContext();
108:                }
109:                return e;
110:            }
111:
112:            /**
113:             * A thread-specific storage for the Transport the thread has chosen. Null,
114:             * if no transport has been chosen yet.
115:             */
116:            private static final ThreadLocal tss_transport_event_ = new ThreadLocal();
117:
118:            /**
119:             * A logger.
120:             */
121:            private Logger logger_;
122:
123:            public int id() throws NoContext {
124:                Event e = getLatestTransportCurentEvent();
125:                return e.hashCode();
126:            }
127:
128:            public long bytes_sent() throws NoContext {
129:                Event e = getLatestTransportCurentEvent();
130:                DefaultStatisticsProvider p = (DefaultStatisticsProvider) e
131:                        .getStatisticsProvider(statistics_provider_index_);
132:                return p.bytes_sent_;
133:            }
134:
135:            public long bytes_received() throws NoContext {
136:                Event e = getLatestTransportCurentEvent();
137:                DefaultStatisticsProvider p = (DefaultStatisticsProvider) e
138:                        .getStatisticsProvider(statistics_provider_index_);
139:                return p.bytes_received_;
140:            }
141:
142:            public long messages_sent() throws NoContext {
143:                Event e = getLatestTransportCurentEvent();
144:                DefaultStatisticsProvider p = (DefaultStatisticsProvider) e
145:                        .getStatisticsProvider(statistics_provider_index_);
146:                return p.messages_sent_;
147:            }
148:
149:            public long messages_received() throws NoContext {
150:                Event e = getLatestTransportCurentEvent();
151:                DefaultStatisticsProvider p = (DefaultStatisticsProvider) e
152:                        .getStatisticsProvider(statistics_provider_index_);
153:                return p.messages_received_;
154:            }
155:
156:            public long open_since() throws NoContext {
157:                Event e = getLatestTransportCurentEvent();
158:                DefaultStatisticsProvider p = (DefaultStatisticsProvider) e
159:                        .getStatisticsProvider(statistics_provider_index_);
160:                return p.created_;
161:            }
162:
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.