KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > iiop > Iiop10Writer


1 /*
2  * Copyright (c) 1998-2000 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.iiop;
30
31 import java.io.IOException JavaDoc;
32
33 public class Iiop10Writer extends IiopWriter {
34   /**
35    * Writes the header for a request
36    *
37    * @param operation the method to call
38    */

39   public void startRequest(byte []oid, int off, int len,
40                String JavaDoc operation, int requestId)
41     throws IOException JavaDoc
42   {
43     startMessage(IiopReader.MSG_REQUEST);
44
45     writeRequestServiceControlList(); // service context list
46

47     write_long(requestId); // request id
48
_out.write(1); // response expected
49

50     writeBytes(oid, off, len); // object id
51
writeString(operation);
52     writeNull(); // principal
53
}
54   
55   /**
56    * Writes the header for a request
57    */

58   public void startReplyOk(int requestId)
59     throws IOException JavaDoc
60   {
61     startMessage(IiopReader.MSG_REPLY);
62     
63     write_long(0); // service control list
64
write_long(requestId); // request id
65
write_long(IiopReader.STATUS_NO_EXCEPTION); // okay
66
}
67   
68   /**
69    * Writes the header for a request
70    */

71   public void startReplySystemException(int requestId,
72                                         String JavaDoc exceptionId,
73                                         int minorStatus,
74                                         int completionStatus)
75     throws IOException JavaDoc
76   {
77     startMessage(IiopReader.MSG_REPLY);
78     
79     write_long(0); // service control list
80
write_long(requestId); // request id
81
write_long(IiopReader.STATUS_SYSTEM_EXCEPTION);
82
83     writeString(exceptionId);
84     write_long(minorStatus);
85     write_long(completionStatus);
86   }
87   
88   /**
89    * Writes the header for a request
90    */

91   public void startReplyUserException(int requestId)
92     throws IOException JavaDoc
93   {
94     startMessage(IiopReader.MSG_REPLY);
95     
96     write_long(0); // service control list
97
write_long(requestId); // request id
98
write_long(IiopReader.STATUS_USER_EXCEPTION);
99   }
100
101   /**
102    * Starts the message.
103    */

104   protected void startMessage(int type)
105     throws IOException JavaDoc
106   {
107     _out.start10Message(type);
108   }
109 }
110
Popular Tags