use of org.eclipse.jetty.server.ServerConnector in project jetty.project by eclipse.
the class AbstractTest method prepareServer.
protected void prepareServer(ConnectionFactory connectionFactory) {
QueuedThreadPool serverExecutor = new QueuedThreadPool();
serverExecutor.setName("server");
server = new Server(serverExecutor);
connector = new ServerConnector(server, 1, 1, connectionFactory);
server.addConnector(connector);
}
use of org.eclipse.jetty.server.ServerConnector in project jetty.project by eclipse.
the class OverlayServer method main.
public static void main(String[] args) throws Exception {
// NamingUtil.__log.setDebugEnabled(true);
String jetty_home = System.getProperty("jetty.home", "target/test-classes/home");
System.setProperty("jetty.home", jetty_home);
Server server = new Server();
server.setAttribute("org.eclipse.jetty.webapp.configuration", new String[] { org.eclipse.jetty.webapp.WebInfConfiguration.class.getCanonicalName(), org.eclipse.jetty.webapp.WebXmlConfiguration.class.getCanonicalName(), org.eclipse.jetty.webapp.MetaInfConfiguration.class.getCanonicalName(), org.eclipse.jetty.webapp.FragmentConfiguration.class.getCanonicalName(), org.eclipse.jetty.plus.webapp.EnvConfiguration.class.getCanonicalName(), org.eclipse.jetty.plus.webapp.PlusConfiguration.class.getCanonicalName(), org.eclipse.jetty.webapp.JettyWebXmlConfiguration.class.getCanonicalName() });
// Setup Connectors
ServerConnector connector = new ServerConnector(server);
connector.setPort(8080);
server.addConnector(connector);
HandlerCollection handlers = new HandlerCollection();
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLogHandler requestLogHandler = new RequestLogHandler();
handlers.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
StatisticsHandler stats = new StatisticsHandler();
stats.setHandler(handlers);
server.setHandler(stats);
// Setup deployers
DeploymentManager deployer = new DeploymentManager();
deployer.setContexts(contexts);
server.addBean(deployer);
OverlayedAppProvider provider = new OverlayedAppProvider();
provider.setNodeName("nodeA");
provider.setScanDir(new File(jetty_home + "/overlays"));
provider.setScanInterval(2);
deployer.addAppProvider(provider);
server.setStopAtShutdown(true);
//server.setSendServerVersion(true);
// Uncomment to work with JNDI examples
// new org.eclipse.jetty.plus.jndi.Transaction(new com.atomikos.icatch.jta.UserTransactionImp());
server.start();
server.join();
}
use of org.eclipse.jetty.server.ServerConnector in project jetty.project by eclipse.
the class SSLAsyncIOServletTest method prepare.
public void prepare(HttpServlet servlet) throws Exception {
server = new Server();
connector = new ServerConnector(server, sslContextFactory);
server.addConnector(connector);
contextPath = "/context";
ServletContextHandler context = new ServletContextHandler(server, contextPath, true, false);
servletPath = "/servlet";
context.addServlet(new ServletHolder(servlet), servletPath);
server.start();
}
use of org.eclipse.jetty.server.ServerConnector in project jetty.project by eclipse.
the class AsyncServletIOTest method setUp.
@Before
public void setUp() throws Exception {
HttpConfiguration http_config = new HttpConfiguration();
http_config.setOutputBufferSize(4096);
_connector = new ServerConnector(_server, new HttpConnectionFactory(http_config));
_server.setConnectors(new Connector[] { _connector });
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/ctx");
context.addEventListener(new DebugListener());
_server.setHandler(context);
_servletHandler = context.getServletHandler();
ServletHolder holder = new ServletHolder(_servlet0);
holder.setAsyncSupported(true);
_servletHandler.addServletWithMapping(holder, "/path/*");
ServletHolder holder2 = new ServletHolder(_servlet2);
holder2.setAsyncSupported(true);
_servletHandler.addServletWithMapping(holder2, "/path2/*");
ServletHolder holder3 = new ServletHolder(_servlet3);
holder3.setAsyncSupported(true);
_servletHandler.addServletWithMapping(holder3, "/path3/*");
ServletHolder holder4 = new ServletHolder(_servlet4);
holder4.setAsyncSupported(true);
_servletHandler.addServletWithMapping(holder4, "/path4/*");
_server.start();
_port = _connector.getLocalPort();
_owp.set(0);
_oda.set(0);
_read.set(0);
}
use of org.eclipse.jetty.server.ServerConnector in project jetty.project by eclipse.
the class AsyncServletTest method setUp.
@Before
public void setUp() throws Exception {
_connector = new ServerConnector(_server);
_server.setConnectors(new Connector[] { _connector });
_log = new ArrayList<>();
RequestLog log = new Log();
RequestLogHandler logHandler = new RequestLogHandler();
logHandler.setRequestLog(log);
_server.setHandler(logHandler);
_expectedLogs = 1;
_expectedCode = "200 ";
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
context.setContextPath("/ctx");
logHandler.setHandler(context);
context.addEventListener(new DebugListener());
_errorHandler = new ErrorPageErrorHandler();
context.setErrorHandler(_errorHandler);
_errorHandler.addErrorPage(300, 599, "/error/custom");
_servletHandler = context.getServletHandler();
ServletHolder holder = new ServletHolder(_servlet);
holder.setAsyncSupported(true);
_servletHandler.addServletWithMapping(holder, "/error/*");
_servletHandler.addServletWithMapping(holder, "/path/*");
_servletHandler.addServletWithMapping(holder, "/path1/*");
_servletHandler.addServletWithMapping(holder, "/path2/*");
_servletHandler.addServletWithMapping(holder, "/p th3/*");
_servletHandler.addServletWithMapping(new ServletHolder(new FwdServlet()), "/fwd/*");
ServletHolder holder2 = new ServletHolder("NoAsync", _servlet);
holder2.setAsyncSupported(false);
_servletHandler.addServletWithMapping(holder2, "/noasync/*");
_server.start();
_port = _connector.getLocalPort();
__history.clear();
__latch = new CountDownLatch(1);
}
Aggregations