本文整理汇总了Java中org.eclipse.jetty.servlet.ServletHandler.addServletWithMapping方法的典型用法代码示例。如果您正苦于以下问题:Java ServletHandler.addServletWithMapping方法的具体用法?Java ServletHandler.addServletWithMapping怎么用?Java ServletHandler.addServletWithMapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.servlet.ServletHandler
的用法示例。
在下文中一共展示了ServletHandler.addServletWithMapping方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
initWeixin();
Server server = new Server(8080);
ServletHandler servletHandler = new ServletHandler();
server.setHandler(servletHandler);
ServletHolder endpointServletHolder = new ServletHolder(new WxCpEndpointServlet(wxCpConfigStorage, wxCpService, wxCpMessageRouter));
servletHandler.addServletWithMapping(endpointServletHolder, "/*");
ServletHolder oauthServletHolder = new ServletHolder(new WxCpOAuth2Servlet(wxCpService));
servletHandler.addServletWithMapping(oauthServletHolder, "/oauth2/*");
server.start();
server.join();
}
示例2: startInJvmProxy
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
/**
* To test that the CF client is able to go through a proxy, we point the CC client to a broken url that can only be resolved by going
* through an inJVM proxy which rewrites the URI. This method starts this inJvm proxy.
*
* @throws Exception
*/
private static void startInJvmProxy() throws Exception {
inJvmProxyPort = getNextAvailablePort(8080);
inJvmProxyServer = new Server(new InetSocketAddress("127.0.0.1", inJvmProxyPort)); // forcing use of loopback
// that will be used both for Httpclient proxy and SocketDestHelper
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMinThreads(1);
inJvmProxyServer.setThreadPool(threadPool);
HandlerCollection handlers = new HandlerCollection();
inJvmProxyServer.setHandler(handlers);
ServletHandler servletHandler = new ServletHandler();
handlers.addHandler(servletHandler);
nbInJvmProxyRcvReqs = new AtomicInteger();
ChainedProxyServlet chainedProxyServlet = new ChainedProxyServlet(httpProxyConfiguration, nbInJvmProxyRcvReqs);
servletHandler.addServletWithMapping(new ServletHolder(chainedProxyServlet), "/*");
// Setup proxy handler to handle CONNECT methods
ConnectHandler proxyHandler;
proxyHandler = new ChainedProxyConnectHandler(httpProxyConfiguration, nbInJvmProxyRcvReqs);
handlers.addHandler(proxyHandler);
inJvmProxyServer.start();
}
示例3: run
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void run() {
try {
this.server = new Server(this.serverPort);
ServletHandler servletHandler = new ServletHandler();
servletHandler.addServletWithMapping(TaskTrackerServlet.class, "/tracker");
this.server.setHandler(servletHandler);
this.server.start();
this.server.join();
} catch (Exception ex) {
// suppress
}
}
示例4: main
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
initWeixin();
Server server = new Server(8080);
ServletHandler servletHandler = new ServletHandler();
server.setHandler(servletHandler);
ServletHolder endpointServletHolder = new ServletHolder(
new WxMpEndpointServlet(wxMpConfigStorage, wxMpService,
wxMpMessageRouter));
servletHandler.addServletWithMapping(endpointServletHolder, "/*");
ServletHolder oauthServletHolder = new ServletHolder(
new WxMpOAuth2Servlet(wxMpService));
servletHandler.addServletWithMapping(oauthServletHolder, "/oauth2/*");
server.start();
server.join();
}
示例5: getAllServices
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
private HandlerList getAllServices() throws Exception{
// File server & Context Handler for root, also setting the index.html
// to be the "welcome file", i.e, autolink on root addresses.
ContextHandler rootContext = new ContextHandler();
rootContext.setContextPath("/*");
rootContext.setHandler(getResourceHandlers());
// Possible servlet lists, for all servlets or custom services you want to access later.
// Warning, it might become a little bit nested if you add to many classes.
ServletHandler questionHandler = new ServletHandler();
questionHandler.addServletWithMapping(QuestionHandler.class, "/question");
// Add the ResourceHandler to the server.
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] {
rootContext ,
questionHandler,
});
return handlers;
}
示例6: createServer
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
private Server createServer() {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8384);
server.addConnector(connector);
ServletHandler handler = new ServletHandler();
Servlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String path = req.getServletPath().substring(1);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
resp.getWriter().append(path);
}
};
handler.addServletWithMapping(new ServletHolder(servlet), "/");
server.setHandler(handler);
return server;
}
示例7: init
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
@PostConstruct
private void init()
{
internal = new Server();
ServletHandler servletHandler = new ServletHandler();
KasijeServlet servlet = context.find(KasijeServlet.class);
ServletHolder servletHolder = new ServletHolder("kasije", servlet);
servletHandler.addServletWithMapping(servletHolder, "/*");
internal.setHandler(servletHandler);
ConfigProvider configProv = context.find(ConfigProvider.class);
ServerConfig config = configProv.getServerConfig();
if (null == config || null == config.getConnectors() || config.getConnectors().isEmpty())
{
internal.addConnector(createConnector(null));
}
else
{
for (Connector connectorConfig : config.getConnectors())
{
internal.addConnector(createConnector(connectorConfig));
}
}
}
示例8: createReverseProxy
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
private ServletHandler createReverseProxy(ProxyMap proxyMap) {
AsyncProxyServlet servlet = new ReverseProxy(proxyMap);
ServletHolder proxyServletHolder = new ServletHolder(servlet);
proxyServletHolder.setAsyncSupported(true);
proxyServletHolder.setInitParameter("maxThreads", "256");
proxyServletHolder.setInitParameter("idleTimeout", String.valueOf(idleTimeout));
proxyServletHolder.setInitParameter("timeout", String.valueOf(totalTimeout));
ServletHandler proxyHandler = new ServletHandler();
proxyHandler.addServletWithMapping(proxyServletHolder, "/*");
return proxyHandler;
}
示例9: main
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
initWeixin();
Server server = new Server(8080);
ServletHandler servletHandler = new ServletHandler();
server.setHandler(servletHandler);
ServletHolder endpointServletHolder = new ServletHolder(
new WxMpEndpointServlet(wxMpConfigStorage, wxMpService,
wxMpMessageRouter));
servletHandler.addServletWithMapping(endpointServletHolder, "/*");
ServletHolder oauthServletHolder = new ServletHolder(
new WxMpOAuth2Servlet(wxMpService));
servletHandler.addServletWithMapping(oauthServletHolder, "/oauth2/*");
server.start();
server.join();
}
示例10: LfsServer
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
/**
* Ctor.
* @param path Server path.
* @param storage Storage container.
* @param port Server port
*/
LfsServer(final String path, final ContentManager storage,
final int port) {
this.server = new Server();
this.http =
new ServerConnector(this.server, new HttpConnectionFactory());
this.http.setPort(port);
// @checkstyle MagicNumber (1 line)
this.http.setIdleTimeout(30000);
this.server.addConnector(this.http);
final ServletHandler handler = new ServletHandler();
this.server.setHandler(handler);
handler.addServletWithMapping(
new ServletHolder(
new PointerServlet(
storage, String.format("%s/info/lfs/storage/", path)
)
),
String.format("%s/info/lfs/objects/*", path)
);
handler.addServletWithMapping(
new ServletHolder(new ContentServlet(storage)),
String.format("%s/info/lfs/storage/*", path)
);
}
示例11: beforeClass
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
ResourceProvider patientProvider = new ResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
RestfulServer servlet = new RestfulServer();
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
ourServer.setHandler(proxyHandler);
ourServer.start();
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
HttpClientBuilder builder = HttpClientBuilder.create();
builder.setConnectionManager(connectionManager);
ourClient = builder.build();
}
示例12: beforeClass
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
RestfulServer servlet = new RestfulServer();
servlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
ourServer.setHandler(proxyHandler);
ourServer.start();
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
HttpClientBuilder builder = HttpClientBuilder.create();
builder.setConnectionManager(connectionManager);
ourClient = builder.build();
}
示例13: beforeClass
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
servlet = new RestfulServer();
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
ourServer.setHandler(proxyHandler);
ourServer.start();
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
HttpClientBuilder builder = HttpClientBuilder.create();
builder.setConnectionManager(connectionManager);
ourClient = builder.build();
}
示例14: beforeClass
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
DummyPlainProvider plainProvider = new DummyPlainProvider();
DummyResourceProvider patientProvider = new DummyResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
RestfulServer servlet = new RestfulServer();
servlet.setPlainProviders(plainProvider);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
ourServer.setHandler(proxyHandler);
ourServer.start();
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
HttpClientBuilder builder = HttpClientBuilder.create();
builder.setConnectionManager(connectionManager);
ourClient = builder.build();
}
示例15: beforeClass
import org.eclipse.jetty.servlet.ServletHandler; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
ServletHandler proxyHandler = new ServletHandler();
ourServlet = new RestfulServer();
ourServlet.setFhirContext(ourCtx);
ourServlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
ServletHolder servletHolder = new ServletHolder(ourServlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
ourServer.setHandler(proxyHandler);
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
HttpClientBuilder builder = HttpClientBuilder.create();
builder.setConnectionManager(connectionManager);
ourClient = builder.build();
}