@@ -0,0 +1,2069 @@
+/*****************************************************************%0AJADE - Java Agent DEvelopment Framework is a framework to develop %0Amulti-agent systems in compliance with the FIPA specifications.%0ACopyright (C) 2000 CSELT S.p.A. %0A%0AThe updating of this file to JADE 2.0 has been partially supported by the IST-1999-10211 LEAP Project%0A%0AGNU Lesser General Public License%0A%0AThis library is free software; you can redistribute it and/or%0Amodify it under the terms of the GNU Lesser General Public%0ALicense as published by the Free Software Foundation, %0Aversion 2.1 of the License. %0A%0AThis library is distributed in the hope that it will be useful,%0Abut WITHOUT ANY WARRANTY; without even the implied warranty of%0AMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0ALesser General Public License for more details.%0A%0AYou should have received a copy of the GNU Lesser General Public%0ALicense along with this library; if not, write to the%0AFree Software Foundation, Inc., 59 Temple Place - Suite 330,%0ABoston, MA  02111-1307, USA.%0A*****************************************************************/%0A%0Apackage jade.domain.KBManagement;%0A%0A/**%0A * @author Elisabetta Cortese - TILab%0A *%0A */%0Aimport jade.domain.FIPAAgentManagement.DFAgentDescription;%0Aimport jade.domain.KBManagement.*;%0A%0Aimport java.util.Date;%0A%0A%0Apublic class DFLeaseManager implements LeaseManager%7B%0A%09%0A%09public Date getLeaseTime(Object item)%7B%0A%09%09if(item instanceof DFAgentDescription)%7B%0A%09%09%09return ((DFAgentDescription) item).getLeaseTime();%0A%09%09%7D%0A%09%09else%7B%0A%09%09%09return DEFAULT_LEASE_TIME;%0A%09%09%7D%0A%09%7D%0A%09%0A%09public void setLeaseTime(Object item, Date lease)%7B%0A%09%09%0A%09%09if(item instanceof DFAgentDescription)%7B%0A%09%09%09if(isValid(lease))%7B%0A%09%09%09%09((DFAgentDescription) item).setLeaseTime(lease);%0A%09%09%09%7D%0A%09%09%09else%7B%0A%09%09%09%09((DFAgentDescription) item).setLeaseTime(DEFAULT_LEASE_TIME);%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09public Object grantLeaseTime(Object item)%7B%0A%09%09// Always grant the requested lease time%0A%09%09return item;%0A%09%7D%0A%09%0A%09public boolean isValid(Date lease)%7B%0A%09%09%0A%09%09if(lease.getTime() %3E= System.currentTimeMillis() %7C%7C lease.getTime() == -1)%0A%09%09%09return true;%0A%09%09return false;%0A%09%7D%0A%0A%7D%0A

Implement the lease manager for DF