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 announcement data
26 * according to discovery protocol formats.
27 *
28 * @author Sun Microsystems, Inc.
29 * @since 2.0
30 */
31 public interface MulticastAnnouncementEncoder extends DiscoveryFormatProvider {
32
33 /**
34 * Encodes the given multicast announcement data into byte buffers obtained
35 * from the provided datagram buffer factory, in a manner that satisfies
36 * the specified absolute constraints. <code>null</code> constraints are
37 * considered equivalent to empty constraints. Multicast announcement data
38 * that is too large to fit in a single datagram buffer is split across
39 * multiple 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 announcement the announcement 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>announcement</code> or
54 * <code>bufs</code> is <code>null</code>
55 */
56 void encodeMulticastAnnouncement(MulticastAnnouncement announcement,
57 DatagramBufferFactory bufs,
58 InvocationConstraints constraints)
59 throws IOException;
60 }