Source Code Cross Referenced for ServerRemoteCall.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » rmi » server » 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 » Apache Harmony Java SE » org package » org.apache.harmony.rmi.server 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         */
018:
019:        /**
020:         * @author  Mikhail A. Markov
021:         * @version $Revision: 1.1.2.2 $
022:         */package org.apache.harmony.rmi.server;
023:
024:        import java.io.DataOutputStream;
025:        import java.io.IOException;
026:        import java.io.StreamCorruptedException;
027:        import java.io.ObjectInput;
028:        import java.io.ObjectInputStream;
029:        import java.io.ObjectOutput;
030:        import java.rmi.server.RemoteCall;
031:
032:        import org.apache.harmony.rmi.internal.nls.Messages;
033:        import org.apache.harmony.rmi.transport.RMIObjectInputStream;
034:        import org.apache.harmony.rmi.transport.RMIObjectOutputStream;
035:        import org.apache.harmony.rmi.transport.RMIProtocolConstants;
036:
037:        /**
038:         * RemoteCall implementation used by UnicastServerRef on server's side.
039:         *
040:         * @author  Mikhail A. Markov
041:         * @version $Revision: 1.1.2.2 $
042:         */
043:        public class ServerRemoteCall implements  RemoteCall,
044:                RMIProtocolConstants {
045:
046:            // Connection to remote server.
047:            private ServerConnection conn;
048:
049:            // InputStream for reading objects.
050:            private ObjectInputStream oin = null;
051:
052:            // OutputStream for sending objects.
053:            private RMIObjectOutputStream oout = null;
054:
055:            // True if getResultStream has been called.
056:            private boolean hasResStream = false;
057:
058:            /**
059:             * Constructs ServerRemoteCall from existing connection.
060:             *
061:             * @param conn opened ServerConnection
062:             */
063:            public ServerRemoteCall(ServerConnection conn) {
064:                this .conn = conn;
065:            }
066:
067:            /**
068:             * Constructs ServerRemoteCall from opened connection and already created
069:             * ObjectOutputStream.
070:             *
071:             * @param conn opened ServerConnection
072:             * @param oin created ObjectOutputStream
073:             */
074:            public ServerRemoteCall(ServerConnection conn, ObjectInputStream oin) {
075:                this .conn = conn;
076:                this .oin = oin;
077:            }
078:
079:            /**
080:             * Constructs ObjectInputStream (if it was not created yet) and returns
081:             * this created stream.
082:             *
083:             * @return ObjectInputStream to read objects from
084:             *
085:             * @throws IOException if an I/O error occurred during stream construction
086:             */
087:            public ObjectInput getInputStream() throws IOException {
088:                if (oin == null) {
089:                    oin = new RMIObjectInputStream(conn.getInputStream());
090:                }
091:                return oin;
092:            }
093:
094:            /**
095:             * Constructs ObjectOutputStream (if it was not created yet) and returns
096:             * this created stream.
097:             *
098:             * @return ObjectOutputStream to write objects to
099:             *
100:             * @throws IOException if an I/O error occurred during stream construction
101:             */
102:
103:            public ObjectOutput getOutputStream() throws IOException {
104:                if (oout == null) {
105:                    oout = new RMIObjectOutputStream(conn.getOutputStream());
106:                }
107:                return oout;
108:            }
109:
110:            /**
111:             * Writes byte meaning normal call return, writes byte identifying call
112:             * result (normal return or exception) - depending on success parameter,
113:             * writes UID of the object (for DGC) and flushes the output stream.
114:             * This method could be called only once.
115:             *
116:             * @param success if true - means that method call was successful (i.e.
117:             *        with no exception) - return data description will be written to
118:             *        the output stream
119:             *
120:             * @throws IOException if an I/O error occurred while writing to the stream
121:             * @throws StreamCorruptedException if this method has already been called
122:             */
123:            public ObjectOutput getResultStream(boolean success)
124:                    throws IOException, StreamCorruptedException {
125:                if (hasResStream) {
126:                    // rmi.7A=getResultStream() method has already been called.
127:                    throw new StreamCorruptedException(Messages
128:                            .getString("rmi.7A")); //$NON-NLS-1$
129:                }
130:                (new DataOutputStream(conn.getOutputStream()))
131:                        .writeByte(CALL_OK);
132:
133:                if (oout == null) {
134:                    oout = new RMIObjectOutputStream(conn.getOutputStream(),
135:                            true);
136:                }
137:                oout.writeByte(success ? RETURN_VAL : RETURN_EX);
138:                oout.writeUID();
139:                oout.flush();
140:                hasResStream = true;
141:                return oout;
142:            }
143:
144:            /**
145:             * @see RemoteCall.releaseInputStream()
146:             */
147:            public void releaseInputStream() throws IOException {
148:                conn.releaseInputStream();
149:            }
150:
151:            /**
152:             * @see RemoteCall.releaseOutputStream()
153:             */
154:            public void releaseOutputStream() throws IOException {
155:            }
156:
157:            /**
158:             * @see RemoteCall.done()
159:             */
160:            public void done() throws IOException {
161:                conn.close();
162:            }
163:
164:            /**
165:             * Not used on server side.
166:             */
167:            public void executeCall() throws Exception {
168:            }
169:
170:            /**
171:             * Returns string representation of this RemoteCall.
172:             *
173:             * @return string representation of this RemoteCall
174:             */
175:            public String toString() {
176:                return "ServerRemoteCall: connection: " + conn; //$NON-NLS-1$
177:            }
178:
179:            /**
180:             * Returns true if getResultStream was already called before and
181:             * false otherwise.
182:             *
183:             * @return true if getResultStream was already called before and
184:             *         false otherwise
185:             */
186:            public boolean hasResultStream() {
187:                return hasResStream;
188:            }
189:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.