Package jadex.micro
Class KernelMultiAgent
- java.lang.Object
-
- jadex.micro.KernelMultiAgent
-
- All Implemented Interfaces:
IComponentFactory
,IMultiKernelNotifierService
public class KernelMultiAgent extends java.lang.Object implements IComponentFactory, IMultiKernelNotifierService
Multi kernel.
-
-
Field Summary
Fields Modifier and Type Field Description protected IInternalAccess
agent
The internal access.protected static IFilter<SClassReader.ClassInfo>
cfilter
Filter for scanning for kernel agent class infos.protected int
cnt
Test if a model can be loaded by the factory.protected java.util.Set<java.lang.String>
componenttypes
Currently supported types (loadable suffixes)protected boolean
dirty
The dirty flag (when classpath changes).protected static FileFilter
ffilter
Filter for scanning for kernel agent class files.protected CallSequentializer<IComponentFactory>
getnewfac
The sequentializer to execute getNewFactory() one by one and not interleaved.protected java.util.Map<java.lang.String,byte[]>
iconcache
Cache of component iconsprotected boolean
inited
The started flag (because init is invoked twice, service impl for 2 services.protected static java.lang.String
KERNEL_EXTENSIONS
Kernel model property for extensionsprotected static java.lang.String
KERNEL_FILTER
protected java.util.Map<java.lang.String,java.util.Collection<Tuple2<java.lang.String,java.util.Set<java.lang.String>>>>
kernelfiles
The scanned kernel files (suffix -> {(classname, suffixes)} ).protected java.util.Map<java.lang.String,java.lang.Object>
kernels
The started factories (kernel classname -> kernel component).protected java.util.Set<java.lang.String>
known_kernels
The known factories.protected MultiCollection<java.lang.String,Tuple2<java.lang.String,java.util.Set<java.lang.String>>>
known_kernels_cache
protected ILibraryService
libservice
protected java.util.List<IMultiKernelListener>
listeners
The listeners.static java.lang.String
MULTIFACTORY
static java.util.Map<java.lang.String,java.lang.Object>
props
Used in SComponentFactory to reorder checks (multi last).protected IServiceIdentifier
sid
The service identifier.
-
Constructor Summary
Constructors Constructor Description KernelMultiAgent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IFuture<java.lang.Void>
addKernelListener(IMultiKernelListener listener)
Adds a kernel listener.protected IFuture<IComponentFactory>
check(java.util.Iterator<Tuple2<java.lang.String,java.util.Set<java.lang.String>>> it, java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
Check a factoryprotected IFuture<IComponentFactory>
doStartKernel(java.lang.String model)
void
fireTypesAdded(java.lang.String[] types)
Fires a types added event.void
fireTypesRemoved(java.lang.String[] types)
Fires a types removed event.IFuture<java.util.Collection<IComponentFeatureFactory>>
getComponentFeatures(IModelInfo model)
Get the component features for a model.IFuture<java.lang.String>
getComponentType(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
Get the component type of a model.IFuture<byte[]>
getComponentTypeIcon(java.lang.String type)
Get a default icon for a component type.java.lang.String[]
getComponentTypes()
Get the names of component types supported by this factory.protected java.util.Collection<IComponentFactory>
getFactories()
Get all subfactories except the multi itself.protected IFuture<IComponentFactory>
getFactoryForModel(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
Get a factory for a model.protected java.util.Map<java.lang.String,java.util.Collection<Tuple2<java.lang.String,java.util.Set<java.lang.String>>>>
getKernelFiles()
Get all kernel files, i.e.protected java.lang.String[]
getKernelTypes(SClassReader.ClassInfo ci)
Add infos about a kernel to the map.protected java.util.Map<java.lang.String,java.util.Collection<Tuple2<java.lang.String,java.util.Set<java.lang.String>>>>
getKnownKernels()
Get known kernels.protected IFuture<IComponentFactory>
getNewFactory(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
If there are other kernel specs for the current filename suffix start and test them.java.util.Map<java.lang.String,java.lang.Object>
getProperties(java.lang.String type)
Get a default icon for a component type.protected IFuture<IComponentFactory>
getRunningFactory(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid, java.util.Iterator<IComponentFactory> it)
Get a running subfactory.protected java.util.Set<java.lang.String>
getSuffixes()
Get the filename suffixes that can be loaded with any of the found factories.protected boolean
isLoadable(java.lang.String filename)
Check if a filename is loadable with respect to the suffixes.IFuture<java.lang.Boolean>
isLoadable(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
Test if a model can be loaded by the factory.IFuture<java.lang.Boolean>
isStartable(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
Test if a model is startable (e.g.IFuture<IModelInfo>
loadModel(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
Load a model.IFuture<java.lang.Void>
removeKernelListener(IMultiKernelListener listener)
Removes a kernel listener.protected java.util.Map<java.lang.String,java.util.Collection<Tuple2<java.lang.String,java.util.Set<java.lang.String>>>>
scanForKernels()
Scan files for kernel components.IFuture<java.lang.Void>
startService()
Starts the service.
-
-
-
Field Detail
-
KERNEL_EXTENSIONS
protected static final java.lang.String KERNEL_EXTENSIONS
Kernel model property for extensions- See Also:
- Constant Field Values
-
KERNEL_FILTER
protected static final java.lang.String KERNEL_FILTER
- See Also:
- Constant Field Values
-
ffilter
protected static FileFilter ffilter
Filter for scanning for kernel agent class files.
-
cfilter
protected static IFilter<SClassReader.ClassInfo> cfilter
Filter for scanning for kernel agent class infos.
-
agent
protected IInternalAccess agent
The internal access.
-
libservice
protected ILibraryService libservice
-
listeners
protected java.util.List<IMultiKernelListener> listeners
The listeners.
-
iconcache
protected java.util.Map<java.lang.String,byte[]> iconcache
Cache of component icons
-
sid
protected IServiceIdentifier sid
The service identifier.
-
componenttypes
protected java.util.Set<java.lang.String> componenttypes
Currently supported types (loadable suffixes)
-
kernelfiles
protected java.util.Map<java.lang.String,java.util.Collection<Tuple2<java.lang.String,java.util.Set<java.lang.String>>>> kernelfiles
The scanned kernel files (suffix -> {(classname, suffixes)} ).
-
kernels
protected java.util.Map<java.lang.String,java.lang.Object> kernels
The started factories (kernel classname -> kernel component).
-
inited
protected boolean inited
The started flag (because init is invoked twice, service impl for 2 services.
-
dirty
protected boolean dirty
The dirty flag (when classpath changes).
-
known_kernels
protected java.util.Set<java.lang.String> known_kernels
The known factories.
-
known_kernels_cache
protected MultiCollection<java.lang.String,Tuple2<java.lang.String,java.util.Set<java.lang.String>>> known_kernels_cache
-
MULTIFACTORY
public static final java.lang.String MULTIFACTORY
- See Also:
- Constant Field Values
-
props
public static final java.util.Map<java.lang.String,java.lang.Object> props
Used in SComponentFactory to reorder checks (multi last). Still necessary?!.
-
getnewfac
protected CallSequentializer<IComponentFactory> getnewfac
The sequentializer to execute getNewFactory() one by one and not interleaved.
-
cnt
protected int cnt
Test if a model can be loaded by the factory.
-
-
Method Detail
-
startService
public IFuture<java.lang.Void> startService()
Starts the service.
-
getComponentTypeIcon
public IFuture<byte[]> getComponentTypeIcon(java.lang.String type)
Get a default icon for a component type.- Specified by:
getComponentTypeIcon
in interfaceIComponentFactory
-
loadModel
public IFuture<IModelInfo> loadModel(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
Load a model.- Specified by:
loadModel
in interfaceIComponentFactory
- Parameters:
model
- The model (e.g. file name or resource name).The
- imports (if any).- Returns:
- The loaded model.
-
getFactoryForModel
protected IFuture<IComponentFactory> getFactoryForModel(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
Get a factory for a model. 1) will check running factories 2) if none was found will check if a new can be started- Returns:
- A factory that can load the model (or null if none was found).
-
getNewFactory
protected IFuture<IComponentFactory> getNewFactory(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
If there are other kernel specs for the current filename suffix start and test them. Returns a new factory that can load the model (if any).
-
scanForKernels
protected java.util.Map<java.lang.String,java.util.Collection<Tuple2<java.lang.String,java.util.Set<java.lang.String>>>> scanForKernels()
Scan files for kernel components.- Returns:
- (suffix -> classname)
-
check
protected IFuture<IComponentFactory> check(java.util.Iterator<Tuple2<java.lang.String,java.util.Set<java.lang.String>>> it, java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
Check a factory- Parameters:
it
- factory iterator.
-
doStartKernel
protected IFuture<IComponentFactory> doStartKernel(java.lang.String model)
- Parameters:
model
-- Returns:
-
getKnownKernels
protected java.util.Map<java.lang.String,java.util.Collection<Tuple2<java.lang.String,java.util.Set<java.lang.String>>>> getKnownKernels()
Get known kernels.
-
getKernelTypes
protected java.lang.String[] getKernelTypes(SClassReader.ClassInfo ci)
Add infos about a kernel to the map.
-
getKernelFiles
protected java.util.Map<java.lang.String,java.util.Collection<Tuple2<java.lang.String,java.util.Set<java.lang.String>>>> getKernelFiles()
Get all kernel files, i.e. specs to start a kernel.
-
getRunningFactory
protected IFuture<IComponentFactory> getRunningFactory(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid, java.util.Iterator<IComponentFactory> it)
Get a running subfactory.
-
isLoadable
public IFuture<java.lang.Boolean> isLoadable(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
Description copied from interface:IComponentFactory
Test if a model can be loaded by the factory.- Specified by:
isLoadable
in interfaceIComponentFactory
- Parameters:
model
- The model (e.g. file name or resource name).- Returns:
- True, if model can be loaded.
-
isStartable
public IFuture<java.lang.Boolean> isStartable(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
Test if a model is startable (e.g. an component).- Specified by:
isStartable
in interfaceIComponentFactory
- Parameters:
model
- The model (e.g. file name or resource name).The
- imports (if any).- Returns:
- True, if startable (and loadable).
-
getComponentType
public IFuture<java.lang.String> getComponentType(java.lang.String model, java.lang.String[] imports, IResourceIdentifier rid)
Get the component type of a model.- Specified by:
getComponentType
in interfaceIComponentFactory
- Parameters:
model
- The model (e.g. file name or resource name).The
- imports (if any).
-
getComponentTypes
public java.lang.String[] getComponentTypes()
Get the names of component types supported by this factory.- Specified by:
getComponentTypes
in interfaceIComponentFactory
-
getProperties
public java.util.Map<java.lang.String,java.lang.Object> getProperties(java.lang.String type)
Get a default icon for a component type.- Specified by:
getProperties
in interfaceIComponentFactory
- Parameters:
type
- The component type.- Returns:
- The properties or null, if the component type is not supported by this factory.
-
getComponentFeatures
public IFuture<java.util.Collection<IComponentFeatureFactory>> getComponentFeatures(IModelInfo model)
Get the component features for a model.- Specified by:
getComponentFeatures
in interfaceIComponentFactory
- Parameters:
model
- The component model.- Returns:
- The component features.
-
getSuffixes
protected java.util.Set<java.lang.String> getSuffixes()
Get the filename suffixes that can be loaded with any of the found factories.
-
isLoadable
protected boolean isLoadable(java.lang.String filename)
Check if a filename is loadable with respect to the suffixes.
-
addKernelListener
public IFuture<java.lang.Void> addKernelListener(IMultiKernelListener listener)
Adds a kernel listener.- Specified by:
addKernelListener
in interfaceIMultiKernelNotifierService
- Parameters:
listener
- The listener.- Returns:
- Null, when done.
-
removeKernelListener
public IFuture<java.lang.Void> removeKernelListener(IMultiKernelListener listener)
Removes a kernel listener.- Specified by:
removeKernelListener
in interfaceIMultiKernelNotifierService
- Parameters:
listener
- The listener.- Returns:
- Null, when done.
-
fireTypesAdded
public void fireTypesAdded(java.lang.String[] types)
Fires a types added event.- Parameters:
types
- The types added.
-
fireTypesRemoved
public void fireTypesRemoved(java.lang.String[] types)
Fires a types removed event.- Parameters:
types
- The types removed.
-
getFactories
protected java.util.Collection<IComponentFactory> getFactories()
Get all subfactories except the multi itself.
-
-