View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    * 
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   * 
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.apache.river.discovery;
20  
21  import java.io.IOException;
22  import net.jini.core.constraint.InvocationConstraints;
23  
24  /**
25   * Interface implemented by classes which encode multicast request data
26   * according to discovery protocol formats.
27   *
28   * @author Sun Microsystems, Inc.
29   * @since 2.0
30   */
31  public interface MulticastRequestEncoder extends DiscoveryFormatProvider {
32  
33      /**
34       * Encodes the given multicast request data into byte buffers obtained from
35       * the provided datagram buffer factory, in a manner that satisfies the
36       * specified absolute constraints.  <code>null</code> constraints are
37       * considered equivalent to empty constraints.  Multicast request data that
38       * is too large to fit in a single datagram buffer is split across multiple
39       * buffers, with the constraints applied to each; this method is
40       * responsible for determining if and when to split the data based on the
41       * available space in the obtained buffers.
42       *
43       * @param request the request data to encode
44       * @param bufs the factory for producing buffers in which to write encoded
45       * data
46       * @param constraints the constraints to apply when encoding the data, or
47       * <code>null</code>
48       * @throws IOException if an error occurs in encoding the data to send
49       * @throws net.jini.io.UnsupportedConstraintException if unable to satisfy
50       * the specified constraints
51       * @throws SecurityException if the given constraints cannot be satisfied
52       * due to insufficient caller permissions
53       * @throws NullPointerException if <code>request</code> or
54       * <code>bufs</code> is <code>null</code>
55       *
56       * Throws IOException if an error
57       * occurs in encoding the data to send.  Throws
58       * UnsupportedConstraintException if unable to satisfy the specified
59       * constraints.  Throws SecurityException if the given constraints cannot
60       * be satisfied due to insufficient caller permissions.
61       */
62      void encodeMulticastRequest(MulticastRequest request,
63  				DatagramBufferFactory bufs,
64  				InvocationConstraints constraints)
65  	throws IOException;
66  }