Class BDIXAgentFeature

  • All Implemented Interfaces:
    jadex.bdiv3.features.impl.IInternalBDIAgentFeature, IBDIXAgentFeature, ICapability, IComponentFeature

    public class BDIXAgentFeature
    extends jadex.bridge.component.impl.AbstractComponentFeature
    implements IBDIXAgentFeature, jadex.bdiv3.features.impl.IInternalBDIAgentFeature
    BDI agent feature version for XML agents.
    • Field Detail

      • bdimodel

        protected IBDIModel bdimodel
        The bdi model.
      • rulesystem

        protected jadex.rules.eca.RuleSystem rulesystem
        The rule system.
      • capa

        protected jadex.bdiv3.runtime.impl.RCapability capa
        The bdi state.
    • Method Detail

      • init

        public IFuture<java.lang.Void> init()
        Initialize the feature.
        Specified by:
        init in interface IComponentFeature
        Overrides:
        init in class jadex.bridge.component.impl.AbstractComponentFeature
      • hasUserBody

        public boolean hasUserBody()
        Check if the feature potentially executed user code in body. Allows blocking operations in user bodies by using separate steps for each feature. Non-user-body-features are directly executed for speed. If unsure just return true. ;-)
        Specified by:
        hasUserBody in interface IComponentFeature
        Overrides:
        hasUserBody in class jadex.bridge.component.impl.AbstractComponentFeature
      • shutdown

        public IFuture<java.lang.Void> shutdown()
        Called on shutdown after successful init.
        Specified by:
        shutdown in interface IComponentFeature
        Overrides:
        shutdown in class jadex.bridge.component.impl.AbstractComponentFeature
      • kill

        public void kill()
        Called on init failure.
        Specified by:
        kill in interface IComponentFeature
        Overrides:
        kill in class jadex.bridge.component.impl.AbstractComponentFeature
      • doCleanup

        protected void doCleanup()
        Cleanup the beliefs in kill and shutdown.
      • addInitArgs

        public static void addInitArgs​(java.lang.Object obj,
                                       java.lang.Class<?> clazz,
                                       java.lang.Class<?>[] argtypes,
                                       java.lang.Object[] args)
        Add an entry to the init calls.
        Parameters:
        obj - object instance that owns the field __initargs
        clazz - Class definition of the obj object
        argtypes - Signature of the init method
        args - Actual argument values for the init method
      • createChangeEvent

        public static void createChangeEvent​(java.lang.Object val,
                                             java.lang.Object oldval,
                                             java.lang.Object info,
                                             IInternalAccess agent,
                                             java.lang.String belname)
        Caution: this method is used from byte engineered code, change signature with caution Create a belief changed event.
        Parameters:
        val - The new value.
        agent - The agent.
        belname - The belief name.
      • getBeliefName

        protected static java.lang.String getBeliefName​(java.lang.Object obj,
                                                        java.lang.String fieldname)
      • isComponentThread

        protected boolean isComponentThread()
      • adaptToCapability

        protected static java.lang.Object adaptToCapability​(java.lang.Object obj,
                                                            java.lang.String capa,
                                                            IBDIModel bdimodel)
        Adapt element for use in inner capabilities.
        Parameters:
        obj - The object to adapt (e.g. a change event)
        capa - The capability name or null for agent.
      • wrapCollections

        protected void wrapCollections​(MCapability mcapa,
                                       java.lang.Object agent)
      • addBeliefListener

        public void addBeliefListener​(java.lang.String name,
                                      IBeliefListener listener)
        Add a belief listener.
        Specified by:
        addBeliefListener in interface jadex.bdiv3.features.impl.IInternalBDIAgentFeature
        Parameters:
        name - The belief name.
        listener - The belief listener.
      • removeBeliefListener

        public void removeBeliefListener​(java.lang.String name,
                                         IBeliefListener listener)
        Remove a belief listener.
        Specified by:
        removeBeliefListener in interface jadex.bdiv3.features.impl.IInternalBDIAgentFeature
        Parameters:
        name - The belief name.
        listener - The belief listener.
      • testBodyAborted

        protected void testBodyAborted​(jadex.bdiv3.runtime.impl.RPlan rplan)
        Check if plan is already aborted.
      • getInjectionValues

        public static java.lang.Object[] getInjectionValues​(java.lang.Class<?>[] ptypes,
                                                            java.lang.annotation.Annotation[][] anns,
                                                            MElement melement,
                                                            ChangeEvent event,
                                                            jadex.bdiv3.runtime.impl.RPlan rplan,
                                                            jadex.bdiv3.runtime.impl.RProcessableElement rpe,
                                                            IInternalAccess component)
        Get parameter values for injection into method and constructor calls.
      • getInjectionValues

        public static java.lang.Object[] getInjectionValues​(java.lang.Class<?>[] ptypes,
                                                            java.lang.annotation.Annotation[][] anns,
                                                            MElement melement,
                                                            ChangeEvent event,
                                                            jadex.bdiv3.runtime.impl.RPlan rplan,
                                                            jadex.bdiv3.runtime.impl.RProcessableElement rpe,
                                                            java.util.Collection<java.lang.Object> vs,
                                                            IInternalAccess component)
        Get parameter values for injection into method and constructor calls.
        Returns:
        A valid assigment or null if no assignment could be found.
      • getRuleSystem

        public jadex.rules.eca.RuleSystem getRuleSystem()
        Get the rulesystem.
        Specified by:
        getRuleSystem in interface jadex.bdiv3.features.impl.IInternalBDIAgentFeature
        Returns:
        The rulesystem.
      • getBDIModel

        public IBDIModel getBDIModel()
        Get the bdimodel.
        Specified by:
        getBDIModel in interface jadex.bdiv3.features.impl.IInternalBDIAgentFeature
        Returns:
        the bdimodel.
      • getCapability

        public jadex.bdiv3.runtime.impl.RCapability getCapability()
        Get the state.
        Specified by:
        getCapability in interface jadex.bdiv3.features.impl.IInternalBDIAgentFeature
        Returns:
        the state.
      • addBeliefEvents

        public static void addBeliefEvents​(IInternalAccess ia,
                                           java.util.List<jadex.rules.eca.EventType> events,
                                           java.lang.String belname)
        Create belief events from a belief name. For normal beliefs beliefchanged.belname and factchanged.belname and for multi beliefs additionally factadded.belname and factremoved are created.
      • getGoalEvents

        public static java.util.List<jadex.rules.eca.EventType> getGoalEvents​(MGoal mgoal)
        Create goal events for a goal name. creates goaladopted, goaldropped goaloption, goalactive, goalsuspended goalinprocess, goalnotinprocess events.
      • readAnnotationEvents

        public static java.util.List<jadex.rules.eca.EventType> readAnnotationEvents​(IInternalAccess ia,
                                                                                     java.lang.annotation.Annotation[][] annos)
        Read the annotation events from method annotations.
      • getCurrentStateEvents

        public java.util.List<IMonitoringEvent> getCurrentStateEvents()
        Get the current state as events.
      • createEventType

        public static jadex.rules.eca.EventType createEventType​(RawEvent rawev)
      • getValueFetcher

        public IValueFetcher getValueFetcher()
        Get the value fetcher.
        Specified by:
        getValueFetcher in interface IComponentFeature
        Overrides:
        getValueFetcher in class jadex.bridge.component.impl.AbstractComponentFeature
      • getEventAdders

        public java.util.Map<jadex.rules.eca.EventType,​IResultCommand<IFuture<java.lang.Void>,​PropertyChangeEvent>> getEventAdders()
        Get the event type.
        Specified by:
        getEventAdders in interface jadex.bdiv3.features.impl.IInternalBDIAgentFeature
        Returns:
        The event adder.
      • getExternalAccess

        public IExternalAccess getExternalAccess()
        Get the scope. Method with IExternalAccess return value included for compatibility with IInternalAccess.
        Specified by:
        getExternalAccess in interface ICapability
        Returns:
        The scope.
      • getLogger

        public java.util.logging.Logger getLogger()
        Get the logger.
        Specified by:
        getLogger in interface ICapability
        Returns:
        The logger.
      • getModel

        public IModelInfo getModel()
        Get the capability model.
        Specified by:
        getModel in interface ICapability
        Returns:
        The capability model.
      • getAgentName

        public java.lang.String getAgentName()
        Get the agent name.
        Specified by:
        getAgentName in interface ICapability
        Returns:
        The agent name.
      • getConfigurationName

        public java.lang.String getConfigurationName()
        Get the configuration name.
        Specified by:
        getConfigurationName in interface ICapability
        Returns:
        The configuration name.
      • getTime

        public long getTime()
        Get the current time. The time unit depends on the currently running clock implementation. For the default system clock, the time value adheres to the time representation as used by System.currentTimeMillis(), i.e., the value of milliseconds passed since 0:00 'o clock, January 1st, 1970, UTC. For custom simulation clocks, arbitrary representations can be used.
        Specified by:
        getTime in interface ICapability
        Returns:
        The current time.
      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
        Get the classloader.
        Specified by:
        getClassLoader in interface ICapability
        Returns:
        The classloader.
      • killAgent

        public IFuture<java.util.Map<java.lang.String,​java.lang.Object>> killAgent()
        Kill the agent.
        Specified by:
        killAgent in interface ICapability