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 java.net.Socket;
23 import java.nio.ByteBuffer;
24 import java.util.Collection;
25 import net.jini.core.constraint.InvocationConstraints;
26 import net.jini.io.UnsupportedConstraintException;
27
28 /**
29 * Interface implemented by classes which handle the server (lookup service)
30 * side of unicast discovery.
31 *
32 * @author Sun Microsystems, Inc.
33 * @since 2.0
34 */
35 public interface UnicastDiscoveryServer extends DiscoveryFormatProvider {
36
37 /**
38 * Checks and returns normally if this server is capable of fulfilling the
39 * given absolute constraints. <code>null</code> constraints are
40 * considered equivalent to empty constraints.
41 *
42 * @param constraints the constraints to check, or <code>null</code>
43 * @throws UnsupportedConstraintException if unable to satisfy the
44 * specified constraints
45 * @throws SecurityException if the given constraints cannot be satisfied
46 * due to insufficient caller permissions
47 */
48 void checkUnicastDiscoveryConstraints(InvocationConstraints constraints)
49 throws UnsupportedConstraintException;
50
51 /**
52 * Handles the server side of unicast discovery, transmitting the given
53 * response data over the provided socket using the given collection of
54 * object stream context objects in a manner that satisfies the specified
55 * absolute constraints and client subject checker (if any). Byte buffers
56 * containing the data received and sent so far over the given socket (for
57 * the unicast discovery protocol 2 handshake) are provided for use by
58 * formats which integrity protect or otherwise incorporate the handshake
59 * data. <code>null</code> constraints are considered equivalent to empty
60 * constraints.
61 *
62 * @param response the unicast response data to transmit
63 * @param socket the socket on which to handle unicast discovery
64 * @param constraints the constraints to apply to unicast discovery, or
65 * <code>null</code>
66 * @param checker the object to use to check the client subject, or
67 * <code>null</code>
68 * @param context the collection of context information objects to use when
69 * marshalling the registrar proxy
70 * @param received a buffer containing the data already received
71 * @param sent a buffer containing the data already sent
72 * @throws IOException if an error occurs in interpreting received data or
73 * in formatting data to send
74 * @throws UnsupportedConstraintException if unable to satisfy the
75 * specified constraints
76 * @throws SecurityException if the given constraints cannot be satisfied
77 * due to insufficient caller permissions, or if the client subject check
78 * fails
79 * @throws NullPointerException if <code>response</code>,
80 * <code>socket</code>, <code>context</code>, <code>received</code>, or
81 * <code>sent</code> is <code>null</code>
82 */
83 void handleUnicastDiscovery(UnicastResponse response,
84 Socket socket,
85 InvocationConstraints constraints,
86 ClientSubjectChecker checker,
87 Collection context,
88 ByteBuffer received,
89 ByteBuffer sent)
90 throws IOException;
91 }