1 /* 2 Copyright 2008 Ramon Servadei 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 package fulmine.rpc; 17 18 import fulmine.model.field.IField; 19 import fulmine.util.reference.QuadValue; 20 21 /** 22 * A codec for RPC invocations. The coded encodes an RPC key and its arguments 23 * into a <code>byte[]</code> and decodes <code>byte[]</code> into an RPC key 24 * and arguments. 25 * 26 * @author Ramon Servadei 27 */ 28 public interface IRpcCodec 29 { 30 /** 31 * Decode the <code>byte[]</code> into the RPC marker, key, identity of the 32 * remote context invoking this RPC and arguments. The name of the remote 33 * context is important for updating the correct RPC result record. 34 * 35 * @param rpcData 36 * the <code>byte[]</code> to decode 37 * @return a {@link QuasValue} holding the RPC marker, key, identity of the 38 * remote context invoking this RPC and the arguments for the 39 * invocation, <code>null</code> if it cannot be decoded. 40 */ 41 QuadValue<IRpcMarker, String, String, IField[]> decode(byte[] rpcData); 42 43 /** 44 * Encode the RPC marker, key and arguments into a <code>byte[]</code> 45 * 46 * @param rpcMarker 47 * the RPC marker to encode 48 * @param rpcKey 49 * the RPC key to encode 50 * @param contextIdentity 51 * the identity of the context invoking the RPC 52 * @param args 53 * the arguments to encode 54 * @return a <code>byte[]</code> with the encoded RPC marker, key and 55 * arguments. 56 */ 57 byte[] encode(IRpcMarker rpcMarker, String rpcKey, String contextIdentity, 58 IField[] args); 59 60 }