Package jadex.bdiv3x.features
Class BDIXAgentFeature
- java.lang.Object
-
- jadex.bridge.component.impl.AbstractComponentFeature
-
- jadex.bdiv3x.features.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBDIXAgentFeature.ChangeInfoEntryMapperMap a change info as Map:Entry.static classBDIXAgentFeature.GoalsExistConditionCondition that tests if goal instances of an mgoal exist.static classBDIXAgentFeature.LifecycleStateConditionCondition for checking the lifecycle state of a goal.static classBDIXAgentFeature.PlansExistConditionCondition that tests if goal instances of an mplan exist.
-
Field Summary
Fields Modifier and Type Field Description protected IBDIModelbdimodelThe bdi model.protected jadex.bdiv3.runtime.impl.RCapabilitycapaThe bdi state.static IComponentFeatureFactoryFACTORYprotected jadex.rules.eca.RuleSystemrulesystemThe rule system.
-
Constructor Summary
Constructors Constructor Description BDIXAgentFeature(IInternalAccess component, ComponentCreationInfo cinfo)Factory method constructor for instance level.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.lang.ObjectadaptToCapability(java.lang.Object obj, java.lang.String capa, IBDIModel bdimodel)Adapt element for use in inner capabilities.static voidaddBeliefEvents(IInternalAccess ia, java.util.List<jadex.rules.eca.EventType> events, java.lang.String belname)Create belief events from a belief name.voidaddBeliefListener(java.lang.String name, IBeliefListener listener)Add a belief listener.static voidaddInitArgs(java.lang.Object obj, java.lang.Class<?> clazz, java.lang.Class<?>[] argtypes, java.lang.Object[] args)Add an entry to the init calls.static voidcreateChangeEvent(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.static jadex.rules.eca.EventTypecreateEventType(RawEvent rawev)protected voiddoCleanup()Cleanup the beliefs in kill and shutdown.IModelInfogetAgentModel()Get the agent model.java.lang.StringgetAgentName()Get the agent name.static IBDIXAgentFeaturegetBDIAgentFeature(IInternalAccess agent)Get the feature from the agent.IBDIModelgetBDIModel()Get the bdimodel.IBeliefbasegetBeliefbase()Get the belief base.protected static java.lang.StringgetBeliefName(java.lang.Object obj, java.lang.String fieldname)jadex.bdiv3.runtime.impl.RCapabilitygetCapability()Get the state.java.lang.ClassLoadergetClassLoader()Get the classloader.IComponentDescriptiongetComponentDescription()Get the component description.IComponentIdentifiergetComponentIdentifier()Get the agent identifier.java.lang.StringgetConfigurationName()Get the configuration name.java.util.List<IMonitoringEvent>getCurrentStateEvents()Get the current state as events.java.util.Map<jadex.rules.eca.EventType,IResultCommand<IFuture<java.lang.Void>,PropertyChangeEvent>>getEventAdders()Get the event type.IEventbasegetEventbase()Get the event base.IExpressionbasegetExpressionbase()Get the expression base.IExternalAccessgetExternalAccess()Get the scope.IGoalbasegetGoalbase()Get the goal base.static java.util.List<jadex.rules.eca.EventType>getGoalEvents(MGoal mgoal)Create goal events for a goal name.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.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.java.util.logging.LoggergetLogger()Get the logger.IModelInfogetModel()Get the capability model.IPlanbasegetPlanbase()Get the plan base.jadex.rules.eca.RuleSystemgetRuleSystem()Get the rulesystem.longgetTime()Get the current time.IValueFetchergetValueFetcher()Get the value fetcher.booleanhasUserBody()Check if the feature potentially executed user code in body.IFuture<java.lang.Void>init()Initialize the feature.protected booleanisComponentThread()voidkill()Called on init failure.IFuture<java.util.Map<java.lang.String,java.lang.Object>>killAgent()Kill the agent.static voidpublishToolBeliefEvent(IInternalAccess ia, MBelief mbel)static java.util.List<jadex.rules.eca.EventType>readAnnotationEvents(IInternalAccess ia, java.lang.annotation.Annotation[][] annos)Read the annotation events from method annotations.voidremoveBeliefListener(java.lang.String name, IBeliefListener listener)Remove a belief listener.IFuture<java.lang.Void>shutdown()Called on shutdown after successful init.ISubscriptionIntermediateFuture<IMonitoringEvent>subscribeToEvents(IFilter<IMonitoringEvent> filter, boolean initial, IMonitoringService.PublishEventLevel elm)Subscribe to monitoring events.protected voidtestBodyAborted(jadex.bdiv3.runtime.impl.RPlan rplan)Check if plan is already aborted.protected voidwrapCollections(MCapability mcapa, java.lang.Object agent)
-
-
-
Field Detail
-
FACTORY
public static final IComponentFeatureFactory FACTORY
-
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.
-
-
Constructor Detail
-
BDIXAgentFeature
public BDIXAgentFeature(IInternalAccess component, ComponentCreationInfo cinfo)
Factory method constructor for instance level.
-
-
Method Detail
-
init
public IFuture<java.lang.Void> init()
Initialize the feature.- Specified by:
initin interfaceIComponentFeature- Overrides:
initin classjadex.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:
hasUserBodyin interfaceIComponentFeature- Overrides:
hasUserBodyin classjadex.bridge.component.impl.AbstractComponentFeature
-
shutdown
public IFuture<java.lang.Void> shutdown()
Called on shutdown after successful init.- Specified by:
shutdownin interfaceIComponentFeature- Overrides:
shutdownin classjadex.bridge.component.impl.AbstractComponentFeature
-
kill
public void kill()
Called on init failure.- Specified by:
killin interfaceIComponentFeature- Overrides:
killin classjadex.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 __initargsclazz- Class definition of the obj objectargtypes- Signature of the init methodargs- 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.
-
publishToolBeliefEvent
public static void publishToolBeliefEvent(IInternalAccess ia, MBelief mbel)
-
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:
addBeliefListenerin interfacejadex.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:
removeBeliefListenerin interfacejadex.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:
getRuleSystemin interfacejadex.bdiv3.features.impl.IInternalBDIAgentFeature- Returns:
- The rulesystem.
-
getBDIModel
public IBDIModel getBDIModel()
Get the bdimodel.- Specified by:
getBDIModelin interfacejadex.bdiv3.features.impl.IInternalBDIAgentFeature- Returns:
- the bdimodel.
-
getCapability
public jadex.bdiv3.runtime.impl.RCapability getCapability()
Get the state.- Specified by:
getCapabilityin interfacejadex.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)
-
getBDIAgentFeature
public static IBDIXAgentFeature getBDIAgentFeature(IInternalAccess agent)
Get the feature from the agent.
-
getValueFetcher
public IValueFetcher getValueFetcher()
Get the value fetcher.- Specified by:
getValueFetcherin interfaceIComponentFeature- Overrides:
getValueFetcherin classjadex.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:
getEventAddersin interfacejadex.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:
getExternalAccessin interfaceICapability- Returns:
- The scope.
-
getBeliefbase
public IBeliefbase getBeliefbase()
Get the belief base.- Specified by:
getBeliefbasein interfaceICapability- Returns:
- The belief base.
-
getEventbase
public IEventbase getEventbase()
Get the event base.- Specified by:
getEventbasein interfaceICapability- Returns:
- The event base.
-
getGoalbase
public IGoalbase getGoalbase()
Get the goal base.- Specified by:
getGoalbasein interfaceICapability- Returns:
- The goal base.
-
getPlanbase
public IPlanbase getPlanbase()
Get the plan base.- Specified by:
getPlanbasein interfaceICapability- Returns:
- The plan base.
-
getExpressionbase
public IExpressionbase getExpressionbase()
Get the expression base.- Specified by:
getExpressionbasein interfaceICapability- Returns:
- The expression base.
-
getLogger
public java.util.logging.Logger getLogger()
Get the logger.- Specified by:
getLoggerin interfaceICapability- Returns:
- The logger.
-
getAgentModel
public IModelInfo getAgentModel()
Get the agent model.- Specified by:
getAgentModelin interfaceICapability- Returns:
- The agent model.
-
getModel
public IModelInfo getModel()
Get the capability model.- Specified by:
getModelin interfaceICapability- Returns:
- The capability model.
-
getAgentName
public java.lang.String getAgentName()
Get the agent name.- Specified by:
getAgentNamein interfaceICapability- Returns:
- The agent name.
-
getConfigurationName
public java.lang.String getConfigurationName()
Get the configuration name.- Specified by:
getConfigurationNamein interfaceICapability- Returns:
- The configuration name.
-
getComponentIdentifier
public IComponentIdentifier getComponentIdentifier()
Get the agent identifier.- Specified by:
getComponentIdentifierin interfaceICapability- Returns:
- The agent identifier.
-
getComponentDescription
public IComponentDescription getComponentDescription()
Get the component description.- Specified by:
getComponentDescriptionin interfaceICapability- Returns:
- The component description.
-
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 bySystem.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:
getTimein interfaceICapability- Returns:
- The current time.
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Get the classloader.- Specified by:
getClassLoaderin interfaceICapability- Returns:
- The classloader.
-
killAgent
public IFuture<java.util.Map<java.lang.String,java.lang.Object>> killAgent()
Kill the agent.- Specified by:
killAgentin interfaceICapability
-
subscribeToEvents
public ISubscriptionIntermediateFuture<IMonitoringEvent> subscribeToEvents(IFilter<IMonitoringEvent> filter, boolean initial, IMonitoringService.PublishEventLevel elm)
Subscribe to monitoring events.- Specified by:
subscribeToEventsin interfaceICapability- Parameters:
filter- An optional filter.
-
-