Class AbstractEnvironmentSpace

    • Field Detail

      • objecttypes

        protected java.util.Map objecttypes
        The space object types.
      • objecttypesMeta

        protected java.util.Map objecttypesMeta
        The space object meta data
      • tasktypes

        protected java.util.Map tasktypes
        The object task types.
      • processtypes

        protected java.util.Map processtypes
        The space process types.
      • percepttypes

        protected java.util.Map percepttypes
        The percepttypes.
      • actions

        protected java.util.Map actions
        Available component actions.
      • perceptgenerators

        protected java.util.Map perceptgenerators
        The percept generators.
      • perceptprocessors

        protected MultiCollection<java.lang.String,​java.lang.Object[]> perceptprocessors
        The percept processors.
      • initialavatars

        protected java.util.Map initialavatars
        Initial avatar settings (cid -> [type, props]).
      • dataviewmappings

        protected MultiCollection<java.lang.String,​java.util.Map> dataviewmappings
        Data view mappings.
      • processes

        protected java.util.Map processes
        The environment processes.
      • spaceobjects

        protected java.util.Map spaceobjects
        Long/ObjectIDs (keys) and environment objects (values).
      • spaceobjectsbytype

        protected java.util.Map spaceobjectsbytype
        Types of EnvironmentObjects and lists of EnvironmentObjects of that type (typed view).
      • spaceobjectsbyowner

        protected java.util.Map spaceobjectsbyowner
        Space objects by owner.
      • actionlist

        protected ComponentActionList actionlist
        The list of scheduled component actions.
      • perceptlist

        protected PerceptList perceptlist
        The list of scheduled percepts.
      • views

        protected java.util.Map views
        Available views
      • listeners

        protected java.util.List listeners
        The environment listeners.
      • dataproviders

        protected java.util.Map dataproviders
        The data providers (name -> provider).
      • dataconsumers

        protected java.util.Map dataconsumers
        The data consumers.
      • zombieobjects

        protected java.util.Map zombieobjects
        The zombie objects.
      • observercenters

        protected java.util.List observercenters
        The observers.
      • classloader

        protected java.lang.ClassLoader classloader
        The class loader.
    • Constructor Detail

      • AbstractEnvironmentSpace

        public AbstractEnvironmentSpace()
        Create an environment space
    • Method Detail

      • initSpace

        public IFuture<java.lang.Void> initSpace()
        Create a space.
      • addSpaceObjectType

        public void addSpaceObjectType​(java.lang.String typename,
                                       IPropertyMetaDataSet mobjecttype)
        Add a space type.
        Specified by:
        addSpaceObjectType in interface IEnvironmentSpace
        Parameters:
        typename - The type name.
        initproperties - The MobjectType.
      • removeSpaceObjectType

        public void removeSpaceObjectType​(java.lang.String typename)
        Remove a space object type.
        Specified by:
        removeSpaceObjectType in interface IEnvironmentSpace
        Parameters:
        typename - The type name.
      • addSpaceProcessType

        public void addSpaceProcessType​(java.lang.String typename,
                                        java.lang.Class clazz,
                                        java.util.List properties)
        Add a space process type.
        Specified by:
        addSpaceProcessType in interface IEnvironmentSpace
        Parameters:
        typename - The type name.
        properties - The properties.
      • removeSpaceProcessType

        public void removeSpaceProcessType​(java.lang.String typename)
        Remove a space process type.
        Specified by:
        removeSpaceProcessType in interface IEnvironmentSpace
        Parameters:
        typename - The type name.
      • createSpaceProcess

        public void createSpaceProcess​(java.lang.String typename,
                                       java.util.Map properties)
        Creates a space process.
        Specified by:
        createSpaceProcess in interface IEnvironmentSpace
        Parameters:
        typename - The type name.
        properties - The properties.
      • addObjectTaskType

        public void addObjectTaskType​(java.lang.String typename,
                                      java.lang.Class clazz,
                                      java.util.List properties)
        Add a object task type.
        Specified by:
        addObjectTaskType in interface IEnvironmentSpace
        Parameters:
        typename - The type name.
        properties - The properties.
      • removeObjectTaskType

        public void removeObjectTaskType​(java.lang.String typename)
        Remove an object task type.
        Specified by:
        removeObjectTaskType in interface IEnvironmentSpace
        Parameters:
        typename - The type name.
      • createObjectTask

        public java.lang.Object createObjectTask​(java.lang.String typename,
                                                 java.util.Map properties,
                                                 java.lang.Object objectid)
        Creates an object task.
        Specified by:
        createObjectTask in interface IEnvironmentSpace
        Parameters:
        typename - The type name.
        properties - The properties.
        Returns:
        The task id.
      • removeObjectTask

        public void removeObjectTask​(java.lang.Object taskid,
                                     java.lang.Object objectid)
        Remove an object task.
        Specified by:
        removeObjectTask in interface IEnvironmentSpace
        Parameters:
        typename - The type name.
        initproperties - The properties.
      • addTaskListener

        public void addTaskListener​(java.lang.Object taskid,
                                    java.lang.Object objectid,
                                    IResultListener listener)
        Add a result listener to an object task. The listener result will be the task id. If the task is already finished, the listener will be notified.
        Specified by:
        addTaskListener in interface IEnvironmentSpace
      • waitForTask

        public IFuture<java.lang.Void> waitForTask​(java.lang.Object taskid,
                                                   java.lang.Object objectid)
        Add a result listener to an object task. The listener result will be the task id. If the task is already finished, the listener will be notified.
        Specified by:
        waitForTask in interface IEnvironmentSpace
      • getSpaceProcessNames

        public java.util.Set getSpaceProcessNames()
        Returns then names of the space processes.
        Returns:
        the names of the space processes
      • getSpaceProcess

        public ISpaceProcess getSpaceProcess​(java.lang.Object id)
        Returns a space process.
        Specified by:
        getSpaceProcess in interface IEnvironmentSpace
        Parameters:
        id - ID of the space process
        Returns:
        the space process or null if not found
      • removeSpaceProcess

        public void removeSpaceProcess​(java.lang.Object id)
        Removes a space process.
        Specified by:
        removeSpaceProcess in interface IEnvironmentSpace
        Parameters:
        id - ID of the space process
      • createSpaceObject

        public final ISpaceObject createSpaceObject​(java.lang.String typename,
                                                    java.util.Map properties,
                                                    java.util.List tasks)
        Creates an object in this space.
        Specified by:
        createSpaceObject in interface IEnvironmentSpace
        Parameters:
        type - the object's type
        properties - initial properties (may be null)
        tasks - initial task list (may be null)
        Returns:
        the object's ID
      • createSpaceObjectZombie

        public ISpaceObject createSpaceObjectZombie​(java.lang.String typename,
                                                    java.util.Map properties,
                                                    java.util.List tasks)
        Creates a zombie object in this space. Zombies are not (yet) visible in the space and must be inited separately.
        Parameters:
        type - the object's type
        properties - initial properties (may be null)
        tasks - initial task list (may be null)
        Returns:
        the object's ID
      • initSpaceObject

        public void initSpaceObject​(ISpaceObject ret)
        Creates an object in this space.
        Parameters:
        type - the object's type
        initproperties - initial properties (may be null)
        tasks - initial task list (may be null)
        listeners - initial listeners (may be null)
      • mergeProperties

        protected java.util.Map mergeProperties​(java.util.Collection typeprops,
                                                java.util.Map properties)
        Add type properties to runtime properties. Runtime properties have precedence if specified.
        Parameters:
        typeprops - The type properties (if any).
        properties - The runtime properties or null.
        Returns:
        The merged runtime properties.
      • mergeProperties

        protected java.util.Map mergeProperties​(IPropertyMetaDataSet mObjectType,
                                                java.util.Map properties)
        Add type properties to runtime properties. Runtime properties have precedence if specified.
        Parameters:
        typeprops - The type
        properties - The runtime properties or null.
        Returns:
        The merged runtime properties.
      • destroySpaceObject

        public void destroySpaceObject​(java.lang.Object id)
        Destroys an object in this space.
        Specified by:
        destroySpaceObject in interface IEnvironmentSpace
        Parameters:
        id - the object's ID
      • getSpaceObject

        public ISpaceObject getSpaceObject​(java.lang.Object id)
        Returns an object in this space.
        Specified by:
        getSpaceObject in interface IEnvironmentSpace
        Parameters:
        id - the object's ID
        Returns:
        the object in this space
      • getSpaceObject0

        public ISpaceObject getSpaceObject0​(java.lang.Object id)
        Returns an object in this space.
        Parameters:
        id - the object's ID
        Returns:
        the object in this space
      • getSpaceObjectsByType

        public ISpaceObject[] getSpaceObjectsByType​(java.lang.String type)
        Get all space object of a specific type.
        Specified by:
        getSpaceObjectsByType in interface IEnvironmentSpace
        Parameters:
        type - The space object type.
        Returns:
        The space objects of the desired type.
      • addAvatarMappings

        public void addAvatarMappings​(AvatarMapping mapping)
        Adds an avatar mapping.
        Parameters:
        componenttype - The component type.
        objecttype - The object type to represent the component.
      • removeAvatarMappings

        public void removeAvatarMappings​(AvatarMapping mapping)
        Remove an avatar mapping.
        Parameters:
        componenttype - The component type.
        objecttype - The object type to represent the component.
      • addSpaceAction

        public void addSpaceAction​(java.lang.String id,
                                   ISpaceAction action)
        Adds an space action.
        Specified by:
        addSpaceAction in interface IEnvironmentSpace
        Parameters:
        actionId - the action ID
        action - the action
      • getSpaceAction

        public ISpaceAction getSpaceAction​(java.lang.String id)
        Adds an space action.
        Parameters:
        actionId - the action ID
        action - the action
      • removeSpaceAction

        public void removeSpaceAction​(java.lang.String id)
        Removes an space action.
        Specified by:
        removeSpaceAction in interface IEnvironmentSpace
        Parameters:
        actionId - the action ID
      • performSpaceAction

        public int performSpaceAction​(java.lang.String id,
                                      java.util.Map parameters,
                                      IResultListener listener)
        Schedules an space action.
        Specified by:
        performSpaceAction in interface IEnvironmentSpace
        Parameters:
        id - Id of the action
        parameters - parameters for the action (may be null)
        listener - the result listener
        Returns:
        The id of the action instance for later access.
      • performSpaceAction

        public java.lang.Object performSpaceAction​(java.lang.String id,
                                                   java.util.Map parameters)
        Performs a space action.
        Parameters:
        id - Id of the action
        parameters - parameters for the action (may be null)
        Returns:
        return value of the action
      • createPercept

        public void createPercept​(java.lang.String typename,
                                  java.lang.Object data,
                                  IComponentDescription comp,
                                  ISpaceObject avatar)
        Create a percept for the given component.
        Parameters:
        typename - The percept type.
        data - The content of the percept (if any).
        cid - The component that should receive the percept.
      • getOwner

        public IComponentDescription getOwner​(java.lang.Object id)
        Get the owner of an object.
        Parameters:
        id - The id.
        Returns:
        The owner.
      • getComponents

        public IComponentDescription[] getComponents()
        Get the avatar objects.
        Returns:
        The avatar objects.
      • addDataView

        public void addDataView​(java.lang.String name,
                                IDataView view)
        Adds a view to the space.
        Specified by:
        addDataView in interface IEnvironmentSpace
        Parameters:
        name - name of the view
        view - the view
      • removeDataView

        public void removeDataView​(java.lang.String name)
        Removes a view from the space.
        Specified by:
        removeDataView in interface IEnvironmentSpace
        Parameters:
        name - name of the view
      • getDataView

        public IDataView getDataView​(java.lang.String name)
        Gets a specific view.
        Specified by:
        getDataView in interface IEnvironmentSpace
        Parameters:
        name - name of the view
        Returns:
        the view
      • getDataViews

        public java.util.Map getDataViews()
        Get all available dataviews in this space.
        Specified by:
        getDataViews in interface IEnvironmentSpace
        Returns:
        all available dataviews
      • addDataViewMapping

        public void addDataViewMapping​(java.lang.String objecttype,
                                       java.util.Map view)
        Add a mapping from object type to data view
        Parameters:
        objecttype - The object type.
        view - Settings for view creation.
      • addPerceptGenerator

        public void addPerceptGenerator​(java.lang.Object id,
                                        IPerceptGenerator gen)
        Adds a percept generator.
        Specified by:
        addPerceptGenerator in interface IEnvironmentSpace
        Parameters:
        id - The percept generator id.
        gen - The percept generator.
      • removePerceptGenerator

        public void removePerceptGenerator​(java.lang.Object id)
        Remove a percept generator.
        Specified by:
        removePerceptGenerator in interface IEnvironmentSpace
        Parameters:
        id - The percept generator id.
      • addPerceptProcessor

        public void addPerceptProcessor​(java.lang.String componenttype,
                                        java.util.Set percepttypes,
                                        IPerceptProcessor proc)
        Add a percept processor.
        Parameters:
        componenttype - The component type.
        proc - The percept processor.
      • removePerceptProcessor

        public void removePerceptProcessor​(java.lang.String componenttype,
                                           IPerceptProcessor proc)
        remove a percept processor.
        Parameters:
        componenttype - The component type.
        proc - The percept processor.
      • addPerceptType

        public void addPerceptType​(PerceptType percepttype)
        Add a space percept type.
        Specified by:
        addPerceptType in interface IEnvironmentSpace
        Parameters:
        typename - The percept name.
        objecttypes - The objecttypes.
        componenttypes - The componenttypes.
      • removePerceptType

        public void removePerceptType​(java.lang.String typename)
        Remove a space process type.
        Specified by:
        removePerceptType in interface IEnvironmentSpace
        Parameters:
        typename - The type name.
      • getPerceptType

        public PerceptType getPerceptType​(java.lang.String percepttype)
        Get a space percept type.
        Specified by:
        getPerceptType in interface IEnvironmentSpace
        Parameters:
        percepttype - The name of the percept type.
        Returns:
        The percept type.
      • componentAdded

        public void componentAdded​(IComponentDescription owner)
        Called when an component was added.
      • componentRemoved

        public void componentRemoved​(IComponentDescription desc)
        Called when an component was removed.
      • getFetcher

        public SimpleValueFetcher getFetcher()
        Get the value fetcher.
        Returns:
        The fetcher.
      • setFetcher

        public void setFetcher​(SimpleValueFetcher fetcher)
        Set the fetcher.
        Parameters:
        fetcher - The fetcher to set.
      • getSpaceObjectsCollection

        public java.util.Collection getSpaceObjectsCollection()
        Get the space objects.
      • getProcesses

        public java.util.Collection getProcesses()
        Get the processes.
      • getComponentActionList

        public ComponentActionList getComponentActionList()
        Get the list of scheduled component actions
      • getPerceptList

        public PerceptList getPerceptList()
        Get the list of scheduled percepts.
      • getViews

        public java.util.Collection getViews()
        Get the views.
      • fireEnvironmentEvent

        protected void fireEnvironmentEvent​(EnvironmentEvent event)
        Fire an environment event.
        Parameters:
        event - The event.
      • fireObjectEvent

        protected void fireObjectEvent​(SpaceObject object,
                                       java.lang.String property,
                                       java.lang.Object value)
        Fire an object event.
        Parameters:
        object - The object.
        property - The changed property.
        value - The new property value.
      • addInitialAvatar

        public void addInitialAvatar​(IComponentIdentifier ownerid,
                                     java.lang.String type,
                                     java.util.Map props)
        Initial settings for the avatar of a specific component.
        Parameters:
        ownerid - The component id.
        type - The object type.
        props - The properties for the object (if any).
      • getAvatarMapping

        protected AvatarMapping getAvatarMapping​(java.lang.String componenttype,
                                                 java.lang.String avatartype)
        Get the avatar mapping for an component avatar combination.
      • addDataProvider

        public void addDataProvider​(java.lang.String name,
                                    ITableDataProvider provider)
        Add a new data provider.
        Parameters:
        name - The name.
        provider - The provider.
      • getDataProvider

        public ITableDataProvider getDataProvider​(java.lang.String name)
        Get a data provider.
        Parameters:
        name - The name.
        Returns:
        The provider.
      • addDataConsumer

        public void addDataConsumer​(java.lang.String name,
                                    ITableDataConsumer consumer)
        Add a new data consumer.
        Parameters:
        consumer - The consumer.
      • getDataConsumer

        public ITableDataConsumer getDataConsumer​(java.lang.String name)
        Get a data consumer.
        Parameters:
        name - The name.
        Returns:
        The consumer.
      • getDataConsumers

        public java.util.Collection getDataConsumers()
        Get the data consumers.
        Returns:
        The data consumers.
      • init

        public IFuture<java.lang.Void> init()
        Initialize the extension. Called once, when the extension is created.
        Specified by:
        init in interface jadex.application.IExtensionInstance
      • terminate

        public IFuture<java.lang.Void> terminate()
        Terminate the extension. Called once, when the extension is terminated.
        Specified by:
        terminate in interface jadex.application.IExtensionInstance
      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
        Get the class loader.
      • getSpaceObjectType

        public MObjectType getSpaceObjectType​(java.lang.String type)
        Get the object type.