|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.crsh.plugin.PluginContext
public final class PluginContext
Field Summary | |
---|---|
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 Summary | |
---|---|
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:
|
Method Summary | ||
---|---|---|
Map<String,Object> |
getAttributes()
|
|
ExecutorService |
getExecutor()
|
|
ClassLoader |
getLoader()
Returns the classloader associated with this context. |
|
|
getPlugin(Class<T> pluginType)
Returns the first plugin associated with this context implementing the specified type. |
|
Iterable<CRaSHPlugin<?>> |
getPlugins()
|
|
|
getPlugins(Class<T> pluginType)
Returns the plugins associated with this context. |
|
|
getProperty(PropertyDescriptor<T> desc)
Returns a context property or null if it cannot be found. |
|
|
getProperty(String propertyName,
Class<T> type)
Returns a context property or null if it cannot be found. |
|
String |
getVersion()
|
|
List<String> |
listResourceId(ResourceKind kind)
List the resources id for a specific resource kind. |
|
Resource |
loadResource(String resourceId,
ResourceKind resourceKind)
Load a resource from the context. |
|
void |
refresh()
Refresh the fs system view. |
|
|
setProperty(PropertyDescriptor<T> desc,
String value)
Set a context property to a new value. |
|
|
setProperty(PropertyDescriptor<T> desc,
T value)
Set a context property to a new value. |
|
(package private) void |
start()
|
|
(package private) void |
stop()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger log
final PluginManager manager
private final ClassLoader loader
private final String version
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
Constructor Detail |
---|
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 loader
NullPointerException
- 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 loader
NullPointerException
- if any parameter argument is nullMethod Detail |
---|
public String getVersion()
public Map<String,Object> getAttributes()
public ExecutorService getExecutor()
public <T> T getProperty(PropertyDescriptor<T> desc) throws NullPointerException
T
- the property parameter typedesc
- the property descriptor
NullPointerException
- if the descriptor argument is nullpublic <T> T getProperty(String propertyName, Class<T> type) throws NullPointerException
T
- the property parameter typepropertyName
- the name of the propertytype
- the property type
NullPointerException
- 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 value
NullPointerException
- 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 value
NullPointerException
- if the descriptor argument is null
IllegalArgumentException
- if the string value cannot be converted to the property typepublic Resource loadResource(String resourceId, ResourceKind resourceKind)
resourceId
- the resource idresourceKind
- the resource kind
public List<String> listResourceId(ResourceKind kind)
kind
- the resource kind
public ClassLoader getLoader()
public Iterable<CRaSHPlugin<?>> getPlugins()
public <T> Iterable<T> getPlugins(Class<T> pluginType)
T
- the plugin generic typepluginType
- the plugin type
public <T> T getPlugin(Class<T> pluginType)
T
- the plugin generic typepluginType
- the plugin type
public void refresh()
void start()
void stop()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |