/*********************************************************************/
/* */
/* AgentService Framework */
/* www.agentservice.it */
/* */
/* Copyright (C) 2007 l.i.d.o. - DIST, University of Genoa, Italy */
/* GNU Lesser General Public License */
/* */
/* This library is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Lesser General Public */
/* License as published by the Free Software Foundation, */
/* version 2.1 of the License. */
/* */
/* This library is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
/* Lesser General Public License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public */
/* License along with this library; if not, write to the */
/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */
/* Boston, MA 02111-1307, USA. */
/* */
/*********************************************************************/
using System;
using AgentService;
using AgentService.Platform.DF;
using AgentService.Platform.AMS;
namespace AgentService.Agent.Runtime
{
///
/// Class DefaultYelloPagesClient. Provides a default implementation of the IYellowPagesClient interface.
///
public class DefaultYellowPagesClient: IYellowPagesClient
{
///
/// AID of the agent instance that owns the client.
///
private AID aid;
///
/// Reference to the YellowPages service.
///
private IYellowPagesServer yellowPagesServer;
///
/// Constructs a DefaultYellowPagesClient.
///
/// aid of the owning agent
/// reference to the YellowPages service
public DefaultYellowPagesClient(AID aid, IYellowPagesServer yellowPagesServer)
{
this.aid = aid;
this.yellowPagesServer = yellowPagesServer;
}
#region IYellowPagesClient Members
///
/// Searches for agents that offer the given service description.
///
/// description of the required service
/// array of agent descriptions that offer the given service
public DFAgentDescription[] SearchAgent(ServiceDescription sd)
{
lock(this.yellowPagesServer)
{
return this.yellowPagesServer.SearchAgent(sd);
}
}
///
/// Searches for agents that offer the given service description.
///
/// description of the required service
/// Flags that specify which fields are used to compare the services
/// array of agent descriptions that offer the given service
public DFAgentDescription[] SearchAgent(ServiceDescription sd, ServiceComparison flags)
{
lock(this.yellowPagesServer)
{
return this.yellowPagesServer.SearchAgent(sd, flags);
}
}
///
/// Searches for agents that offer the given service description, by following the given constraints.
///
/// description of the required service
/// set of constraints that will be applied to the search
/// array of agent descriptions that offer the given service
public DFAgentDescription[] SearchAgent(ServiceDescription sd, SearchConstraints constraint)
{
lock(this.yellowPagesServer)
{
return this.yellowPagesServer.SearchAgent(sd, constraint);
}
}
///
/// Searches for agents that offer the given service description, by following the given constraints.
///
/// description of the required service
/// Flags that specify which fields are used to compare the services
/// set of constraints that will be applied to the search
/// array of agent descriptions that offer the given service
public DFAgentDescription[] SearchAgent(ServiceDescription sd, ServiceComparison flags, SearchConstraints constraint)
{
lock(this.yellowPagesServer)
{
return this.yellowPagesServer.SearchAgent(sd, flags, constraint);
}
}
///
/// Registers an agent with the directory facilitator service.
///
/// description of the services promoted by the agent
public void Register(DFAgentDescription description)
{
lock(this.yellowPagesServer)
{
description.Aid = this.aid;
this.yellowPagesServer.Register(description);
}
}
///
/// Modifies the agent description previously registered with the directory facilitator service.
///
/// description of the services promoted by the agent
public void Edit(DFAgentDescription description)
{
lock(this.yellowPagesServer)
{
description.Aid = this.aid;
this.yellowPagesServer.Edit(description);
}
}
///
/// Deregisters an agent with the directory facilitator service.
///
public void Deregister()
{
lock(this.yellowPagesServer)
{
this.yellowPagesServer.Deregister(this.aid);
}
}
///
/// Deregisters an agent with the directory facilitator service.
///
/// identifier of the agents whoes description has to be removed
public void Deregister(AID aid)
{
lock (this.yellowPagesServer)
{
this.yellowPagesServer.Deregister(aid);
}
}
#endregion
#region IRuntimeBindable Members
///
/// Connects the runtime component to the events
/// originated by the agent instance.
///
/// proxy to the agent instance
public void BindEvents(IAgentEventProxy proxy)
{}
///
/// Disconnects the runtime component to the events
/// originated by the agent instance.
///
/// proxy to the agent instance
public void UnbindEvents(IAgentEventProxy proxy)
{}
#endregion
}
}