001 package org.crsh.processor.term; 002 003 import org.crsh.plugin.CRaSHPlugin; 004 import org.crsh.shell.impl.async.AsyncShell; 005 import org.crsh.shell.impl.command.CRaSH; 006 import org.crsh.shell.impl.command.CRaSHSession; 007 import org.crsh.term.BaseTerm; 008 import org.crsh.term.spi.TermIO; 009 import org.crsh.term.spi.TermIOHandler; 010 011 import java.security.Principal; 012 013 /** 014 * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a> 015 */ 016 public class ProcessorIOHandler extends CRaSHPlugin<TermIOHandler> implements TermIOHandler { 017 018 /** . */ 019 private CRaSH crash; 020 021 @Override 022 public TermIOHandler getImplementation() { 023 return this; 024 } 025 026 @Override 027 public void init() { 028 this.crash = new CRaSH(getContext()); 029 } 030 031 @Override 032 public void destroy() { 033 } 034 035 public void handle(final TermIO io, Principal user) { 036 CRaSHSession shell = crash.createSession(user); 037 AsyncShell asyncShell = new AsyncShell(getContext().getExecutor(), shell); 038 BaseTerm term = new BaseTerm(io); 039 Processor processor = new Processor(term, asyncShell); 040 processor.addListener(io); 041 processor.addListener(asyncShell); 042 processor.addListener(shell); 043 processor.run(); 044 } 045 }