merge the formfield patch from ooo-build
[ooovba.git] / jurt / com / sun / star / lib / uno / environments / remote / IProtocol.java
blobad92723017c7949e09e9006e74ddba4de588f2b3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: IProtocol.java,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package com.sun.star.lib.uno.environments.remote;
33 import com.sun.star.lib.uno.typedesc.TypeDescription;
34 import java.io.IOException;
36 /**
37 * An abstraction of remote bridge protocols.
39 * <p>A class implementing a given protocol <var>prot</var> must be named
40 * <code>com.sun.star.lib.uno.protocols.<var>prot</var>.<var>prot</var></code>
41 * and must have a public constructor that takes four arguments: The first
42 * argument of type <code>com.sun.star.uno.IBridge</code> must not be null. The
43 * second argument of type <code>String</code> represents any attributes; it may
44 * be null if there are no attributes. The third argument of type
45 * <code>java.io.InputStream</code> must not be null. The fourth argument of
46 * type <code>java.io.OutputStream</code> must not be null.</p>
48 public interface IProtocol {
49 /**
50 * Initializes the connection.
52 * <p>This method must be called exactly once, after the
53 * <code>readMessage</code> loop has already been established.</p>
55 void init() throws IOException;
57 /**
58 * Reads a request or reply message.
60 * <p>Access to this method from multiple threads must be properly
61 * synchronized.</p>
63 * @return a non-null message; if the input stream is exhausted, a
64 * <code>java.io.IOException</code> is thrown instead
66 Message readMessage() throws IOException;
68 /**
69 * Writes a request message.
71 * @param oid a non-null OID
72 * @param type a non-null UNO type
73 * @param function a non-null function (the name of a UNO interface method
74 * or attribute compatible with the given <code>type</code>, or either
75 * <code>"queryInterface"</code> or <code>"release"</code>)
76 * @param threadId a non-null TID
77 * @param arguments a list of UNO arguments compatible with the given
78 * <code>type</code> and <code>function</code>; may be null to represent
79 * an empty list
80 * @return <code>true</code> if the request message is sent as a synchronous
81 * request
83 boolean writeRequest(
84 String oid, TypeDescription type, String function, ThreadId tid,
85 Object[] arguments)
86 throws IOException;
88 /**
89 * Writes a reply message.
91 * @param exception <code>true</code> if the reply corresponds to a raised
92 * exception
93 * @param tid a non-null TID
94 * @param result if <code>exception</code> is <code>true</code>, a non-null
95 * UNO exception; otherwise, a UNO return value, which may be null to
96 * represent a <code>VOID</code> return value
98 void writeReply(boolean exception, ThreadId tid, Object result)
99 throws IOException;