org.crsh.lang.groovy
Class GroovyCommandManagerImpl

java.lang.Object
  extended by org.crsh.lang.groovy.GroovyCommandManagerImpl
All Implemented Interfaces:
CommandManager

public class GroovyCommandManagerImpl
extends Object
implements CommandManager

Author:
Julien Viet

Field Summary
(package private) static Logger log
          .
private  GroovyClassFactory<Object> objectGroovyClassFactory
          .
private  ClassCache<GroovyScript> scriptCache
          .
 
Constructor Summary
GroovyCommandManagerImpl(PluginContext context)
           
 
Method Summary
 void destroy(HashMap<String,Object> session)
           
 String doCallBack(HashMap<String,Object> session, String name, String defaultValue)
           
private  String eval(HashMap<String,Object> session, String name, String def)
           
 Set<String> getExtensions()
          Returns the set of extensions managed by this implementation.
static groovy.lang.GroovyShell getGroovyShell(CRaSHSession session)
          The underlying groovu shell used for the REPL.
 GroovyScript getLifeCycle(HashMap<String,Object> session, String name)
           
 void init(HashMap<String,Object> session)
           
 boolean isActive()
          Return true if this command manager is active.
private
<C extends BaseCommand>
ShellCommandImpl<C>
make(Class<C> clazz)
           
private
<C extends GroovyScriptCommand>
GroovyScriptShellCommand<C>
make2(Class<C> clazz)
           
 CommandResolution resolveCommand(String name, byte[] source)
          Resolve a command for the specified command name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

static final Logger log
.


scriptCache

private ClassCache<GroovyScript> scriptCache
.


objectGroovyClassFactory

private GroovyClassFactory<Object> objectGroovyClassFactory
.

Constructor Detail

GroovyCommandManagerImpl

public GroovyCommandManagerImpl(PluginContext context)
Method Detail

getExtensions

public Set<String> getExtensions()
Description copied from interface: CommandManager
Returns the set of extensions managed by this implementation.

Specified by:
getExtensions in interface CommandManager
Returns:
the set of extensions, for instance ("groovy")

isActive

public boolean isActive()
Description copied from interface: CommandManager
Return true if this command manager is active. Implementation can decide based on the runtime, for instance the Groovy REPL can be inactive when Groovy is not available at runtime.

Specified by:
isActive in interface CommandManager
Returns:
the active status

doCallBack

public String doCallBack(HashMap<String,Object> session,
                         String name,
                         String defaultValue)
Specified by:
doCallBack in interface CommandManager

init

public void init(HashMap<String,Object> session)
Specified by:
init in interface CommandManager

destroy

public void destroy(HashMap<String,Object> session)
Specified by:
destroy in interface CommandManager

getGroovyShell

public static groovy.lang.GroovyShell getGroovyShell(CRaSHSession session)
The underlying groovu shell used for the REPL.

Returns:
a groovy shell operating on the session attributes

eval

private String eval(HashMap<String,Object> session,
                    String name,
                    String def)

getLifeCycle

public GroovyScript getLifeCycle(HashMap<String,Object> session,
                                 String name)
                          throws CommandCreationException,
                                 NullPointerException
Throws:
CommandCreationException
NullPointerException

resolveCommand

public CommandResolution resolveCommand(String name,
                                        byte[] source)
                                 throws CommandCreationException,
                                        NullPointerException
Description copied from interface: CommandManager
Resolve a command for the specified command name.

Specified by:
resolveCommand in interface CommandManager
Parameters:
name - the command name
source - the command source @return the command or null if no command can be resolved
Throws:
CommandCreationException - when the command exists but cannot be created
NullPointerException - if the command name is null

make

private <C extends BaseCommand> ShellCommandImpl<C> make(Class<C> clazz)

make2

private <C extends GroovyScriptCommand> GroovyScriptShellCommand<C> make2(Class<C> clazz)


Copyright © 2014 eXo Platform SAS. All Rights Reserved.