Search in sources :

Example 1 with Command

use of org.exist.debuggee.dbgp.packets.Command in project exist by eXist-db.

the class RequestDecoder method doDecode.

@Override
protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
    byte b;
    while (true) {
        if (in.remaining() > 0) {
            b = in.get();
            if (b == (byte) 0) {
                Command command = Command.parse(session, sCommand);
                command.exec();
                System.out.println("doDecode command = " + command);
                if (!(command instanceof CommandContinuation)) {
                    out.write(command);
                }
                sCommand = "";
                continue;
            }
            sCommand += (char) b;
        } else {
            return false;
        }
    }
}
Also used : Command(org.exist.debuggee.dbgp.packets.Command) CommandContinuation(org.exist.debuggee.CommandContinuation)

Example 2 with Command

use of org.exist.debuggee.dbgp.packets.Command in project exist by eXist-db.

the class ProtocolHandler method messageReceived.

@Override
public void messageReceived(IoSession session, Object message) {
    Command command = (Command) message;
    if (LOG.isDebugEnabled())
        LOG.debug("" + command.toString());
    session.write(command);
}
Also used : Command(org.exist.debuggee.dbgp.packets.Command)

Example 3 with Command

use of org.exist.debuggee.dbgp.packets.Command in project exist by eXist-db.

the class ContextGet method eval.

@Override
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    try {
        Debuggee dbgr = BrokerPool.getInstance().getDebuggee();
        IoSession session = (IoSession) dbgr.getSession(args[0].getStringValue());
        if (session == null)
            return StringValue.EMPTY_STRING;
        Command command = new org.exist.debuggee.dbgp.packets.ContextGet(session, "");
        command.exec();
        return Utils.nodeFromString(getContext(), new String(command.responseBytes()));
    } catch (Throwable e) {
        throw new XPathException(this, Module.DEBUG001, e);
    }
}
Also used : Debuggee(org.exist.debuggee.Debuggee) Command(org.exist.debuggee.dbgp.packets.Command) XPathException(org.exist.xquery.XPathException) IoSession(org.apache.mina.core.session.IoSession)

Example 4 with Command

use of org.exist.debuggee.dbgp.packets.Command in project exist by eXist-db.

the class Stop method eval.

@Override
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    try {
        Debuggee dbgr = BrokerPool.getInstance().getDebuggee();
        IoSession session = (IoSession) dbgr.getSession(args[0].getStringValue());
        if (session == null)
            return BooleanValue.FALSE;
        Command command = new org.exist.debuggee.dbgp.packets.Stop(session, "");
        command.exec();
        return BooleanValue.TRUE;
    } catch (Throwable e) {
        throw new XPathException(this, Module.DEBUG001, e);
    }
}
Also used : Debuggee(org.exist.debuggee.Debuggee) Command(org.exist.debuggee.dbgp.packets.Command) XPathException(org.exist.xquery.XPathException) IoSession(org.apache.mina.core.session.IoSession)

Example 5 with Command

use of org.exist.debuggee.dbgp.packets.Command in project exist by eXist-db.

the class Run method eval.

@Override
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    try {
        Debuggee dbgr = BrokerPool.getInstance().getDebuggee();
        IoSession session = (IoSession) dbgr.getSession(args[0].getStringValue());
        if (session == null)
            return BooleanValue.FALSE;
        Command command = new org.exist.debuggee.dbgp.packets.Run(session, "");
        command.exec();
        return BooleanValue.TRUE;
    } catch (Throwable e) {
        throw new XPathException(this, Module.DEBUG001, e);
    }
}
Also used : Debuggee(org.exist.debuggee.Debuggee) Command(org.exist.debuggee.dbgp.packets.Command) XPathException(org.exist.xquery.XPathException) IoSession(org.apache.mina.core.session.IoSession)

Aggregations

Command (org.exist.debuggee.dbgp.packets.Command)12 IoSession (org.apache.mina.core.session.IoSession)10 Debuggee (org.exist.debuggee.Debuggee)10 XPathException (org.exist.xquery.XPathException)10 CommandContinuation (org.exist.debuggee.CommandContinuation)1