Source Code Cross Referenced for ReplyPlaceholder.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:
021:        package org.jacorb.orb.giop;
022:
023:        import org.jacorb.orb.*;
024:
025:        import org.omg.CORBA.portable.RemarshalException;
026:
027:        /**
028:         * Connections deliver replies to instances of this class.
029:         * The mechanism by which the ORB can retrieve the replies is
030:         * implemented in subclasses.
031:         *
032:         * @author Nicolas Noffke
033:         * @version $Id: ReplyPlaceholder.java,v 1.23 2006/08/29 15:03:00 alphonse.bendt Exp $
034:         */
035:        public abstract class ReplyPlaceholder {
036:            protected final Object lock = new Object();
037:            protected boolean ready = false;
038:            protected boolean communicationException = false;
039:            protected boolean remarshalException = false;
040:            protected boolean timeoutException = false;
041:
042:            protected MessageInputStream in = null;
043:
044:            protected final int timeout;
045:
046:            /**
047:             * self-configuring c'tor
048:             */
049:
050:            public ReplyPlaceholder(ORB orb) {
051:                timeout = orb.getConfiguration().getAttributeAsInteger(
052:                        "jacorb.connection.client.pending_reply_timeout", 0);
053:            }
054:
055:            public void replyReceived(MessageInputStream in) {
056:                synchronized (lock) {
057:                    if (!timeoutException) {
058:                        this .in = in;
059:                        ready = true;
060:                        lock.notifyAll();
061:                    }
062:                }
063:            }
064:
065:            public void cancel() {
066:                synchronized (lock) {
067:                    if (in == null) {
068:                        communicationException = true;
069:                        ready = true;
070:                        lock.notify();
071:                    }
072:                }
073:            }
074:
075:            public void retry() {
076:                synchronized (lock) {
077:                    remarshalException = true;
078:                    ready = true;
079:                    lock.notify();
080:                }
081:            }
082:
083:            /**
084:             * Non-public implementation of the blocking method that
085:             * returns a reply when it becomes available.  Subclasses
086:             * should specify a different method, under a different
087:             * name, that does any specific processing of the reply before
088:             * returning it to the caller.
089:             */
090:            protected MessageInputStream getInputStream(boolean hasTimeoutPolicy)
091:                    throws RemarshalException {
092:                final boolean _shouldUseTimeout = !hasTimeoutPolicy
093:                        && timeout > 0;
094:                final long _maxWait = _shouldUseTimeout ? System
095:                        .currentTimeMillis()
096:                        + timeout : Long.MAX_VALUE;
097:                final long _timeout = _shouldUseTimeout ? timeout : 0;
098:
099:                synchronized (lock) {
100:                    try {
101:                        while (!ready && System.currentTimeMillis() < _maxWait) {
102:                            lock.wait(_timeout);
103:                        }
104:                    } catch (InterruptedException e) {
105:                        // ignored
106:                    }
107:
108:                    if (!ready && _shouldUseTimeout) {
109:                        timeoutException = true;
110:                    }
111:
112:                    if (remarshalException) {
113:                        throw new org.omg.CORBA.portable.RemarshalException();
114:                    }
115:
116:                    if (communicationException) {
117:                        throw new org.omg.CORBA.COMM_FAILURE(0,
118:                                org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
119:                    }
120:
121:                    if (timeoutException) {
122:                        throw new org.omg.CORBA.TIMEOUT(
123:                                "client timeout reached");
124:                    }
125:
126:                    return in;
127:                }
128:            }
129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.