/*********************************************************************/ /* */ /* 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; using System.ServiceModel; using AgentService.Platform.Modules; namespace AgentService.Agent.Runtime { [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, AddressFilterMode = AddressFilterMode.Any)] public class RemoteYellowPagesClient: IYellowPagesClient { /// /// Reference to the YellowPages service. /// private IYellowPagesServer yellowPagesServer; /// /// Constructs a DefaultYellowPagesClient. /// /// aid of the owning agent /// reference to the YellowPages service public RemoteYellowPagesClient(IYellowPagesServer yellowPagesServer) { 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) { 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) { this.yellowPagesServer.Edit(description); } } /// /// Deregisters an agent with the directory facilitator service. /// public void Deregister() { //Not used in remote version of the client } /// /// 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 } }