Class CodeLocator


  • public class CodeLocator
    extends Object
    Class that maps agents and classloaders. The access to the methods should be made inside a synchronized block against the CodeLocator instance.
    Version:
    2.0
    Author:
    Jordi Cucurull Juan
    • Constructor Detail

      • CodeLocator

        public CodeLocator()
    • Method Detail

      • registerAgent

        public void registerAgent​(AID name,
                                  ClassLoader cl)
                           throws Exception
        Register an agent to the CodeLocator.
        Parameters:
        name - Agent name.
        cl - Agent associated classloader.
        localCode - Indicates the code is local (i.e. has not get to by any migration service) and cannot be modified.
        Throws:
        Exception
      • updateAgent

        public boolean updateAgent​(AID name,
                                   ClassLoader cl)
                            throws Exception
        Update an agent ClassLoader in the CodeLocator.
        Parameters:
        name - Agent name.
        cl - Agent associated classloader.
        Returns:
        True - Agent is updated. False - Agent cannot be updated.
        Throws:
        Exception
      • removeAgent

        public void removeAgent​(AID name)
        Remove an agent fromt the list.
        Parameters:
        name - Agent name.
      • cloneAgent

        public void cloneAgent​(AID oldName,
                               AID newName)
        Remove an agent fromt the list.
        Parameters:
        name - Agent name.
      • isRegistered

        public boolean isRegistered​(AID name)
        Check if the agent is registered.
        Parameters:
        name - Agent name.
        Returns:
        True - The agent is registered. False - The agent is not registered.
      • getAgentClassLoader

        public ClassLoader getAgentClassLoader​(AID name)
                                        throws Exception
        Get the agent associated classloader.
        Parameters:
        name - Agent name.
        Returns:
        The agent ClassLoader.
        Throws:
        Throws - and exception if the agent is not found.
        Exception
      • changeAgentName

        public void changeAgentName​(AID oldName,
                                    AID newName)
        Change the agent name.
        Parameters:
        oldName - Old agent name.
        newName - New agent name.
      • subscribeToEvents

        public void subscribeToEvents​(CodeLocatorListener cle)
        Method to subscribe to CodeLocator basic events from an external class.
        Parameters:
        cle - Class with a method per event which should be overloaded by users.
      • unSubscribeToEvents

        public boolean unSubscribeToEvents​(CodeLocatorListener cle)
        Method to unsubscribe to CodeLocator events.
        Parameters:
        cle - CodeLocatorListener class to unsubscribe.
        Returns:
        True - Unsubscription ok. False - Subscription not found.