Package jadex.base
Class Starter
- java.lang.Object
-
- jadex.base.Starter
-
public class Starter extends java.lang.ObjectStarter class for starting the Jadex platform.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDATA_BOOTSTRAPFACTORYThe bootstrap component factory.static java.lang.StringDATA_CMSSTATEThe CMS state.static java.lang.StringDATA_COMPONENTMODELSThe cache of component models found by scanning available resources.static java.lang.StringDATA_DEFAULT_TIMEOUTConstant for default timeout name.static java.lang.StringDATA_INVOKEDMETHODSThe weak set of invoked init, start or shutdown methods - to not invoke twice.static java.lang.StringDATA_KERNELFILTERSstatic java.lang.StringDATA_NETWORKNAMESCACHEThe used to store the current network names.static java.lang.StringDATA_PARAMETERCOPYFlag if copying parameters for local service calls is allowed.static java.lang.StringDATA_PLATFORMACCESSThe bootstrap component factory.static java.lang.StringDATA_PLATFORMSETTINGSThe platform settings.static java.lang.StringDATA_REALTIMETIMEOUTFlag if local timeouts should be realtime (instead of clock dependent).static java.lang.StringDATA_SERIALIZATIONSERVICESThe serialization services for serializing and en/decoding objects including remote reference handling.static java.lang.StringDATA_SERVICEREGISTRYThe local service registry data key.static java.lang.StringDATA_TRANSPORTCACHEThe transport cache used to .protected static IRwMap<IComponentIdentifier,IRwMap<java.lang.String,java.lang.Object>>platformmemGlobal platform data.protected static java.util.Map<IComponentIdentifier,Tuple2<BlockingQueue,java.lang.Thread>>rescuethreadsThe rescue threads - per platform.protected static java.util.Map<java.lang.String,java.lang.Integer>UNIQUENAMESCounters for generating unique names of platforms.
-
Constructor Summary
Constructors Constructor Description Starter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static IFuture<IExternalAccess>createAgent(java.lang.String filename, IComponentFactory cfac, IExecutionService es, IClockService cs)Create an agent based on filename, agent factory and platform services.static IFuture<IExternalAccess>createPlatform()Create the platform.static IFuture<IExternalAccess>createPlatform(IPlatformConfiguration config)Create the platform.static IFuture<IExternalAccess>createPlatform(IPlatformConfiguration pconfig, java.lang.String... args)Create the platform.static IFuture<IExternalAccess>createPlatform(IPlatformConfiguration pconfig, java.util.Map<java.lang.String,java.lang.Object> pargs)Create the platform.static IFuture<IExternalAccess>createPlatform(java.lang.String... args)Create the platform.static IFuture<IExternalAccess>createPlatform(java.util.Map<java.lang.String,java.lang.String> args)Create the platform.static IComponentIdentifiercreatePlatformIdentifier(java.lang.String pfname, boolean unique)Internal method to create a component identifier.static IFuture<IExternalAccess>createProxy(IExternalAccess local, IExternalAccess remote)Create a proxy for the remote platform.static Tuple2<IExecutionService,IClockService>createServices()Create the necessary platform service replacements.static booleangetBooleanValueWithArgs(java.util.Map<java.lang.String,java.lang.Object> args, java.lang.String argname, IPlatformConfiguration conf)Get a boolean value from args (otherwise return default value passed as arg).static IClockServicegetClockService(IInternalAccess ia)Get the clock service.static longgetDefaultTimeout(IComponentIdentifier platform)Get the default timeout.static IExecutionServicegetExecutionService(IInternalAccess ia)Get the execution service.static java.lang.ObjectgetPlatformArgument(IComponentIdentifier cid, java.lang.String arg)Get a platform argument, i.e.static IPlatformSettingsgetPlatformSettings(IComponentIdentifier platform)static java.lang.ObjectgetPlatformValue(IComponentIdentifier platform, java.lang.String key)Get a global platform value.static longgetScaledDefaultTimeout(IComponentIdentifier platform, double scale)Get the scaled default timeout.static booleanhasPlatformValue(IComponentIdentifier platform, java.lang.String key)Get a global platform value.static voidinitRescueThread(IComponentIdentifier cid, IPlatformConfiguration rootconfig)Init the rescue thread for a platform..static booleanisNoPlatformMode(IInternalAccess agent)Test if agent runs in no platform mode.static booleanisParameterCopy(IComponentIdentifier platform)Check if the parameter copy flag is set for a platform.static booleanisRealtimeTimeout(IComponentIdentifier cid, boolean def)Check if the real time / non-real time timeout flag is set for a platform.static booleanisRescueThread(IComponentIdentifier cid)Test if the current thread is the rescue thread of the platform.static voidmain(java.lang.String[] args)Main for starting the platform (with meaningful fallbacks)static voidparseArg(java.lang.String okey, java.lang.String val, java.util.Map<java.lang.String,java.lang.Object> vals)static java.util.Map<java.lang.String,java.lang.Object>parseArgs(java.lang.String args)Create a platform configuration.static java.util.Map<java.lang.String,java.lang.Object>parseArgs(java.lang.String[] args)static voidputPlatformValue(IComponentIdentifier platform, java.lang.String key, java.lang.Object value)Get a global platform value.static voidremovePlatformMemory(IComponentIdentifier platform)Get a global platform value.static voidscheduleRescueStep(IComponentIdentifier cid, java.lang.Runnable run)Schedule a rescue step.static voidsetDefaultTimeout(IComponentIdentifier platform, long timeout)Set the default timeout.static voidshutdownRescueThread(IComponentIdentifier cid)Shutdown the rescue thread of a platform.protected static IFuture<java.lang.Void>startComponents(int i, java.util.List<java.lang.String> components, IInternalAccess instance)Loop for starting components.protected static java.lang.Stringunescape(java.lang.String str)Unescape a string.
-
-
-
Field Detail
-
DATA_PARAMETERCOPY
public static java.lang.String DATA_PARAMETERCOPY
Flag if copying parameters for local service calls is allowed.
-
DATA_REALTIMETIMEOUT
public static java.lang.String DATA_REALTIMETIMEOUT
Flag if local timeouts should be realtime (instead of clock dependent).
-
DATA_SERVICEREGISTRY
public static java.lang.String DATA_SERVICEREGISTRY
The local service registry data key.
-
DATA_SERIALIZATIONSERVICES
public static java.lang.String DATA_SERIALIZATIONSERVICES
The serialization services for serializing and en/decoding objects including remote reference handling.
-
DATA_TRANSPORTCACHE
public static java.lang.String DATA_TRANSPORTCACHE
The transport cache used to .
-
DATA_NETWORKNAMESCACHE
public static java.lang.String DATA_NETWORKNAMESCACHE
The used to store the current network names.
-
DATA_CMSSTATE
public static java.lang.String DATA_CMSSTATE
The CMS state.
-
DATA_DEFAULT_TIMEOUT
public static java.lang.String DATA_DEFAULT_TIMEOUT
Constant for default timeout name.
-
DATA_PLATFORMACCESS
public static java.lang.String DATA_PLATFORMACCESS
The bootstrap component factory.
-
DATA_PLATFORMSETTINGS
public static java.lang.String DATA_PLATFORMSETTINGS
The platform settings.
-
DATA_BOOTSTRAPFACTORY
public static java.lang.String DATA_BOOTSTRAPFACTORY
The bootstrap component factory.
-
DATA_INVOKEDMETHODS
public static java.lang.String DATA_INVOKEDMETHODS
The weak set of invoked init, start or shutdown methods - to not invoke twice.
-
DATA_COMPONENTMODELS
public static java.lang.String DATA_COMPONENTMODELS
The cache of component models found by scanning available resources.
-
DATA_KERNELFILTERS
public static java.lang.String DATA_KERNELFILTERS
-
platformmem
protected static final IRwMap<IComponentIdentifier,IRwMap<java.lang.String,java.lang.Object>> platformmem
Global platform data. For each platform stored by
-
UNIQUENAMES
protected static java.util.Map<java.lang.String,java.lang.Integer> UNIQUENAMES
Counters for generating unique names of platforms.
-
rescuethreads
protected static java.util.Map<IComponentIdentifier,Tuple2<BlockingQueue,java.lang.Thread>> rescuethreads
The rescue threads - per platform.
-
-
Method Detail
-
unescape
protected static java.lang.String unescape(java.lang.String str)
Unescape a string.
-
main
public static void main(java.lang.String[] args)
Main for starting the platform (with meaningful fallbacks)- Parameters:
args- The arguments.- Throws:
java.lang.Exception
-
createPlatform
public static IFuture<IExternalAccess> createPlatform(java.util.Map<java.lang.String,java.lang.String> args)
Create the platform.- Parameters:
args- The command line arguments.- Returns:
- The external access of the root component.
-
createPlatform
public static IFuture<IExternalAccess> createPlatform(java.lang.String... args)
Create the platform.- Parameters:
args- The command line arguments.- Returns:
- The external access of the root component.
-
createPlatform
public static IFuture<IExternalAccess> createPlatform(IPlatformConfiguration config)
Create the platform.- Returns:
- The external access of the root component.
-
createPlatform
public static IFuture<IExternalAccess> createPlatform()
Create the platform.- Returns:
- The external access of the root component.
-
createPlatform
public static IFuture<IExternalAccess> createPlatform(IPlatformConfiguration pconfig, java.lang.String... args)
Create the platform.- Parameters:
config- The PlatformConfiguration object.- Returns:
- The external access of the root component.
-
getBooleanValueWithArgs
public static boolean getBooleanValueWithArgs(java.util.Map<java.lang.String,java.lang.Object> args, java.lang.String argname, IPlatformConfiguration conf)Get a boolean value from args (otherwise return default value passed as arg). Any non-boolean, non-null value (e.g. a string) is also considered 'true'.- Parameters:
args- The args map.argname- The argument name.conf- The platform config.- Returns:
- The arg value.
-
createPlatform
public static IFuture<IExternalAccess> createPlatform(IPlatformConfiguration pconfig, java.util.Map<java.lang.String,java.lang.Object> pargs)
Create the platform.- Parameters:
config- The PlatformConfiguration object.- Returns:
- The external access of the root component.
-
createPlatformIdentifier
public static IComponentIdentifier createPlatformIdentifier(java.lang.String pfname, boolean unique)
Internal method to create a component identifier.- Parameters:
pfname- The platform name.unique- When true, keeps track of already created names and creates a name that is unique in this VM.
-
startComponents
protected static IFuture<java.lang.Void> startComponents(int i, java.util.List<java.lang.String> components, IInternalAccess instance)
Loop for starting components.- Parameters:
i- Number to start.components- The list of components.instance- The instance.- Returns:
- True, when done.
-
initRescueThread
public static void initRescueThread(IComponentIdentifier cid, IPlatformConfiguration rootconfig)
Init the rescue thread for a platform..
-
scheduleRescueStep
public static void scheduleRescueStep(IComponentIdentifier cid, java.lang.Runnable run)
Schedule a rescue step.- Parameters:
cid- The id of a component of the platform.run- The runnable to execute.
-
isRescueThread
public static boolean isRescueThread(IComponentIdentifier cid)
Test if the current thread is the rescue thread of the platform.- Parameters:
cid- The id of a component of the platform.- Returns:
- True, if is the rescue thread.
-
shutdownRescueThread
public static void shutdownRescueThread(IComponentIdentifier cid)
Shutdown the rescue thread of a platform.
-
createProxy
public static IFuture<IExternalAccess> createProxy(IExternalAccess local, IExternalAccess remote)
Create a proxy for the remote platform.
-
getPlatformValue
public static java.lang.Object getPlatformValue(IComponentIdentifier platform, java.lang.String key)
Get a global platform value.- Parameters:
platform- The platform name.key- The key.- Returns:
- The value.
-
getPlatformArgument
public static java.lang.Object getPlatformArgument(IComponentIdentifier cid, java.lang.String arg)
Get a platform argument, i.e. global Jadex setting value as defined by arguments of jadex.platform.PlatformAgent.- Parameters:
platform- An id of any component on the platform.arg- The argument name.- Returns:
- The value.
-
putPlatformValue
public static void putPlatformValue(IComponentIdentifier platform, java.lang.String key, java.lang.Object value)
Get a global platform value.- Parameters:
platform- The platform name.key- The key.value- The value.
-
hasPlatformValue
public static boolean hasPlatformValue(IComponentIdentifier platform, java.lang.String key)
Get a global platform value.- Parameters:
platform- The platform name.key- The key.- Returns:
- The value.
-
removePlatformMemory
public static void removePlatformMemory(IComponentIdentifier platform)
Get a global platform value.- Parameters:
platform- The platform name.
-
getPlatformSettings
public static final IPlatformSettings getPlatformSettings(IComponentIdentifier platform)
-
getDefaultTimeout
public static long getDefaultTimeout(IComponentIdentifier platform)
Get the default timeout.
-
getScaledDefaultTimeout
public static long getScaledDefaultTimeout(IComponentIdentifier platform, double scale)
Get the scaled default timeout.
-
setDefaultTimeout
public static void setDefaultTimeout(IComponentIdentifier platform, long timeout)
Set the default timeout.
-
isRealtimeTimeout
public static boolean isRealtimeTimeout(IComponentIdentifier cid, boolean def)
Check if the real time / non-real time timeout flag is set for a platform. By default some timeouts are real time (e.g. network communication) and others are clock dependent (e.g. agent.waitFor...). The "realtimetimeout" platform setting (default=null) allows forcing all timeouts to real time (true) or clock dependent (false).- Parameters:
cid- Use platform setting of the given component.def- The default value to be returned when flag is null in platform config.
-
isParameterCopy
public static boolean isParameterCopy(IComponentIdentifier platform)
Check if the parameter copy flag is set for a platform.
-
parseArgs
public static java.util.Map<java.lang.String,java.lang.Object> parseArgs(java.lang.String args)
Create a platform configuration.- Parameters:
args- The command line arguments.- Returns:
- StarterConfiguration
-
parseArgs
public static java.util.Map<java.lang.String,java.lang.Object> parseArgs(java.lang.String[] args)
- Parameters:
args-config-
-
parseArg
public static void parseArg(java.lang.String okey, java.lang.String val, java.util.Map<java.lang.String,java.lang.Object> vals)- Parameters:
okey-val-config-
-
createAgent
public static IFuture<IExternalAccess> createAgent(java.lang.String filename, IComponentFactory cfac, IExecutionService es, IClockService cs)
Create an agent based on filename, agent factory and platform services.- Parameters:
filename- The model filename.es- The execution service.cs- The clock service.- Returns:
- External access of the created agent.
-
isNoPlatformMode
public static boolean isNoPlatformMode(IInternalAccess agent)
Test if agent runs in no platform mode.- Parameters:
agent- The agent.- Returns:
- True, if runs in no platform mode.
-
getClockService
public static IClockService getClockService(IInternalAccess ia)
Get the clock service.- Returns:
- The clock service.
-
getExecutionService
public static IExecutionService getExecutionService(IInternalAccess ia)
Get the execution service.- Returns:
- The execution service.
-
createServices
public static Tuple2<IExecutionService,IClockService> createServices()
Create the necessary platform service replacements.- Returns:
- The services (execution and clock).
-
-