public class MultiFactory
extends java.lang.Object
implements jadex.bridge.service.types.factory.IComponentFactory, jadex.bridge.service.types.factory.IMultiKernelNotifierService
Modifier and Type | Field and Description |
---|---|
protected java.util.Set<java.lang.String> |
activatedkernels
Set of kernels that have been active at one point
|
protected boolean |
activekernelsdirty
Flag if active kernels has changed.
|
protected java.util.Set<java.lang.String> |
baseextensionblacklist
Base Blacklist of extension for which there is no factory
|
protected java.util.Set<java.lang.String> |
componenttypes
Currently supported types
|
protected java.util.Map<java.lang.String,jadex.bridge.service.types.factory.IComponentFactory> |
factorycache
Cache of known factories
|
protected jadex.bridge.IInternalAccess |
ia
The internal access.
|
protected java.util.Map<java.lang.String,byte[]> |
iconcache
Cache of component icons
|
protected static java.lang.String |
KERNEL_EXTENSIONS
Kernel model property for extensions
|
protected java.util.Set<java.lang.String> |
kernelblacklist
Kernel blacklist
|
protected jadex.commons.collection.MultiCollection<java.lang.String,java.lang.String> |
kerneldefaultlocations
Kernel default locations
|
protected jadex.commons.collection.MultiCollection<java.lang.String,java.lang.String> |
kernellocationcache
Cache of kernel locations
|
protected jadex.commons.collection.MultiCollection<java.net.URI,java.lang.String> |
kerneluris
URLs of the kernels
|
protected jadex.bridge.service.types.library.ILibraryServiceListener |
liblistener
Library service listener
|
protected jadex.bridge.service.types.library.ILibraryService |
libservice
The library service.
|
protected java.util.List<jadex.bridge.IMultiKernelListener> |
listeners
The listeners.
|
static java.lang.String |
MULTIFACTORY |
protected jadex.commons.future.CallMultiplexer |
multiplexer
Call Multiplexer
|
protected java.util.Set<java.lang.String> |
potentialkernellocations
Unloadable kernel locations that may become loadable later.
|
protected java.util.Set<java.net.URI> |
potentialuris
Set of potential URLs for kernel searches
|
static java.util.Map<java.lang.String,java.lang.Object> |
props |
protected jadex.bridge.service.IServiceIdentifier |
sid
The service identifier.
|
protected boolean |
started
Flag whether the service has started
|
protected java.util.Set<java.net.URI> |
validuris
Currently valid URLs
|
Constructor and Description |
---|
MultiFactory(java.lang.String[] defaultLocations,
java.lang.String[] kernelblacklist,
java.lang.String[] extensionblacklist)
Creates a new MultiFactory.
|
Modifier and Type | Method and Description |
---|---|
jadex.commons.future.IFuture |
addKernelListener(jadex.bridge.IMultiKernelListener listener)
Adds a kernel listener.
|
boolean |
equals(java.lang.Object obj) |
protected jadex.commons.future.IFuture<java.util.Map<java.lang.String,java.lang.String>> |
examineKernelModels(java.util.List<java.lang.String> modellocs,
jadex.bridge.IResourceIdentifier rid)
Examines potential kernels whether their model can be loaded or loaded
with the help of another kernel that can be found.
|
protected jadex.commons.future.IFuture |
findActiveKernel(java.lang.String model,
java.lang.String[] imports,
jadex.bridge.IResourceIdentifier rid)
Attempts to find a running kernel matching the model.
|
protected jadex.commons.future.IFuture<jadex.bridge.service.types.factory.IComponentFactory> |
findKernel(java.lang.String model,
java.lang.String[] imports,
jadex.bridge.IResourceIdentifier rid)
Attempts to find an active kernel factory, searching, loading and instantiating as required.
|
protected jadex.commons.future.IFuture |
findKernel(java.lang.String model,
java.lang.String[] imports,
jadex.bridge.IResourceIdentifier rid,
boolean isrecur)
Attempts to find an active kernel factory, searching, loading and instantiating as required.
|
protected jadex.commons.future.IFuture |
findKernelInCache(java.lang.String model,
java.lang.String[] imports,
jadex.bridge.IResourceIdentifier rid,
boolean isrecur)
Attempts to find a kernel which is currently not loaded in the
cache or through search, matching the model.
|
protected jadex.commons.future.IFuture |
findLoadableKernel(java.lang.String model,
java.lang.String[] imports,
jadex.bridge.IResourceIdentifier rid,
boolean isrecur)
Attempts to find a kernel which is currently not loaded, matching the model.
|
jadex.commons.future.IFuture |
fireTypesAdded(java.lang.String[] types)
Fires a types added event.
|
jadex.commons.future.IFuture |
fireTypesRemoved(java.lang.String[] types)
Fires a types removed event.
|
protected jadex.commons.Tuple2<java.lang.String,java.lang.Object> |
getCacheKeyValueForModel(java.lang.String model,
java.util.Map<java.lang.String,java.lang.Object> map)
Gets key/value for a cached object based on model name.
|
protected java.lang.Object |
getCacheResultForModel(java.lang.String model,
java.util.Map map)
Gets result for a cached object based on model name.
|
jadex.commons.future.IFuture<java.util.Collection<jadex.bridge.component.IComponentFeatureFactory>> |
getComponentFeatures(jadex.bridge.modelinfo.IModelInfo model)
Get the component features for a model.
|
jadex.commons.future.IFuture<java.lang.String> |
getComponentType(java.lang.String model,
java.lang.String[] imports,
jadex.bridge.IResourceIdentifier rid)
Get the component type of a model.
|
jadex.commons.future.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.
|
java.util.Map |
getProperties(java.lang.String type)
Get the properties (name/value pairs).
|
int |
hashCode() |
protected boolean |
hasLoadablePotentialKernels()
Check if there is a potential kernel that could be
loaded when another kernel from cache is started.
|
protected boolean |
isInExtensionBlacklist(java.lang.Object model,
java.util.Set blacklist)
Checks if a model matches an extension blacklist.
|
jadex.commons.future.IFuture<java.lang.Boolean> |
isLoadable(java.lang.String model,
java.lang.String[] imports,
jadex.bridge.IResourceIdentifier rid)
Test if a model can be loaded by the factory.
|
jadex.commons.future.IFuture<java.lang.Boolean> |
isStartable(java.lang.String model,
java.lang.String[] imports,
jadex.bridge.IResourceIdentifier rid)
Test if a model is startable (e.g.
|
protected jadex.commons.future.IFuture<java.util.Map<java.lang.String,java.lang.String>> |
kernelSearch(java.net.URI uri,
jadex.commons.IFilter prefilter,
jadex.bridge.IResourceIdentifier rid)
Searches supplied URL for a potential kernel matching the filter and containing
a description of loadable file extensions.
|
jadex.commons.future.IFuture<jadex.bridge.modelinfo.IModelInfo> |
loadModel(java.lang.String model,
java.lang.String[] imports,
jadex.bridge.IResourceIdentifier rid)
Load a model.
|
jadex.commons.future.IFuture<jadex.bridge.modelinfo.IModelInfo> |
loadModel(java.lang.String model,
java.lang.String[] imports,
jadex.bridge.IResourceIdentifier rid,
boolean isrecur)
Load a model.
|
protected jadex.commons.future.IFuture<java.util.Map<java.lang.String,java.lang.String>> |
quickKernelSearch(java.net.URI uri,
jadex.bridge.IResourceIdentifier rid)
Searches supplied URL for a potential kernel.
|
jadex.commons.future.IFuture |
removeKernelListener(jadex.bridge.IMultiKernelListener listener)
Removes a kernel listener.
|
protected java.util.List<java.lang.String> |
searchApk(java.io.File apk,
jadex.commons.IFilter filter)
Searches a .apk for files matching a filter.
|
protected java.util.List<java.lang.String> |
searchDirectory(java.io.File dir,
jadex.commons.IFilter filter,
boolean prependDir)
Searches a directory for files matching a filter.
|
protected java.util.List<java.lang.String> |
searchJar(java.io.File jar,
jadex.commons.IFilter filter)
Searches a .jar for files matching a filter.
|
protected jadex.commons.future.IFuture |
searchPotentialUrls(jadex.bridge.IResourceIdentifier rid)
Searches the set of potential URLs for a kernel supporting the extension,
putting it in the cache for use if found.
|
protected java.util.List<java.lang.String> |
searchUri(java.net.URI uri,
jadex.commons.IFilter filter)
Searches an URI, accepts both directory and .jar-based URLs.
|
jadex.commons.future.IFuture<java.lang.Void> |
shutdownService()
Stops the service.
|
protected jadex.commons.future.IFuture |
startLoadableKernel(java.lang.String model,
java.lang.String[] imports,
jadex.bridge.IResourceIdentifier rid,
java.lang.String kernelmodel)
Starts a kernel matching the model.
|
jadex.commons.future.IFuture<java.lang.Void> |
startService()
Starts the service.
|
protected static final java.lang.String KERNEL_EXTENSIONS
protected jadex.bridge.IInternalAccess ia
protected jadex.commons.collection.MultiCollection<java.lang.String,java.lang.String> kerneldefaultlocations
protected java.util.Map<java.lang.String,jadex.bridge.service.types.factory.IComponentFactory> factorycache
protected jadex.commons.collection.MultiCollection<java.lang.String,java.lang.String> kernellocationcache
protected jadex.commons.collection.MultiCollection<java.net.URI,java.lang.String> kerneluris
protected java.util.Set<java.net.URI> potentialuris
protected java.util.Set<java.net.URI> validuris
protected java.util.Set<java.lang.String> activatedkernels
protected boolean activekernelsdirty
protected java.util.Set<java.lang.String> componenttypes
protected java.util.Map<java.lang.String,byte[]> iconcache
protected java.util.Set<java.lang.String> baseextensionblacklist
protected java.util.Set<java.lang.String> kernelblacklist
protected java.util.Set<java.lang.String> potentialkernellocations
protected jadex.commons.future.CallMultiplexer multiplexer
protected java.util.List<jadex.bridge.IMultiKernelListener> listeners
protected jadex.bridge.service.IServiceIdentifier sid
protected boolean started
protected jadex.bridge.service.types.library.ILibraryServiceListener liblistener
protected jadex.bridge.service.types.library.ILibraryService libservice
public static final java.lang.String MULTIFACTORY
public static final java.util.Map<java.lang.String,java.lang.Object> props
public MultiFactory(java.lang.String[] defaultLocations, java.lang.String[] kernelblacklist, java.lang.String[] extensionblacklist)
ia
- Component internal access.defaultLocations
- Known kernel location to be checked first.kernelblacklist
- Kernels the factory should ignore.extensionblacklist
- File extension the factory should not consider to be models
(no extension and most files with .class extension are ignored by default)public jadex.commons.future.IFuture<java.lang.Void> startService()
public jadex.commons.future.IFuture<java.lang.Void> shutdownService()
public jadex.commons.future.IFuture<jadex.bridge.modelinfo.IModelInfo> loadModel(java.lang.String model, java.lang.String[] imports, jadex.bridge.IResourceIdentifier rid)
loadModel
in interface jadex.bridge.service.types.factory.IComponentFactory
model
- The model (e.g. file name).The
- imports (if any).public jadex.commons.future.IFuture<jadex.bridge.modelinfo.IModelInfo> loadModel(java.lang.String model, java.lang.String[] imports, jadex.bridge.IResourceIdentifier rid, boolean isrecur)
model
- The model (e.g. file name).The
- imports (if any).public jadex.commons.future.IFuture<java.lang.Boolean> isLoadable(java.lang.String model, java.lang.String[] imports, jadex.bridge.IResourceIdentifier rid)
isLoadable
in interface jadex.bridge.service.types.factory.IComponentFactory
model
- The model (e.g. file name).The
- imports (if any).public jadex.commons.future.IFuture<java.lang.Boolean> isStartable(java.lang.String model, java.lang.String[] imports, jadex.bridge.IResourceIdentifier rid)
isStartable
in interface jadex.bridge.service.types.factory.IComponentFactory
model
- The model (e.g. file name).The
- imports (if any).public jadex.commons.future.IFuture<java.lang.String> getComponentType(java.lang.String model, java.lang.String[] imports, jadex.bridge.IResourceIdentifier rid)
getComponentType
in interface jadex.bridge.service.types.factory.IComponentFactory
model
- The model (e.g. file name).The
- imports (if any).public jadex.commons.future.IFuture<byte[]> getComponentTypeIcon(java.lang.String type)
getComponentTypeIcon
in interface jadex.bridge.service.types.factory.IComponentFactory
public java.lang.String[] getComponentTypes()
getComponentTypes
in interface jadex.bridge.service.types.factory.IComponentFactory
public java.util.Map getProperties(java.lang.String type)
getProperties
in interface jadex.bridge.service.types.factory.IComponentFactory
type
- The component type.public jadex.commons.future.IFuture<java.util.Collection<jadex.bridge.component.IComponentFeatureFactory>> getComponentFeatures(jadex.bridge.modelinfo.IModelInfo model)
getComponentFeatures
in interface jadex.bridge.service.types.factory.IComponentFactory
model
- The component model.public jadex.commons.future.IFuture addKernelListener(jadex.bridge.IMultiKernelListener listener)
addKernelListener
in interface jadex.bridge.service.types.factory.IMultiKernelNotifierService
listener
- The listener.public jadex.commons.future.IFuture removeKernelListener(jadex.bridge.IMultiKernelListener listener)
removeKernelListener
in interface jadex.bridge.service.types.factory.IMultiKernelNotifierService
listener
- The listener.public jadex.commons.future.IFuture fireTypesAdded(java.lang.String[] types)
types
- The types added.public jadex.commons.future.IFuture fireTypesRemoved(java.lang.String[] types)
types
- The types removed.protected jadex.commons.future.IFuture<jadex.bridge.service.types.factory.IComponentFactory> findKernel(java.lang.String model, java.lang.String[] imports, jadex.bridge.IResourceIdentifier rid)
model
- The model for which the kernel is needed.imports
- Model imports.classloader
- Model classloader.protected jadex.commons.future.IFuture findKernel(java.lang.String model, java.lang.String[] imports, jadex.bridge.IResourceIdentifier rid, boolean isrecur)
model
- The model for which the kernel is needed.imports
- Model imports.classloader
- Model classloader.protected jadex.commons.future.IFuture findActiveKernel(java.lang.String model, java.lang.String[] imports, jadex.bridge.IResourceIdentifier rid)
model
- The model for which the kernel is needed.imports
- Model imports.protected jadex.commons.future.IFuture findLoadableKernel(java.lang.String model, java.lang.String[] imports, jadex.bridge.IResourceIdentifier rid, boolean isrecur)
model
- The model for which the kernel is needed.imports
- Model imports.classloader
- Model classloader.protected jadex.commons.future.IFuture findKernelInCache(java.lang.String model, java.lang.String[] imports, jadex.bridge.IResourceIdentifier rid, boolean isrecur)
model
- The model for which the kernel is needed.imports
- Model imports.classloader
- Model classloader.protected boolean hasLoadablePotentialKernels()
protected jadex.commons.future.IFuture startLoadableKernel(java.lang.String model, java.lang.String[] imports, jadex.bridge.IResourceIdentifier rid, java.lang.String kernelmodel)
model
- The model for which the kernel is needed.imports
- Model imports.classloader
- Model classloader.kernelmodel
- Model of the kernel.protected jadex.commons.future.IFuture searchPotentialUrls(jadex.bridge.IResourceIdentifier rid)
protected jadex.commons.future.IFuture<java.util.Map<java.lang.String,java.lang.String>> quickKernelSearch(java.net.URI uri, jadex.bridge.IResourceIdentifier rid)
url
- The URL to searchprotected jadex.commons.future.IFuture<java.util.Map<java.lang.String,java.lang.String>> kernelSearch(java.net.URI uri, jadex.commons.IFilter prefilter, jadex.bridge.IResourceIdentifier rid)
url
- The URL to searchprefilter
- Prefilter applied before further restrictions are applied.protected jadex.commons.future.IFuture<java.util.Map<java.lang.String,java.lang.String>> examineKernelModels(java.util.List<java.lang.String> modellocs, jadex.bridge.IResourceIdentifier rid)
modellocs
- List of locations of potential kernels.libservice
- Library service.protected java.util.List<java.lang.String> searchUri(java.net.URI uri, jadex.commons.IFilter filter)
uri
- The URI.filter
- The search filter.protected java.util.List<java.lang.String> searchDirectory(java.io.File dir, jadex.commons.IFilter filter, boolean prependDir)
dir
- The directory.filter
- The filter.prependDir
- Flag whether to prepend the directory name to files found,
used when unwinding recursions.protected java.util.List<java.lang.String> searchJar(java.io.File jar, jadex.commons.IFilter filter)
jar
- The .jar-file.filter
- The filter.protected java.util.List<java.lang.String> searchApk(java.io.File apk, jadex.commons.IFilter filter)
jar
- The .jar-file.filter
- The filter.protected boolean isInExtensionBlacklist(java.lang.Object model, java.util.Set blacklist)
protected java.lang.Object getCacheResultForModel(java.lang.String model, java.util.Map map)
model
- The model.map
- The cache.protected jadex.commons.Tuple2<java.lang.String,java.lang.Object> getCacheKeyValueForModel(java.lang.String model, java.util.Map<java.lang.String,java.lang.Object> map)
model
- The model.map
- The cache.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object