public class ReconfigurableClientAgent extends ReconfigurableClient<IAgentClient> implements IAgentClient
IClient.ListenerCommand| Constructor and Description |
|---|
ReconfigurableClientAgent() |
| Modifier and Type | Method and Description |
|---|---|
void |
closeConnection()
Closes the connection with the message server.
|
protected void |
configureMessageProcessor(AbstractMessageProcessor<IAgentClient> messageProcessor)
Configures the message processor.
|
protected IAgentClient |
createNewMessagingClient(String messageServerIp,
String messageServerUser,
String messageServerPwd,
String factoryName)
Creates a new messaging client and opens a connection with the messaging server.
|
protected IAgentClient |
getDismissedClient() |
boolean |
isConnected() |
void |
listenToExportsFromOtherAgents(IClient.ListenerCommand command,
net.roboconf.core.model.beans.Instance instance)
Configures the listener for the exports from other agents.
|
void |
listenToRequestsFromOtherAgents(IClient.ListenerCommand command,
net.roboconf.core.model.beans.Instance instance)
Configures the listener for requests from other agents.
|
void |
listenToTheDm(IClient.ListenerCommand command)
Configures the listener for messages from the DM.
|
void |
openConnection()
Opens a connection with the message server.
|
protected void |
openConnection(IAgentClient newMessagingClient)
Configures a newly created client.
|
void |
publishExports(net.roboconf.core.model.beans.Instance instance)
Publishes the exports for a given instance.
|
void |
publishExports(net.roboconf.core.model.beans.Instance instance,
String facetOrComponentName)
Publishes specific exports for a given instance.
|
void |
requestExportsFromOtherAgents(net.roboconf.core.model.beans.Instance instance)
Requests other agents to export their variables on the messaging server.
|
void |
sendMessageToTheDm(Message message)
Sends a message to the DM.
|
void |
setApplicationName(String applicationName)
Sets the application name.
|
void |
setIpAddress(String ipAddress) |
void |
setMessageQueue(LinkedBlockingQueue<Message> messageQueue)
Sets the message queue where the client can store the messages to process.
|
void |
setNeedsModel(boolean needsModel) |
void |
setParameters(String messageServerIp,
String messageServerUsername,
String messageServerPassword)
Sets the connection parameters.
|
void |
setRootInstanceName(String rootInstanceName)
Sets the name of the root instance associated with the agent.
|
void |
unpublishExports(net.roboconf.core.model.beans.Instance instance)
Un-publishes the exports for a given instance.
|
associateMessageProcessor, getMessageProcessor, getMessagingClient, hasValidClient, resetInternalClient, switchMessagingClientprotected IAgentClient createNewMessagingClient(String messageServerIp, String messageServerUser, String messageServerPwd, String factoryName) throws IOException
ReconfigurableClientcreateNewMessagingClient in class ReconfigurableClient<IAgentClient>messageServerIp - the server's IPmessageServerUser - the server's user namemessageServerPwd - the server's passwordfactoryName - the factory name (see MessagingConstants)IOException - if something went wrongprotected void openConnection(IAgentClient newMessagingClient) throws IOException
ReconfigurableClientFor an agent, it consists into listening to messages coming from the DM.
For the DM, it consists in listening to messages coming from various agents.
openConnection in class ReconfigurableClient<IAgentClient>newMessagingClient - the messaging client to configureIOException - if something went wrongprotected IAgentClient getDismissedClient()
getDismissedClient in class ReconfigurableClient<IAgentClient>protected void configureMessageProcessor(AbstractMessageProcessor<IAgentClient> messageProcessor)
ReconfigurableClientconfigureMessageProcessor in class ReconfigurableClient<IAgentClient>messageProcessor - the message processorpublic void setParameters(String messageServerIp, String messageServerUsername, String messageServerPassword)
IClientsetParameters in interface IClientmessageServerIp - the IP address of the messaging servermessageServerUsername - the user name to connect to the servermessageServerPassword - the password to connect to the serverpublic void setMessageQueue(LinkedBlockingQueue<Message> messageQueue)
IClientsetMessageQueue in interface IClientmessageQueue - the message queuepublic boolean isConnected()
isConnected in interface IClientpublic void openConnection()
throws IOException
IClientopenConnection in interface IClientIOExceptionpublic void closeConnection()
throws IOException
IClient
There is no need to check IClient.isConnected() before invoking this method.
closeConnection in interface IClientIOExceptionpublic void publishExports(net.roboconf.core.model.beans.Instance instance)
throws IOException
IAgentClientThis method indicates to other instances that they can use the variables exported by THIS instance.
publishExports in interface IAgentClientinstance - the instance whose exports must be publishedIOException - if something went wrongpublic void publishExports(net.roboconf.core.model.beans.Instance instance,
String facetOrComponentName)
throws IOException
IAgentClientpublishExports in interface IAgentClientinstance - the instance whose exports must be publishedfacetOrComponentName - the prefix of the variables to publishIOException - if something went wrongpublic void unpublishExports(net.roboconf.core.model.beans.Instance instance)
throws IOException
IAgentClientThis method indicates to other instances that the variables exported by THIS instance cannot be used anymore.
unpublishExports in interface IAgentClientinstance - the instance whose exports must be publishedIOException - if something went wrongpublic void listenToRequestsFromOtherAgents(IClient.ListenerCommand command, net.roboconf.core.model.beans.Instance instance) throws IOException
IAgentClientSuch requests aim at asking an agent to publish its exports. The agent will do so only if it exports a variable prefixed that is required by THIS instance.
listenToRequestsFromOtherAgents in interface IAgentClientcommand - ListenerCommand#START to start listening, ListenerCommand#STOP to stop listeninginstance - the instance that need exports from other agentsIOException - if something went wrongpublic void requestExportsFromOtherAgents(net.roboconf.core.model.beans.Instance instance)
throws IOException
IAgentClientThis should be called when a new instance is registered on the agent. It guarantees that any new instance can be notified about the instances located on other agents.
requestExportsFromOtherAgents in interface IAgentClientinstance - the instance that need exports from other agentsIOException - if something went wrongpublic void listenToExportsFromOtherAgents(IClient.ListenerCommand command, net.roboconf.core.model.beans.Instance instance) throws IOException
IAgentClientlistenToExportsFromOtherAgents in interface IAgentClientcommand - ListenerCommand#START to start listening, ListenerCommand#STOP to stop listeninginstance - the instance that determine which exports must be listened toIOException - if something went wrongpublic void sendMessageToTheDm(Message message) throws IOException
IClientsendMessageToTheDm in interface IClientmessage - the message to sendIOException - if something went wrongpublic void listenToTheDm(IClient.ListenerCommand command) throws IOException
IClientlistenToTheDm in interface IClientcommand - IClient.ListenerCommand.START to stop listening, IClient.ListenerCommand.STOP to stop listeningIOException - if something went wrongpublic void setApplicationName(String applicationName)
IAgentClientsetApplicationName in interface IAgentClientpublic void setRootInstanceName(String rootInstanceName)
IAgentClientsetRootInstanceName in interface IAgentClientpublic void setIpAddress(String ipAddress)
public void setNeedsModel(boolean needsModel)
Copyright © 2015. All rights reserved.