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 net.jini.core.lookup; 20 21 import java.rmi.RemoteException; 22 import net.jini.core.lease.*; 23 import net.jini.core.entry.Entry; 24 25 /** 26 * A registered service item is manipulated using an instance of this class. 27 * This is not a remote interface; each implementation of the lookup service 28 * exports proxy objects that implement this interface local the client. The 29 * proxy methods obey normal RMI remote interface semantics. Every method 30 * invocation (on both ServiceRegistrar and ServiceRegistration) is atomic 31 * with respect to other invocations. 32 * 33 * @author Sun Microsystems, Inc. 34 * 35 * @see ServiceRegistrar 36 * 37 * @since 1.0 38 */ 39 public interface ServiceRegistration { 40 41 /** 42 * Returns the service ID for this service. Note that this method 43 * does not make a remote call. 44 * 45 * @return the ServiceID for this service. 46 */ 47 ServiceID getServiceID(); 48 49 /** 50 * Returns the lease that controls the service registration, allowing 51 * the lease to be renewed or cancelled. Note that this does not make 52 * a remote call. 53 * 54 * @return the lease that controls this service registration. 55 */ 56 Lease getLease(); 57 58 /** 59 * Adds the specified attribute sets (those that aren't duplicates of 60 * existing attribute sets) to the registered service item. Note that 61 * this operation has no effect on existing attribute sets of the 62 * service item, and can be repeated in an idempotent fashion. 63 * 64 * @param attrSets attribute sets to add 65 * @throws UnknownLeaseException the registration lease has expired 66 * or been cancelled. 67 * @throws java.rmi.RemoteException when a connection issue occurs. 68 */ 69 void addAttributes(Entry[] attrSets) 70 throws UnknownLeaseException, RemoteException; 71 72 /** 73 * Modifies existing attribute sets. The lengths of attrSetTemplates and 74 * attrSets must be equal, or IllegalArgumentException is thrown. The 75 * service item's attribute sets are modified as follows. For each array 76 * index i: if attrSets[i] is null, then every entry that matches 77 * attrSetTemplates[i] is deleted; otherwise, for every non-null field 78 * in attrSets[i], the value of that field is stored into the 79 * corresponding field of every entry that matches attrSetTemplates[i]. 80 * The class of attrSets[i] must be the same as, or a superclass of, the 81 * class of attrSetTemplates[i], or IllegalArgumentException is thrown. 82 * If the modifications result in duplicate entries within the service 83 * item, the duplicates are eliminated. 84 * <p> 85 * Note that it is possible to use modifyAttributes in ways that are not 86 * idempotent. The attribute schema should be designed in such a way 87 * that all intended uses of this method can be performed in an 88 * idempotent fashion. Also note that modifyAttributes does not provide 89 * a means for setting a field to null; it is assumed that the attribute 90 * schema is designed in such a way that this is not necessary. 91 * 92 * @param attrSetTemplates attribute set templates to match 93 * @param attrSets modifications to make to matching attribute sets 94 * @throws UnknownLeaseException the registration lease has expired 95 * or been cancelled 96 * @throws IllegalArgumentException lengths of attrSetTemplates and 97 * attrSets are not equal, or class of an attrSets element is 98 * not the same as, or a superclass of, the class of the 99 * corresponding attrSetTemplates element 100 * @throws java.rmi.RemoteException when a connection issue occurs. 101 */ 102 void modifyAttributes(Entry[] attrSetTemplates, Entry[] attrSets) 103 throws UnknownLeaseException, RemoteException; 104 105 /** 106 * Deletes all of the service item's existing attributes, and replaces 107 * them with the specified attribute sets. Any duplicate attribute sets 108 * are eliminated in the stored representation of the item. 109 * 110 * @param attrSets attribute sets to use 111 * @throws UnknownLeaseException the registration lease has expired 112 * or been cancelled 113 * @throws java.rmi.RemoteException when a connection issue occurs. 114 */ 115 void setAttributes(Entry[] attrSets) 116 throws UnknownLeaseException, RemoteException; 117 }