public final class PluginContext extends Object
Modifier and Type | Field and Description |
---|---|
private Map<String,Object> |
attributes
.
|
private ExecutorService |
executor
The shared executor.
|
private ClassLoader |
loader
.
|
private static Logger |
log
.
|
(package private) PluginManager |
manager
.
|
private PropertyManager |
propertyManager
.
|
private ResourceManager |
resourceManager
.
|
private ScheduledExecutorService |
scanner
.
|
private ScheduledFuture |
scannerFuture
.
|
private boolean |
started
.
|
private String |
version
.
|
Constructor and Description |
---|
PluginContext(ExecutorService executor,
ScheduledExecutorService scanner,
PluginDiscovery discovery,
Map<String,Object> attributes,
FS cmdFS,
FS confFS,
ClassLoader loader)
Create a new plugin context.
|
PluginContext(PluginDiscovery discovery,
Map<String,Object> attributes,
FS cmdFS,
FS confFS,
ClassLoader loader)
Create a new plugin context with preconfigured executor and scanner, this is equivalent to invoking:
|
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
getAttributes() |
ExecutorService |
getExecutor() |
ClassLoader |
getLoader()
Returns the classloader associated with this context.
|
<T> T |
getPlugin(Class<T> pluginType)
Returns the first plugin associated with this context implementing the specified type.
|
Iterable<CRaSHPlugin<?>> |
getPlugins() |
<T> Iterable<T> |
getPlugins(Class<T> pluginType)
Returns the plugins associated with this context.
|
<T> T |
getProperty(PropertyDescriptor<T> desc)
Returns a context property or null if it cannot be found.
|
PropertyManager |
getPropertyManager() |
String |
getVersion() |
Iterable<String> |
listResources(ResourceKind kind)
List the resources id for a specific resource kind.
|
Resource |
loadResource(String resourceId,
ResourceKind resourceKind)
Load a resource from the context.
|
Iterable<Resource> |
loadResources(String resourceId,
ResourceKind resourceKind)
Load a resource from the context.
|
void |
refresh()
Refresh the fs system view.
|
<T> void |
setProperty(PropertyDescriptor<T> desc,
String value)
Set a context property to a new value.
|
<T> void |
setProperty(PropertyDescriptor<T> desc,
T value)
Set a context property to a new value.
|
(package private) void |
start() |
(package private) void |
stop() |
final PluginManager manager
private final ClassLoader loader
private final ScheduledExecutorService scanner
private final Map<String,Object> attributes
private final ExecutorService executor
private boolean started
private ScheduledFuture scannerFuture
private final ResourceManager resourceManager
private final PropertyManager propertyManager
public PluginContext(PluginDiscovery discovery, Map<String,Object> attributes, FS cmdFS, FS confFS, ClassLoader loader) throws NullPointerException
new PluginContext(
Executors.newFixedThreadPool(20),
new ScheduledThreadPoolExecutor(1),
discovery,
attributes,
cmdFS,
confFS,
loader);
discovery
- the plugin discoverycmdFS
- the command file systemattributes
- the attributesconfFS
- the conf file systemloader
- the loaderNullPointerException
- if any parameter argument is nullpublic PluginContext(ExecutorService executor, ScheduledExecutorService scanner, PluginDiscovery discovery, Map<String,Object> attributes, FS cmdFS, FS confFS, ClassLoader loader) throws NullPointerException
executor
- the executor for executing asynchronous jobsscanner
- the background scanner for scanning commandsdiscovery
- the plugin discoverycmdFS
- the command file systemattributes
- the attributesconfFS
- the conf file systemloader
- the loaderNullPointerException
- if any parameter argument is nullpublic String getVersion()
public Map<String,Object> getAttributes()
public ExecutorService getExecutor()
public PropertyManager getPropertyManager()
public <T> T getProperty(PropertyDescriptor<T> desc) throws NullPointerException
T
- the property parameter typedesc
- the property descriptorNullPointerException
- if the descriptor argument is nullpublic <T> void setProperty(PropertyDescriptor<T> desc, T value) throws NullPointerException
T
- the property parameter typedesc
- the property descriptorvalue
- the property valueNullPointerException
- if the descriptor argument is nullpublic <T> void setProperty(PropertyDescriptor<T> desc, String value) throws NullPointerException, IllegalArgumentException
T
- the property parameter typedesc
- the property descriptorvalue
- the property valueNullPointerException
- if the descriptor argument is nullIllegalArgumentException
- if the string value cannot be converted to the property typepublic Resource loadResource(String resourceId, ResourceKind resourceKind)
resourceId
- the resource idresourceKind
- the resource kindpublic Iterable<Resource> loadResources(String resourceId, ResourceKind resourceKind)
resourceId
- the resource idresourceKind
- the resource kindpublic Iterable<String> listResources(ResourceKind kind)
kind
- the resource kindpublic ClassLoader getLoader()
public Iterable<CRaSHPlugin<?>> getPlugins()
public <T> Iterable<T> getPlugins(Class<T> pluginType)
T
- the plugin generic typepluginType
- the plugin typepublic <T> T getPlugin(Class<T> pluginType)
T
- the plugin generic typepluginType
- the plugin typepublic void refresh()
void start()
void stop()
Copyright © 2015 eXo Platform SAS. All Rights Reserved.