try {
URI uri = wsSession.getRequestURI();
String path = uri.getPath();
log.fine("Establishing session for " + path);
String contextPath = path.substring(0, path.lastIndexOf('/'));
PluginContext context = WebPluginLifeCycle.getPluginContext(contextPath);
if (context != null) {
Boolean enabled = context.getProperty(WebPlugin.ENABLED);
if (enabled != null && enabled) {
log.fine("Using shell " + context);
ShellFactory factory = context.getPlugin(ShellFactory.class);
Principal user = wsSession.getUserPrincipal();
Shell shell = factory.create(user);
CRaSHSession session = new CRaSHSession(wsSession, shell);
sessions.put(wsSession.getId(), session);
log.fine("Established session " + wsSession.getId());