本文整理匯總了Java中org.eclipse.jetty.server.Server.getConnectors方法的典型用法代碼示例。如果您正苦於以下問題:Java Server.getConnectors方法的具體用法?Java Server.getConnectors怎麽用?Java Server.getConnectors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.server.Server
的用法示例。
在下文中一共展示了Server.getConnectors方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: afterPropertiesSet
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public void afterPropertiesSet() throws Exception {
Resource configXml = Resource.newSystemResource(config);
XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
server = (Server) configuration.configure();
Integer port = getPort();
if (port != null && port > 0) {
Connector[] connectors = server.getConnectors();
for (Connector connector : connectors) {
connector.setPort(port);
}
}
Handler handler = server.getHandler();
if (handler != null && handler instanceof ServletContextHandler) {
ServletContextHandler servletHandler = (ServletContextHandler) handler;
servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", htdocsDir);
}
server.start();
if (logger.isInfoEnabled()) {
logger.info("##Jetty Embed Server is startup!");
}
}
示例2: main
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String args[]) throws Exception {
Resource jetty_xml = Resource.newSystemResource("jetty/jetty.xml");
XmlConfiguration configuration = new XmlConfiguration(jetty_xml.getInputStream());
Server server = (Server) configuration.configure();
int port = 8081;
Connector[] connectors = server.getConnectors();
for (Connector connector : connectors) {
connector.setPort(port);
}
Handler handler = server.getHandler();
if (handler != null && handler instanceof ServletContextHandler) {
ServletContextHandler servletHandler = (ServletContextHandler) handler;
servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", "/tmp/");
}
server.start();
server.join();
}
示例3: startServer
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
/**
* startUAVServer
*/
public void startServer(Object... args) {
Server server = (Server) args[0];
// integrate Tomcat log
UAVServer.instance().setLog(new JettyLog("MonitorServer"));
// start Monitor Server when server starts
UAVServer.instance().start(new Object[] { UAVServer.ServerVendor.JETTY });
// get server port
if (UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT) == null) {
// set port
ServerConnector sc = (ServerConnector) server.getConnectors()[0];
String protocol = sc.getDefaultProtocol();
if (protocol.toLowerCase().indexOf("http") >= 0) {
UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT, sc.getPort());
}
}
}
示例4: start
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
/**
* Starts the server. Returns immediately. May only be called once.
* @throws StartErrorException if there is a problem starting the server or this invocation of start is not the
* first.
*/
// we don't allow start to be called twice just because the HTTP listen port should still be in use from the
// first start call since we have no stop action currently.
void start() throws StartErrorException
{
_logger.debug("entering");
if(_startCalled)
{
_logger.debug("exiting");
throw new StartErrorException("Already started");
}
_startCalled = true;
/*
* Create and configure the HTTP server.
*/
Server server = new Server(_httpListenPort.AsInt);
{
// Pattern as per https://www.eclipse.org/jetty/documentation/9.4.x/embedding-jetty.html
ServletHandler handler = new ServletHandler();
server.setHandler(handler);
// register a servlet for performing apisynthesis
handler.addServletWithMapping(ApiSynthesisServlet.class, "/apisynthesis");
// register a servlet for collecting user feedback on result quatliy
handler.addServletWithMapping(ApiSynthesisResultQualityFeedbackServlet.class, "/apisynthesisfeedback");
// register a servlet for checking on the health of the entire apisynthesis process
handler.addServletWithMapping(ApiSynthesisHealthCheckServlet.class, "/apisynthesishealth");
/*
* Code completion requests are sent via POST to ApiSynthesisServlet, however,
* the site URL for the page that sends those POST requests can house that request body as a query parameter
* for bookmarking. That bookmarked URL then becomes the referrer of the POST request. As such there is a
* relationship between the required header buffer size for this server and the allowed body size.
*
* As such ensure that we can accept headers as large as our max body size.
*/
for (Connector c : server.getConnectors())
{
HttpConfiguration config = c.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
config.setRequestHeaderSize(_codeCompletionRequestBodyMaxBytesCount.AsInt);
}
}
/*
* Start the HTTP server.
*/
try
{
server.start(); // returns immediately
_logger.info("Started HTTP server on port " + _httpListenPort);
}
catch (Throwable e)
{
throw new StartErrorException(e);
}
_logger.debug("exiting");
}