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 IInternalAccessagentThe internal access.protected java.util.Map<java.lang.String,java.lang.String>allannotationtypesprotected java.util.Set<java.lang.String>allcomponenttypesThe annotation type values representing different class component types.protected static IFilter<SClassReader.ClassInfo>cfilterFilter for scanning for kernel agent class infos.protected intcntTest if a model can be loaded by the factory.protected java.util.Set<java.lang.String>componenttypesCurrently supported types (loadable suffixes)protected booleandirtyThe dirty flag (when classpath changes).protected static FileFilterffilterFilter for scanning for kernel agent class files.protected java.util.Map<java.lang.String,byte[]>iconcacheCache of component iconsprotected booleaninitedThe started flag (because init is invoked twice, service impl for 2 services.protected static java.lang.StringKERNEL_EXTENSIONSKernel model property for extensionsprotected static java.lang.StringKERNEL_FILTERprotected java.util.Map<java.lang.String,java.util.Collection<Tuple2<java.lang.String,java.util.Set<java.lang.String>>>>kernelfilesThe scanned kernel files (suffix -> {(classname, suffixes)} ).protected java.util.Map<java.lang.String,java.lang.Object>kernelsThe started factories (kernel classname -> kernel component).protected java.util.Set<java.lang.String>known_kernelsThe known factories.protected MultiCollection<java.lang.String,Tuple2<java.lang.String,java.util.Set<java.lang.String>>>known_kernels_cacheprotected ILibraryServicelibserviceprotected java.util.List<IMultiKernelListener>listenersThe listeners.static java.lang.StringMULTIFACTORYstatic java.util.Map<java.lang.String,java.lang.Object>propsUsed in SComponentFactory to reorder checks (multi last).protected Future<java.util.Map<java.lang.String,java.util.Collection<Tuple2<java.lang.String,java.util.Set<java.lang.String>>>>>scanfutureprotected IServiceIdentifiersidThe 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.Object pojo, java.lang.String[] imports, IResourceIdentifier rid)Check a factoryprotected IFuture<IComponentFactory>doStartKernel(java.lang.String model)voidfireTypesAdded(java.lang.String[] types)Fires a types added event.voidfireTypesRemoved(java.lang.String[] types)Fires a types removed event.java.lang.String[]getComponentAnnotationTypes()IFuture<java.util.Collection<IComponentFeatureFactory>>getComponentFeatures(IModelInfo model, java.lang.Object pojo)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.Object pojo, java.lang.String[] imports, IResourceIdentifier rid)Get a factory for a model.protected java.lang.String[]getKernelAnnotationTypes(SClassReader.ClassInfo ci)Add infos about a kernel to the map (@Agent(type=))protected java.lang.String[]getKernelComponentAnnotationTypes(SClassReader.ClassInfo ci)Get supported kernel component types.protected java.lang.String[]getKernelComponentTypes(SClassReader.ClassInfo ci)Get supported kernel component types.protected Future<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[]getKernelSuffixes(SClassReader.ClassInfo ci)Get supported kernel suffixes.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.Object pojo, 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.Object pojo, 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 voidinitKnownComponentTypes()Get known class component types in annotation.protected booleanisLoadable(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.Object pojo, 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.Object pojo, java.lang.String[] imports, IResourceIdentifier rid)Test if a model is startable (e.g.IFuture<IModelInfo>loadModel(java.lang.String model, java.lang.Object pojo, java.lang.String[] imports, IResourceIdentifier rid)Load a model.IFuture<java.lang.Void>removeKernelListener(IMultiKernelListener listener)Removes a kernel listener.protected IFuture<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) 
- 
allcomponenttypes
protected java.util.Set<java.lang.String> allcomponenttypes
The annotation type values representing different class component types. () 
- 
allannotationtypes
protected java.util.Map<java.lang.String,java.lang.String> allannotationtypes
 
- 
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?!. 
- 
scanfuture
protected Future<java.util.Map<java.lang.String,java.util.Collection<Tuple2<java.lang.String,java.util.Set<java.lang.String>>>>> scanfuture
 
- 
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:
 getComponentTypeIconin interfaceIComponentFactory
 
- 
loadModel
public IFuture<IModelInfo> loadModel(java.lang.String model, java.lang.Object pojo, java.lang.String[] imports, IResourceIdentifier rid)
Load a model.- Specified by:
 loadModelin 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.Object pojo, 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.Object pojo, 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 IFuture<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.Object pojo, 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. suffix -> [factory class name, {types}] 
- 
initKnownComponentTypes
protected void initKnownComponentTypes()
Get known class component types in annotation. 
- 
getKernelSuffixes
protected java.lang.String[] getKernelSuffixes(SClassReader.ClassInfo ci)
Get supported kernel suffixes. These types are the file suffixes. 
- 
getKernelComponentTypes
protected java.lang.String[] getKernelComponentTypes(SClassReader.ClassInfo ci)
Get supported kernel component types. Add infos about a kernel 
- 
getKernelComponentAnnotationTypes
protected java.lang.String[] getKernelComponentAnnotationTypes(SClassReader.ClassInfo ci)
Get supported kernel component types. Add infos about a kernel 
- 
getKernelAnnotationTypes
protected java.lang.String[] getKernelAnnotationTypes(SClassReader.ClassInfo ci)
Add infos about a kernel to the map (@Agent(type=)) 
- 
getKernelFiles
protected Future<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.Object pojo, 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.Object pojo, java.lang.String[] imports, IResourceIdentifier rid)
Description copied from interface:IComponentFactoryTest if a model can be loaded by the factory.- Specified by:
 isLoadablein 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.Object pojo, java.lang.String[] imports, IResourceIdentifier rid)
Test if a model is startable (e.g. an component).- Specified by:
 isStartablein 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:
 getComponentTypein 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:
 getComponentTypesin interfaceIComponentFactory
 
- 
getComponentAnnotationTypes
public java.lang.String[] getComponentAnnotationTypes()
- Specified by:
 getComponentAnnotationTypesin 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:
 getPropertiesin 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, java.lang.Object pojo)
Get the component features for a model.- Specified by:
 getComponentFeaturesin 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. Used for isLoadAble() 
- 
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:
 addKernelListenerin interfaceIMultiKernelNotifierService- Parameters:
 listener- The listener.- Returns:
 - Null, when done.
 
 
- 
removeKernelListener
public IFuture<java.lang.Void> removeKernelListener(IMultiKernelListener listener)
Removes a kernel listener.- Specified by:
 removeKernelListenerin 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. 
 - 
 
 -