本文整理汇总了Java中org.mortbay.jetty.servlet.Context.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Context.setAttribute方法的具体用法?Java Context.setAttribute怎么用?Java Context.setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.servlet.Context
的用法示例。
在下文中一共展示了Context.setAttribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExternalDelegationTokenSecretManager
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
@Test
public void testExternalDelegationTokenSecretManager() throws Exception {
DummyDelegationTokenSecretManager secretMgr
= new DummyDelegationTokenSecretManager();
final Server jetty = createJettyServer();
Context context = new Context();
context.setContextPath("/foo");
jetty.setHandler(context);
context.addFilter(new FilterHolder(AFilter.class), "/*", 0);
context.addServlet(new ServletHolder(PingServlet.class), "/bar");
try {
secretMgr.startThreads();
context.setAttribute(DelegationTokenAuthenticationFilter.
DELEGATION_TOKEN_SECRET_MANAGER_ATTR, secretMgr);
jetty.start();
URL authURL = new URL(getJettyURL() + "/foo/bar?authenticated=foo");
DelegationTokenAuthenticatedURL.Token token =
new DelegationTokenAuthenticatedURL.Token();
DelegationTokenAuthenticatedURL aUrl =
new DelegationTokenAuthenticatedURL();
aUrl.getDelegationToken(authURL, token, FOO_USER);
Assert.assertNotNull(token.getDelegationToken());
Assert.assertEquals(new Text("fooKind"),
token.getDelegationToken().getKind());
} finally {
jetty.stop();
secretMgr.stopThreads();
}
}
示例2: main
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
* Sets up and runs server.
* @param args
*/
public static void main(String[] args)
{
final Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
Context htmlContext = new Context(server, "/", Context.SESSIONS);
ResourceHandler htmlHandler = new ResourceHandler();
htmlHandler.setResourceBase("web");
htmlContext.setHandler(htmlHandler);
Context servletContext = new Context(server, "/", Context.SESSIONS);
GenericWebApplicationContext springContext = new GenericWebApplicationContext();
springContext.setParent(new ClassPathXmlApplicationContext("org/getahead/dwrdemo/cli/spring.xml"));
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, springContext);
ServletHolder holder = new ServletHolder(new DwrSpringServlet());
holder.setInitParameter("pollAndCometEnabled", "true");
holder.setInitParameter("debug", "true");
servletContext.addServlet(holder, "/dwr/*");
try
{
JettyShutdown.addShutdownHook(server);
server.start();
server.join();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
示例3: AzkabanExecutorServer
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
* Constructor
*
* @throws Exception
*/
public AzkabanExecutorServer(Props props) throws Exception {
this.props = props;
int portNumber = props.getInt("executor.port", DEFAULT_PORT_NUMBER);
int maxThreads = props.getInt("executor.maxThreads", DEFAULT_THREAD_NUMBER);
server = new Server(portNumber);
QueuedThreadPool httpThreadPool = new QueuedThreadPool(maxThreads);
server.setThreadPool(httpThreadPool);
boolean isStatsOn = props.getBoolean("executor.connector.stats", true);
logger.info("Setting up connector with stats on: " + isStatsOn);
for (Connector connector : server.getConnectors()) {
connector.setStatsOn(isStatsOn);
logger.info(String.format(
"Jetty connector name: %s, default header buffer size: %d",
connector.getName(), connector.getHeaderBufferSize()));
connector.setHeaderBufferSize(props.getInt("jetty.headerBufferSize",
DEFAULT_HEADER_BUFFER_SIZE));
logger.info(String.format(
"Jetty connector name: %s, (if) new header buffer size: %d",
connector.getName(), connector.getHeaderBufferSize()));
}
Context root = new Context(server, "/", Context.SESSIONS);
root.setMaxFormContentSize(MAX_FORM_CONTENT_SIZE);
root.addServlet(new ServletHolder(new ExecutorServlet()), "/executor");
root.addServlet(new ServletHolder(new JMXHttpServlet()), "/jmx");
root.addServlet(new ServletHolder(new StatsServlet()), "/stats");
root.addServlet(new ServletHolder(new ServerStatisticsServlet()), "/serverStatistics");
root.setAttribute(ServerConstants.AZKABAN_SERVLET_CONTEXT_KEY, this);
executionLoader = createExecLoader(props);
projectLoader = createProjectLoader(props);
runnerManager =
new FlowRunnerManager(props, executionLoader, projectLoader, this
.getClass().getClassLoader());
JmxJobMBeanManager.getInstance().initialize(props);
// make sure this happens before
configureJobCallback(props);
configureMBeanServer();
configureMetricReports();
SystemMemoryInfo.init(props.getInt("executor.memCheck.interval", 30));
loadCustomJMXAttributeProcessor(props);
try {
server.start();
} catch (Exception e) {
logger.warn(e);
Utils.croak(e.getMessage(), 1);
}
logger.info("Azkaban Executor Server started on port " + portNumber);
}
示例4: AzkabanExecutorServer
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
* Constructor
*
* @throws Exception
*/
public AzkabanExecutorServer(Props props) throws Exception {
this.props = props;
int portNumber = props.getInt("executor.port", DEFAULT_PORT_NUMBER);
int maxThreads = props.getInt("executor.maxThreads", DEFAULT_THREAD_NUMBER);
server = new Server(portNumber);
QueuedThreadPool httpThreadPool = new QueuedThreadPool(maxThreads);
server.setThreadPool(httpThreadPool);
Context root = new Context(server, "/", Context.SESSIONS);
root.setMaxFormContentSize(MAX_FORM_CONTENT_SIZE);
root.addServlet(new ServletHolder(new ExecutorServlet()), "/executor");
root.addServlet(new ServletHolder(new JMXHttpServlet()), "/jmx");
root.setAttribute(AzkabanServletContextListener.AZKABAN_SERVLET_CONTEXT_KEY, this);
executionLoader = createExecLoader(props);
projectLoader = createProjectLoader(props);
runnerManager = new FlowRunnerManager(props, executionLoader, projectLoader, this.getClass().getClassLoader());
String globalPropsPath = props.getString("executor.global.properties", null);
if (globalPropsPath == null) {
executorGlobalProps = new Props();
}
else {
executorGlobalProps = new Props(null, globalPropsPath);
}
runnerManager.setGlobalProps(executorGlobalProps);
configureMBeanServer();
try {
server.start();
}
catch (Exception e) {
logger.warn(e);
Utils.croak(e.getMessage(), 1);
}
logger.info("Azkaban Executor Server started on port " + portNumber);
}
示例5: setAttribute
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
* Set a value in the webapp context. These values are available to the jsp
* pages as "application.getAttribute(name)".
* @param context Context to add attribute
* @param name The name of the attribute
* @param value The value of the attribute
*/
public void setAttribute(Context context, String name, Object value) {
context.setAttribute(name, value);
}