Search in sources :

Example 1 with ISessionContextManager

use of com.ibm.jvm.dtfjview.spi.ISessionContextManager in project openj9 by eclipse.

the class CloseCommand method run.

public void run(String command, String[] args, IContext context, PrintStream out) throws CommandException {
    if (initCommand(command, args, context, out)) {
        // processing already handled by super class
        return;
    }
    Object obj = ctx.getProperties().get(SessionProperties.SESSION_PROPERTY);
    if (obj == null) {
        logger.fine("Could not close a new context as the session property has not been set");
        return;
    }
    if (!(obj instanceof Session)) {
        logger.fine("Could not close an existing context as the session type was not recognised [" + obj.getClass().getName() + "]");
        return;
    }
    ISessionContextManager mgr = ((ISession) obj).getContextManager();
    switch(args.length) {
        case // close all contexts
        0:
            out.println("Closing all contexts");
            mgr.removeAllContexts();
            out.println("All contexts have been closed");
            break;
        case // close all images shared with the specified context
        1:
            out.println("Closing all contexts sharing the same Image");
            int id = Integer.valueOf(args[0]);
            ICombinedContext toclose = mgr.getContext(id);
            if (toclose == null) {
                out.println("The specified context id " + args[0] + " was invalid");
                return;
            }
            mgr.removeContexts(toclose.getImage().getSource());
            out.println("Closed all contexts created from " + toclose.getImage().getSource());
            break;
        default:
            out.println("This command takes 0 or 1 parameters. Execute 'close help' for more information");
            return;
    }
}
Also used : ISession(com.ibm.jvm.dtfjview.spi.ISession) ISessionContextManager(com.ibm.jvm.dtfjview.spi.ISessionContextManager) ICombinedContext(com.ibm.jvm.dtfjview.spi.ICombinedContext) ISession(com.ibm.jvm.dtfjview.spi.ISession) Session(com.ibm.jvm.dtfjview.Session)

Aggregations

Session (com.ibm.jvm.dtfjview.Session)1 ICombinedContext (com.ibm.jvm.dtfjview.spi.ICombinedContext)1 ISession (com.ibm.jvm.dtfjview.spi.ISession)1 ISessionContextManager (com.ibm.jvm.dtfjview.spi.ISessionContextManager)1