bump product version to 5.0.4.1
[LibreOffice.git] / jurt / com / sun / star / lib / uno / environments / remote / IProtocol.java
blobf736142e0b208b70274db7da77ac3defc5f65a21
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package com.sun.star.lib.uno.environments.remote;
21 import com.sun.star.lib.uno.typedesc.TypeDescription;
22 import java.io.IOException;
24 /**
25 * An abstraction of remote bridge protocols.
27 * <p>A class implementing a given protocol <var>prot</var> must be named
28 * <code>com.sun.star.lib.uno.protocols.<var>prot</var>.<var>prot</var></code>
29 * and must have a public constructor that takes four arguments: The first
30 * argument of type <code>com.sun.star.uno.IBridge</code> must not be null. The
31 * second argument of type <code>String</code> represents any attributes; it may
32 * be null if there are no attributes. The third argument of type
33 * <code>java.io.InputStream</code> must not be null. The fourth argument of
34 * type <code>java.io.OutputStream</code> must not be null.</p>
36 public interface IProtocol {
37 /**
38 * Initializes the connection.
40 * <p>This method must be called exactly once, after the
41 * <code>readMessage</code> loop has already been established.</p>
43 void init() throws IOException;
45 void terminate();
47 /**
48 * Reads a request or reply message.
50 * <p>Access to this method from multiple threads must be properly
51 * synchronized.</p>
53 * @return a non-null message; if the input stream is exhausted, a
54 * <code>java.io.IOException</code> is thrown instead.
56 Message readMessage() throws IOException;
58 /**
59 * Writes a request message.
61 * @param oid a non-null OID.
62 * @param type a non-null UNO type.
63 * @param function a non-null function (the name of a UNO interface method
64 * or attribute compatible with the given <code>type</code>, or either
65 * <code>"queryInterface"</code> or <code>"release"</code>).
66 * @param tid a non-null TID.
67 * @param arguments a list of UNO arguments compatible with the given
68 * <code>type</code> and <code>function</code>; may be null to represent
69 * an empty list.
70 * @return <code>true</code> if the request message is sent as a synchronous
71 * request.
73 boolean writeRequest(
74 String oid, TypeDescription type, String function, ThreadId tid,
75 Object[] arguments)
76 throws IOException;
78 /**
79 * Writes a reply message.
81 * @param exception <code>true</code> if the reply corresponds to a raised
82 * exception.
83 * @param tid a non-null TID.
84 * @param result if <code>exception</code> is <code>true</code>, a non-null
85 * UNO exception; otherwise, a UNO return value, which may be null to
86 * represent a <code>VOID</code> return value.
88 void writeReply(boolean exception, ThreadId tid, Object result)
89 throws IOException;