Example usage for org.apache.shiro.concurrent SubjectAwareExecutorService SubjectAwareExecutorService

List of usage examples for org.apache.shiro.concurrent SubjectAwareExecutorService SubjectAwareExecutorService

Introduction

In this page you can find the example usage for org.apache.shiro.concurrent SubjectAwareExecutorService SubjectAwareExecutorService.

Prototype

public SubjectAwareExecutorService(ExecutorService target) 

Source Link

Usage

From source file:org.openengsb.core.security.SecurityContext.java

License:Apache License

/**
 * Wrap the given executor so that it takes authentication-information and context are inherited to tasks when they
 * are submitted./*from www  .ja v  a2  s. co  m*/
 */
public static ExecutorService getSecurityContextAwareExecutor(ExecutorService original) {
    SubjectAwareExecutorService subjectAwareExecutor = new SubjectAwareExecutorService(original);
    return ThreadLocalUtil.contextAwareExecutor(subjectAwareExecutor);
}

From source file:org.seedstack.seed.shell.internal.InteractiveShell.java

License:Mozilla Public License

@Override
public void start(Environment environment) throws IOException {
    errorPrintStream = new PrintStream(errorStream, true);

    String user = environment.getEnv().get(Environment.ENV_USER);

    if (Strings.isNullOrEmpty(user)) {
        user = "unknown";
    }/*from   www. j  av  a  2  s  .  c o m*/
    try {
        // Use our RemoteTerminal which does not depends on the platform.
        terminal = new RemoteTerminal(true);
        terminal.init();
    } catch (Exception e) {
        LOGGER.warn("Error during terminal detection, falling back to unsupported terminal");
        LOGGER.debug(DETAILS_MESSAGE, e);
        terminal = new UnsupportedTerminal();
    }

    consoleReader = new ConsoleReader(inputStream, outputStream, terminal);
    // Disable jline shutdownhook to avoid exception at application shutdown
    jline.internal.Configuration.getString("jline.shutdownhook", "false");

    consoleReader.addCompleter(new StringsCompleter(commandRegistry.getCommandList()));
    consoleReader.setCompletionHandler(new CandidateListCompletionHandler());
    consoleReader.setPrompt(user + "@" + application.getId() + "$ ");
    consoleReader.setHandleUserInterrupt(false);
    consoleReader.setHistoryEnabled(true);

    ses = new SubjectAwareExecutorService(Executors.newSingleThreadExecutor());
    ses.submit(this);
}

From source file:org.seedstack.seed.shell.internal.NonInteractiveShell.java

License:Mozilla Public License

@Override
public void start(Environment env) throws IOException {
    outputPrintStream = new PrintStream(outputStream, true);
    errorPrintStream = new PrintStream(errorStream, true);

    ses = new SubjectAwareExecutorService(Executors.newSingleThreadExecutor());
    ses.submit(this);
}

From source file:org.seedstack.shell.internal.InteractiveShell.java

License:Mozilla Public License

@Override
public void start(Environment environment) throws IOException {
    errorPrintStream = new PrintStream(errorStream, true, UTF_8);

    String user = environment.getEnv().get(Environment.ENV_USER);

    if (Strings.isNullOrEmpty(user)) {
        user = "unknown";
    }/*from  w ww.ja v a 2s  .  c om*/
    try {
        // Use our RemoteTerminal which does not depends on the platform.
        terminal = new RemoteTerminal(true);
        terminal.init();
    } catch (Exception e) {
        LOGGER.warn("Error during terminal detection, falling back to unsupported terminal");
        LOGGER.debug(DETAILS_MESSAGE, e);
        terminal = new UnsupportedTerminal();
    }

    consoleReader = new ConsoleReader(inputStream, outputStream, terminal);
    // Disable jline shutdownhook to avoid exception at application shutdown
    jline.internal.Configuration.getString("jline.shutdownhook", "false");

    consoleReader.addCompleter(new StringsCompleter(commandRegistry.getCommandList()));
    consoleReader.setCompletionHandler(new CandidateListCompletionHandler());
    consoleReader.setPrompt(user + "@" + application.getId() + "$ ");
    consoleReader.setHandleUserInterrupt(false);
    consoleReader.setHistoryEnabled(true);

    ses = new SubjectAwareExecutorService(Executors.newSingleThreadExecutor());
    ses.submit(this);
}

From source file:org.seedstack.shell.internal.NonInteractiveShell.java

License:Mozilla Public License

@Override
public void start(Environment env) throws IOException {
    outputPrintStream = new PrintStream(outputStream, true, UTF_8);
    errorPrintStream = new PrintStream(errorStream, true, UTF_8);

    ses = new SubjectAwareExecutorService(Executors.newSingleThreadExecutor());
    ses.submit(this);
}