本文整理汇总了Java中org.mortbay.jetty.servlet.Context.addEventListener方法的典型用法代码示例。如果您正苦于以下问题:Java Context.addEventListener方法的具体用法?Java Context.addEventListener怎么用?Java Context.addEventListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.servlet.Context
的用法示例。
在下文中一共展示了Context.addEventListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startServer
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
private static void startServer() throws Exception, InterruptedException {
Server server = new Server(port);
Context context = new Context(server, "/", Context.SESSIONS);
context.addServlet(DefaultServlet.class, "/*");
context.addEventListener(new ContextLoaderListener(getContext()));
context.addEventListener(new RequestContextListener());
WicketFilter filter = new WicketFilter();
filter.setFilterPath("/");
FilterHolder holder = new FilterHolder(filter);
holder.setInitParameter("applicationFactoryClassName", APP_FACTORY_NAME);
context.addFilter(holder, "/*", Handler.DEFAULT);
server.setHandler(context);
server.start();
server.join();
}
示例2: addFilters
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
protected void addFilters(Context context) throws ClassNotFoundException, NoSuchMethodException,
InstantiationException, IllegalAccessException, InvocationTargetException {
context.addFilter(XdServletFilter.class, "/*", Handler.DEFAULT);
context.addFilter(MethodOverrideServletFilter.class, "/*", Handler.DEFAULT);
if (FlagConfig.enableAuth_FLAG.equalsIgnoreCase("true")) {
ServletHolder servletHolder2 = new ServletHolder(new GetAuthTokenServlet());
context.addServlet(servletHolder2, "/accounts/ClientLogin");
context.addFilter(SignedRequestFilter.class, "/*", org.mortbay.jetty.Handler.DEFAULT);
EventListener listener = new GuiceServletContextListener();
context.addEventListener(listener);
logger.info("FeedServer to accept signed requests");
} else if (!FlagConfig.enableOAuthSignedFetch_FLAG.equalsIgnoreCase("false")) {
// Register the OAuth filter
SimpleKeyMananger sKeyManager = new SimpleKeyMananger();
Filter oauthFilter =
createOAuthFilter(FlagConfig.enableOAuthSignedFetch_FLAG.equalsIgnoreCase("true") ?
FlagConfig.OAUTH_SIGNED_FETCH_FILTER_CLASS_NAME :
FlagConfig.enableOAuthSignedFetch_FLAG, sKeyManager);
context.addFilter(new FilterHolder(oauthFilter), "/*", org.mortbay.jetty.Handler.DEFAULT);
logger.info("FeedServer to accept OAuth signed requests");
}
}
示例3: setup
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
@BeforeMethod
public void setup() throws Exception
{
RestEasyApplication.singletonsRef.set(new RestEasySingletons());
ResteasyProviderFactory.setInstance(new ResteasyProviderFactory());
HttpServletDispatcher dispatcher = new HttpServletDispatcher();
port = InstanceSpec.getRandomPort();
server = new Server(port);
Context root = new Context(server, "/", Context.SESSIONS);
root.getInitParams().put("javax.ws.rs.Application", RestEasyApplication.class.getName());
root.addServlet(new ServletHolder(dispatcher), "/*");
root.addEventListener(new ResteasyBootstrap());
server.start();
}
示例4: EmbeddedWebServer
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
@VisibleForTesting EmbeddedWebServer(Server server, Context context) {
this.server = server;
context.addFilter(GuiceFilter.class, "/*", 0);
context.addServlet(DefaultServlet.class, "/");
context.addEventListener(new GuiceServletConfig());
context.addEventListener(new ServiceRegistryServletContextListener());
}
示例5: runJetty
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
public static Server runJetty(String[] args) throws Exception {
boolean configureOAuthFilter = false;
boolean signedRequest = false;
String oauthFilterClassName = SimpleOAuthFilter.class.getName();
// Check if the OAuth filter flag has been given as command line input
if (args != null) {
for (int i = 0; i < args.length; i++) {
if (args[i].startsWith("authenticated")) {
String signedRequests = args[i].substring(args[i].indexOf("=") + 1);
if (signedRequests.equalsIgnoreCase("true")) {
signedRequest = true;
}
} else if (args[i].startsWith("OAuth_authenticated")) {
String oauthFilter = args[i].substring(args[i].indexOf("=") + 1);
if (oauthFilter.equalsIgnoreCase("true")) {
configureOAuthFilter = true;
}
} else if (args[i].startsWith("oauthFilterClass")) {
oauthFilterClassName = args[i].substring(args[i].indexOf("=") + 1);
}
}
}
SampleFileSystemFeedConfigStore feedConfigStore = new SampleFileSystemFeedConfigStore();
log.info("Created a file store");
FeedServerConfiguration config = FeedServerConfiguration.createIntance(feedConfigStore);
config.setAclValidator(new AllowAllAclValidator());
config.initialize(new SimpleCommandLineParser(args));
config.setWrapperManagerClassName("com.google.feedserver.samples.manager.XmlWrapperManager");
// set up server
Server server = new Server(config.getPort());
Context context = new Context(server, "/", Context.SESSIONS);
// Add the Abdera servlet
ServletHolder servletHolder = new ServletHolder(new AbderaServlet());
servletHolder.setInitParameter(ServiceManager.PROVIDER, FeedServerProvider.class.getName());
context.addServlet(servletHolder, "/*");
// Register the filters
context.addFilter(XdServletFilter.class, "/*", Handler.DEFAULT);
context.addFilter(MethodOverrideServletFilter.class, "/*", Handler.DEFAULT);
if (signedRequest) {
ServletHolder servletHolder2 = new ServletHolder(new GetAuthTokenServlet());
context.addServlet(servletHolder2, "/accounts/ClientLogin");
context.addFilter(SignedRequestFilter.class, "/*", org.mortbay.jetty.Handler.DEFAULT);
EventListener listener = new GuiceServletContextListener();
context.addEventListener(listener);
log.info("Starting the feedserver to accept signed requests");
} else if (configureOAuthFilter) {
// Register the OAuth filter
SimpleKeyMananger sKeyManager = new SimpleKeyMananger();
Filter of = createOAuthFilter(oauthFilterClassName, sKeyManager);
FilterHolder fh = new FilterHolder(of);
context.addFilter(fh, "/*", org.mortbay.jetty.Handler.DEFAULT);
log.info("Starting the feedserver to accept OAuth signed requests");
}
// start server
server.start();
return server;
}