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 class
BDIXAgentFeature.ChangeInfoEntryMapper
Map a change info as Map:Entry.static class
BDIXAgentFeature.GoalsExistCondition
Condition that tests if goal instances of an mgoal exist.static class
BDIXAgentFeature.LifecycleStateCondition
Condition for checking the lifecycle state of a goal.static class
BDIXAgentFeature.PlansExistCondition
Condition that tests if goal instances of an mplan exist.
-
Field Summary
Fields Modifier and Type Field Description protected IBDIModel
bdimodel
The bdi model.protected jadex.bdiv3.runtime.impl.RCapability
capa
The bdi state.static IComponentFeatureFactory
FACTORY
protected RuleSystem
rulesystem
The 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.Object
adaptToCapability(java.lang.Object obj, java.lang.String capa, IBDIModel bdimodel)
Adapt element for use in inner capabilities.static void
addBeliefEvents(IInternalAccess ia, java.util.List<EventType> events, java.lang.String belname)
Create belief events from a belief name.void
addBeliefListener(java.lang.String name, IBeliefListener listener)
Add a belief listener.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.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.static EventType
createEventType(RawEvent rawev)
protected void
doCleanup()
Cleanup the beliefs in kill and shutdown.IModelInfo
getAgentModel()
Get the agent model.java.lang.String
getAgentName()
Get the agent name.static IBDIXAgentFeature
getBDIAgentFeature(IInternalAccess agent)
Get the feature from the agent.IBDIModel
getBDIModel()
Get the bdimodel.IBeliefbase
getBeliefbase()
Get the belief base.protected static java.lang.String
getBeliefName(java.lang.Object obj, java.lang.String fieldname)
jadex.bdiv3.runtime.impl.RCapability
getCapability()
Get the state.java.lang.ClassLoader
getClassLoader()
Get the classloader.IComponentDescription
getComponentDescription()
Get the component description.IComponentIdentifier
getComponentIdentifier()
Get the agent identifier.java.lang.String
getConfigurationName()
Get the configuration name.java.util.List<IMonitoringEvent>
getCurrentStateEvents()
Get the current state as events.java.util.Map<EventType,IResultCommand<IFuture<java.lang.Void>,PropertyChangeEvent>>
getEventAdders()
Get the event type.IEventbase
getEventbase()
Get the event base.IExpressionbase
getExpressionbase()
Get the expression base.IExternalAccess
getExternalAccess()
Get the scope.IGoalbase
getGoalbase()
Get the goal base.static java.util.List<EventType>
getGoalEvents(MGoal mgoal)
Create goal events for a goal name. creates goaladopted, goaldropped goaloption, goalactive, goalsuspended goalinprocess, goalnotinprocess events.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.Logger
getLogger()
Get the logger.IModelInfo
getModel()
Get the capability model.IPlanbase
getPlanbase()
Get the plan base.RuleSystem
getRuleSystem()
Get the rulesystem.long
getTime()
Get the current time.IValueFetcher
getValueFetcher()
Get the value fetcher.boolean
hasUserBody()
Check if the feature potentially executed user code in body.IFuture<java.lang.Void>
init()
Initialize the feature.protected boolean
isComponentThread()
void
kill()
Called on init failure.IFuture<java.util.Map<java.lang.String,java.lang.Object>>
killAgent()
Kill the agent.static void
publishToolBeliefEvent(IInternalAccess ia, MBelief mbel)
static java.util.List<EventType>
readAnnotationEvents(IInternalAccess ia, java.lang.annotation.Annotation[][] annos)
Read the annotation events from method annotations.void
removeBeliefListener(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 void
testBodyAborted(jadex.bdiv3.runtime.impl.RPlan rplan)
Check if plan is already aborted.protected void
wrapCollections(MCapability mcapa, java.lang.Object agent)
-
-
-
Field Detail
-
FACTORY
public static final IComponentFeatureFactory FACTORY
-
bdimodel
protected IBDIModel bdimodel
The bdi model.
-
rulesystem
protected 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:
init
in interfaceIComponentFeature
- Overrides:
init
in 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:
hasUserBody
in interfaceIComponentFeature
- Overrides:
hasUserBody
in classjadex.bridge.component.impl.AbstractComponentFeature
-
shutdown
public IFuture<java.lang.Void> shutdown()
Called on shutdown after successful init.- Specified by:
shutdown
in interfaceIComponentFeature
- Overrides:
shutdown
in classjadex.bridge.component.impl.AbstractComponentFeature
-
kill
public void kill()
Called on init failure.- Specified by:
kill
in interfaceIComponentFeature
- Overrides:
kill
in 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:
addBeliefListener
in 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:
removeBeliefListener
in 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 RuleSystem getRuleSystem()
Get the rulesystem.- Specified by:
getRuleSystem
in interfacejadex.bdiv3.features.impl.IInternalBDIAgentFeature
- Returns:
- The rulesystem.
-
getBDIModel
public IBDIModel getBDIModel()
Get the bdimodel.- Specified by:
getBDIModel
in interfacejadex.bdiv3.features.impl.IInternalBDIAgentFeature
- Returns:
- the bdimodel.
-
getCapability
public jadex.bdiv3.runtime.impl.RCapability getCapability()
Get the state.- Specified by:
getCapability
in interfacejadex.bdiv3.features.impl.IInternalBDIAgentFeature
- Returns:
- the state.
-
addBeliefEvents
public static void addBeliefEvents(IInternalAccess ia, java.util.List<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<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<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.
-
getBDIAgentFeature
public static IBDIXAgentFeature getBDIAgentFeature(IInternalAccess agent)
Get the feature from the agent.
-
getValueFetcher
public IValueFetcher getValueFetcher()
Get the value fetcher.- Specified by:
getValueFetcher
in interfaceIComponentFeature
- Overrides:
getValueFetcher
in classjadex.bridge.component.impl.AbstractComponentFeature
-
getEventAdders
public java.util.Map<EventType,IResultCommand<IFuture<java.lang.Void>,PropertyChangeEvent>> getEventAdders()
Get the event type.- Specified by:
getEventAdders
in 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:
getExternalAccess
in interfaceICapability
- Returns:
- The scope.
-
getBeliefbase
public IBeliefbase getBeliefbase()
Get the belief base.- Specified by:
getBeliefbase
in interfaceICapability
- Returns:
- The belief base.
-
getEventbase
public IEventbase getEventbase()
Get the event base.- Specified by:
getEventbase
in interfaceICapability
- Returns:
- The event base.
-
getGoalbase
public IGoalbase getGoalbase()
Get the goal base.- Specified by:
getGoalbase
in interfaceICapability
- Returns:
- The goal base.
-
getPlanbase
public IPlanbase getPlanbase()
Get the plan base.- Specified by:
getPlanbase
in interfaceICapability
- Returns:
- The plan base.
-
getExpressionbase
public IExpressionbase getExpressionbase()
Get the expression base.- Specified by:
getExpressionbase
in interfaceICapability
- Returns:
- The expression base.
-
getLogger
public java.util.logging.Logger getLogger()
Get the logger.- Specified by:
getLogger
in interfaceICapability
- Returns:
- The logger.
-
getAgentModel
public IModelInfo getAgentModel()
Get the agent model.- Specified by:
getAgentModel
in interfaceICapability
- Returns:
- The agent model.
-
getModel
public IModelInfo getModel()
Get the capability model.- Specified by:
getModel
in interfaceICapability
- Returns:
- The capability model.
-
getAgentName
public java.lang.String getAgentName()
Get the agent name.- Specified by:
getAgentName
in interfaceICapability
- Returns:
- The agent name.
-
getConfigurationName
public java.lang.String getConfigurationName()
Get the configuration name.- Specified by:
getConfigurationName
in interfaceICapability
- Returns:
- The configuration name.
-
getComponentIdentifier
public IComponentIdentifier getComponentIdentifier()
Get the agent identifier.- Specified by:
getComponentIdentifier
in interfaceICapability
- Returns:
- The agent identifier.
-
getComponentDescription
public IComponentDescription getComponentDescription()
Get the component description.- Specified by:
getComponentDescription
in 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:
getTime
in interfaceICapability
- Returns:
- The current time.
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Get the classloader.- Specified by:
getClassLoader
in interfaceICapability
- Returns:
- The classloader.
-
killAgent
public IFuture<java.util.Map<java.lang.String,java.lang.Object>> killAgent()
Kill the agent.- Specified by:
killAgent
in interfaceICapability
-
subscribeToEvents
public ISubscriptionIntermediateFuture<IMonitoringEvent> subscribeToEvents(IFilter<IMonitoringEvent> filter, boolean initial, IMonitoringService.PublishEventLevel elm)
Subscribe to monitoring events.- Specified by:
subscribeToEvents
in interfaceICapability
- Parameters:
filter
- An optional filter.
-
-