org.apache.river.reggie.proxy.RegistrarLeaseMap Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.river.reggie.proxy;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import net.jini.core.lease.Lease;
import net.jini.core.lease.LeaseMapException;
import net.jini.core.lookup.ServiceID;
import net.jini.id.Uuid;
import org.apache.river.lease.AbstractIDLeaseMap;
/**
* The LeaseMap implementation class for registrar leases. Clients only see
* instances via the LeaseMap interface.
*
* @author Sun Microsystems, Inc.
*
*/
class RegistrarLeaseMap extends AbstractIDLeaseMap {
private static final long serialVersionUID = 2L;
/**
* The registrar.
*
* @serial
*/
final Registrar server;
/**
* The registrar's service ID.
*
* @serial
*/
final ServiceID registrarID;
/** Simple constructor */
RegistrarLeaseMap(RegistrarLease lease, long duration) {
this(lease.getRegistrar(), lease, duration);
}
/** Constructor used by ConstrainableRegistrarLeaseMap */
RegistrarLeaseMap(Registrar server, RegistrarLease lease, long duration) {
super();
this.server = server;
registrarID = lease.getRegistrarID();
put(lease, Long.valueOf(duration));
}
/** Any RegistrarLease from the same server can be in the map */
public boolean canContainKey(Object key) {
return (key instanceof RegistrarLease &&
registrarID.equals(((RegistrarLease) key).getRegistrarID()));
}
// This method's javadoc is inherited from an interface of this class
public void renewAll() throws LeaseMapException, RemoteException {
if (isEmpty()) return;
List leases = new LinkedList();
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy