1*2be43276SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2be43276SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2be43276SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2be43276SAndrew Rist * distributed with this work for additional information 6*2be43276SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2be43276SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2be43276SAndrew Rist * "License"); you may not use this file except in compliance 9*2be43276SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2be43276SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2be43276SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2be43276SAndrew Rist * software distributed under the License is distributed on an 15*2be43276SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2be43276SAndrew Rist * KIND, either express or implied. See the License for the 17*2be43276SAndrew Rist * specific language governing permissions and limitations 18*2be43276SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2be43276SAndrew Rist *************************************************************/ 21*2be43276SAndrew Rist 22*2be43276SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package com.sun.star.lib.uno.environments.remote; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import com.sun.star.lib.uno.typedesc.TypeDescription; 27cdf0e10cSrcweir import java.io.IOException; 28cdf0e10cSrcweir 29cdf0e10cSrcweir /** 30cdf0e10cSrcweir * An abstraction of remote bridge protocols. 31cdf0e10cSrcweir * 32cdf0e10cSrcweir * <p>A class implementing a given protocol <var>prot</var> must be named 33cdf0e10cSrcweir * <code>com.sun.star.lib.uno.protocols.<var>prot</var>.<var>prot</var></code> 34cdf0e10cSrcweir * and must have a public constructor that takes four arguments: The first 35cdf0e10cSrcweir * argument of type <code>com.sun.star.uno.IBridge</code> must not be null. The 36cdf0e10cSrcweir * second argument of type <code>String</code> represents any attributes; it may 37cdf0e10cSrcweir * be null if there are no attributes. The third argument of type 38cdf0e10cSrcweir * <code>java.io.InputStream</code> must not be null. The fourth argument of 39cdf0e10cSrcweir * type <code>java.io.OutputStream</code> must not be null.</p> 40cdf0e10cSrcweir */ 41cdf0e10cSrcweir public interface IProtocol { 42cdf0e10cSrcweir /** 43cdf0e10cSrcweir * Initializes the connection. 44cdf0e10cSrcweir * 45cdf0e10cSrcweir * <p>This method must be called exactly once, after the 46cdf0e10cSrcweir * <code>readMessage</code> loop has already been established.</p> 47cdf0e10cSrcweir */ init()48cdf0e10cSrcweir void init() throws IOException; 49cdf0e10cSrcweir terminate()50cdf0e10cSrcweir void terminate(); 51cdf0e10cSrcweir 52cdf0e10cSrcweir /** 53cdf0e10cSrcweir * Reads a request or reply message. 54cdf0e10cSrcweir * 55cdf0e10cSrcweir * <p>Access to this method from multiple threads must be properly 56cdf0e10cSrcweir * synchronized.</p> 57cdf0e10cSrcweir * 58cdf0e10cSrcweir * @return a non-null message; if the input stream is exhausted, a 59cdf0e10cSrcweir * <code>java.io.IOException</code> is thrown instead 60cdf0e10cSrcweir */ readMessage()61cdf0e10cSrcweir Message readMessage() throws IOException; 62cdf0e10cSrcweir 63cdf0e10cSrcweir /** 64cdf0e10cSrcweir * Writes a request message. 65cdf0e10cSrcweir * 66cdf0e10cSrcweir * @param oid a non-null OID 67cdf0e10cSrcweir * @param type a non-null UNO type 68cdf0e10cSrcweir * @param function a non-null function (the name of a UNO interface method 69cdf0e10cSrcweir * or attribute compatible with the given <code>type</code>, or either 70cdf0e10cSrcweir * <code>"queryInterface"</code> or <code>"release"</code>) 71cdf0e10cSrcweir * @param threadId a non-null TID 72cdf0e10cSrcweir * @param arguments a list of UNO arguments compatible with the given 73cdf0e10cSrcweir * <code>type</code> and <code>function</code>; may be null to represent 74cdf0e10cSrcweir * an empty list 75cdf0e10cSrcweir * @return <code>true</code> if the request message is sent as a synchronous 76cdf0e10cSrcweir * request 77cdf0e10cSrcweir */ writeRequest( String oid, TypeDescription type, String function, ThreadId tid, Object[] arguments)78cdf0e10cSrcweir boolean writeRequest( 79cdf0e10cSrcweir String oid, TypeDescription type, String function, ThreadId tid, 80cdf0e10cSrcweir Object[] arguments) 81cdf0e10cSrcweir throws IOException; 82cdf0e10cSrcweir 83cdf0e10cSrcweir /** 84cdf0e10cSrcweir * Writes a reply message. 85cdf0e10cSrcweir * 86cdf0e10cSrcweir * @param exception <code>true</code> if the reply corresponds to a raised 87cdf0e10cSrcweir * exception 88cdf0e10cSrcweir * @param tid a non-null TID 89cdf0e10cSrcweir * @param result if <code>exception</code> is <code>true</code>, a non-null 90cdf0e10cSrcweir * UNO exception; otherwise, a UNO return value, which may be null to 91cdf0e10cSrcweir * represent a <code>VOID</code> return value 92cdf0e10cSrcweir */ writeReply(boolean exception, ThreadId tid, Object result)93cdf0e10cSrcweir void writeReply(boolean exception, ThreadId tid, Object result) 94cdf0e10cSrcweir throws IOException; 95cdf0e10cSrcweir } 96