org.apache.felix.gogo.runtime

## Class CommandProcessorImpl

- java.lang.Object
- - org.apache.felix.gogo.runtime.CommandProcessorImpl

All Implemented Interfaces:
  CommandProcessor

    @Capability(namespace="osgi.service",
                attribute="objectClass=\'org.apache.felix.service.command.CommandProcessor\'")
    public class CommandProcessorImpl
    extends Object
    implements CommandProcessor

### Field Summary

Fields
`protected ConcurrentMap<String,Map<Object,Integer>>` `commands`
`protected Map<String,Object>` `constants`
`protected Set<Converter>` `converters`
`protected Set<CommandSessionListener>` `listeners`
`protected WeakHashMap<CommandSession,Object>` `sessions`
`protected boolean` `stopped`
`protected ThreadIO` `threadIO`

### Fields inherited from interface org.apache.felix.service.command.CommandProcessor

`COMMAND_FUNCTION, COMMAND_SCOPE`

### Constructor Summary

Constructors
Constructor and Description
`CommandProcessorImpl()`
`CommandProcessorImpl(ThreadIO tio)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addCommand(String scope, Object target)`
`void` `addCommand(String scope, Object target, Class<?> functions)`
`void` `addCommand(String scope, Object target, Class<?> functions, int ranking)`
`void` `addCommand(String scope, Object target, String function)`
`void` `addCommand(String scope, Object target, String function, int ranking)`
`Object` `addConstant(String name, Object target)`
`void` `addConverter(Converter c)`
`void` `addListener(CommandSessionListener l)`
`Object` `convert(CommandSession session, Class<?> desiredType, Object in)`
`CommandSessionImpl` `createSession(CommandSession parent)`
`CommandSessionImpl` `createSession(InputStream in, OutputStream out, OutputStream err)` Create a new command session associated with IO streams.
`Object` `eval(CommandSession session, Object[] argv)`
`Object` `expr(CommandSessionImpl session, CharSequence expr)`
`protected Function` `getCommand(String name, Object path)`
`Set<String>` `getCommands()`
`Object` `invoke(CommandSessionImpl session, Object target, String name, List<Object> args)`
`Path` `redirect(CommandSessionImpl session, Path path, int mode)`
`void` `removeCommand(Object target)`
`void` `removeCommand(String scope, String function)`
`void` `removeCommand(String scope, String function, Object target)`
`Object` `removeConstant(String name)`
`void` `removeConverter(Converter c)`
`void` `removeListener(CommandSessionListener l)`
`void` `stop()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### converters

    protected final Set<Converter> converters

#### listeners

    protected final Set<CommandSessionListener> listeners

#### commands

    protected final ConcurrentMap<String,Map<Object,Integer>> commands

#### constants

    protected final Map<String,Object> constants

#### threadIO

    protected final ThreadIO threadIO

#### sessions

    protected final WeakHashMap<CommandSession,Object> sessions

#### stopped

    protected boolean stopped

### Constructor Detail

#### CommandProcessorImpl

    public CommandProcessorImpl()

#### CommandProcessorImpl

    public CommandProcessorImpl(ThreadIO tio)

### Method Detail

#### createSession

    public CommandSessionImpl createSession(CommandSession parent)

Specified by:
  `createSession` in interface `CommandProcessor`

#### createSession

    public CommandSessionImpl createSession(InputStream in,
                                            OutputStream out,
                                            OutputStream err)

Description copied from interface: `CommandProcessor`
Create a new command session associated with IO streams.

The session is bound to the life cycle of the bundle getting this service. The session will be automatically closed when this bundle is stopped or the service is returned.

The shell will provide any available commands to this session and can set additional variables.

Specified by:
  `createSession` in interface `CommandProcessor`
Parameters:
  `in` - The value used for System.in
  `out` - The stream used for System.out
  `err` - The stream used for System.err
Returns:
  A new session.

#### stop

    public void stop()

#### addConverter

    public void addConverter(Converter c)

#### removeConverter

    public void removeConverter(Converter c)

#### addListener

    public void addListener(CommandSessionListener l)

#### removeListener

    public void removeListener(CommandSessionListener l)

#### getCommands

    public Set<String> getCommands()

#### getCommand

    protected Function getCommand(String name,
                                  Object path)

#### addCommand

    public void addCommand(String scope,
                           Object target)

#### addCommand

    public void addCommand(String scope,
                           Object target,
                           Class<?> functions)

#### addCommand

    public void addCommand(String scope,
                           Object target,
                           Class<?> functions,
                           int ranking)

#### addConstant

    public Object addConstant(String name,
                              Object target)

#### removeConstant

    public Object removeConstant(String name)

#### addCommand

    public void addCommand(String scope,
                           Object target,
                           String function)

#### addCommand

    public void addCommand(String scope,
                           Object target,
                           String function,
                           int ranking)

#### removeCommand

    public void removeCommand(String scope,
                              String function)

#### removeCommand

    public void removeCommand(String scope,
                              String function,
                              Object target)

#### removeCommand

    public void removeCommand(Object target)

#### convert

    public Object convert(CommandSession session,
                          Class<?> desiredType,
                          Object in)

#### eval

    public Object eval(CommandSession session,
                       Object[] argv)
                throws Exception

Throws:
  `Exception`

#### expr

    public Object expr(CommandSessionImpl session,
                       CharSequence expr)

#### invoke

    public Object invoke(CommandSessionImpl session,
                         Object target,
                         String name,
                         List<Object> args)
                  throws Exception

Throws:
  `Exception`

#### redirect

    public Path redirect(CommandSessionImpl session,
                         Path path,
                         int mode)