Class AgentFactory

  • All Implemented Interfaces:
    AgentMBean, Encodable, Serializable

    final class AgentFactory
    extends Agent
    Agent used to allow remote agent creation. Every agent server hosts a factory agent, they all use a predefined stamp identifier AgentId.factoryId. The factory must be able to create all types of objects, actually it is supposed that the corresponding classes can be reached.

    The agent creation process involves the following steps

    • locally creating the Agent object in memory ;
    • serializing the agent state, building an AgentCreateRequest notification with the resulting string, sending it to the target Factory agent ;
    • the factory agent building the object in memory from the serialized image, and saving it into operational storage ;
    • the factory agent calling the initialize method.
    The AgentDeleteRequest class of notification follows a similar process to remotely delete agents.
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        define serialVersionUID for interoperability
        See Also:
        Constant Field Values
    • Constructor Detail

      • AgentFactory

        AgentFactory​(AgentId factoryId)
        Allocates a new AgentFactory agent. An AgentFactory agent must be created on every agent server the first time it runs.
        Parameters:
        factoryId - unique identifier for factory agent.
    • Method Detail

      • getLogTopic

        protected String getLogTopic()
        Returns log topic for factory agent.
        Overrides:
        getLogTopic in class Agent
        Returns:
        the default log topic for agents.
      • agentInitialize

        protected void agentInitialize​(boolean firstTime)
                                throws Exception
        Gives this agent an opportunity to initialize after having been deployed, and each time it is loaded into memory. Loads the list of agents with a fixed field set to true.
        Overrides:
        agentInitialize in class Agent
        Parameters:
        firstTime - true when first called by the factory
        Throws:
        Exception - unspecialized exception
      • react

        public void react​(AgentId from,
                          Notification not)
                   throws Exception
        Reacts to notifications ... .
        Overrides:
        react in class Agent
        Parameters:
        from - agent sending notification
        not - notification to react to
        Throws:
        Exception - unspecialized exception