本文整理了Java中org.mortbay.jetty.Server.<init>()
方法的一些代码示例,展示了Server.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.<init>()
方法的具体详情如下:
包路径:org.mortbay.jetty.Server
类名称:Server
方法名:<init>
[英]Convenience constructor Creates server and a SocketConnector at the passed port.
[中]便利构造函数在传递的端口创建服务器和SocketConnector。
代码示例来源:origin: ltsopensource/light-task-scheduler
Server server = new Server(Integer.parseInt(port));
WebAppContext webapp = new WebAppContext();
webapp.setWar(confPath + "/war/lts-admin.war");
代码示例来源:origin: azkaban/azkaban
@Override
public Server get() {
requireNonNull(this.props);
final int maxThreads = this.props
.getInt("jetty.maxThreads", Constants.DEFAULT_JETTY_MAX_THREAD_COUNT);
final boolean useSsl = this.props.getBoolean("jetty.use.ssl", true);
final int port;
final Server server = new Server();
if (useSsl) {
final int sslPortNumber = this.props
.getInt("jetty.ssl.port", Constants.DEFAULT_SSL_PORT_NUMBER);
port = sslPortNumber;
server.addConnector(getSslSocketConnector(sslPortNumber));
} else {
port = this.props.getInt("jetty.port", Constants.DEFAULT_PORT_NUMBER);
server.addConnector(getSocketConnector(port));
}
// setting stats configuration for connectors
setStatsOnConnectors(server);
logger.info(String.format(
"Starting %sserver on port: %d # Max threads: %d", useSsl ? "SSL " : "", port, maxThreads));
return server;
}
代码示例来源:origin: pentaho/pentaho-kettle
public String getRedirectUri() throws IOException {
if ( this.port == -1 ) {
this.port = getUnusedPort();
}
this.server = new Server( this.port );
Connector[] arr$ = this.server.getConnectors();
int len$ = arr$.length;
for ( int i$ = 0; i$ < len$; ++i$ ) {
Connector c = arr$[i$];
c.setHost( this.host );
}
this.server.addHandler( new CustomLocalServerReceiver.CallbackHandler() );
try {
this.server.start();
} catch ( Exception var5 ) {
Throwables.propagateIfPossible( var5 );
throw new IOException( var5 );
}
return "http://" + this.host + ":" + this.port + "/Callback/success.html";
}
代码示例来源:origin: tjake/Solandra
public JettySolandraRunner( String context, int port, String host)
{
this.context = context;
server = new Server( port );
server.getConnectors()[0].setHost(host);
server.setStopAtShutdown( true );
// Initialize the servlets
Context root = new Context( server, context, Context.SESSIONS );
// for some reason, there must be a servlet for this to get applied
root.addServlet( Servlet404.class, "/*" );
dispatchFilter = root.addFilter( SolandraDispatchFilter.class, "*", Handler.REQUEST );
}
代码示例来源:origin: twitter/ambrose
server = new Server();
server.setConnectors(new Connector[]{connector});
代码示例来源:origin: Netflix/eureka
public MockRemoteEurekaServer(int port, Map<String, Application> applicationMap,
Map<String, Application> applicationDeltaMap) {
this.applicationMap = applicationMap;
this.applicationDeltaMap = applicationDeltaMap;
ServletHandler handler = new AppsResourceHandler();
EurekaServerConfig serverConfig = new DefaultEurekaServerConfig();
EurekaServerContext serverContext = mock(EurekaServerContext.class);
when(serverContext.getServerConfig()).thenReturn(serverConfig);
handler.addFilterWithMapping(ServerRequestAuthFilter.class, "/*", 1).setFilter(new ServerRequestAuthFilter(serverContext));
handler.addFilterWithMapping(RateLimitingFilter.class, "/*", 1).setFilter(new RateLimitingFilter(serverContext));
server = new Server(port);
server.addHandler(handler);
System.out.println(String.format(
"Created eureka server mock with applications map %s and applications delta map %s",
stringifyAppMap(applicationMap), stringifyAppMap(applicationDeltaMap)));
}
代码示例来源:origin: Netflix/eureka
public void start() throws Exception {
server = new Server(port);
server.setHandler(new AppsResourceHandler());
server.start();
port = server.getConnectors()[0].getLocalPort();
}
代码示例来源:origin: testcontainers/testcontainers-java
@Before
public void setupLocalServer() throws Exception {
// Set up a local Jetty HTTP server
Server server = new Server();
server.addConnector(new SocketConnector());
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase("src/test/resources/server");
server.addHandler(resourceHandler);
server.start();
// The server will have a random port assigned, so capture that
localPort = server.getConnectors()[0].getLocalPort();
}
代码示例来源:origin: voldemort/voldemort
public static Context getJettyServer(String clusterXml,
String storesXml,
String storeName,
RequestFormatType requestFormat,
int port) throws Exception {
StoreRepository repository = getStores(storeName, clusterXml, storesXml);
// initialize servlet
Server server = new Server(port);
server.setSendServerVersion(false);
Context context = new Context(server, "/", Context.NO_SESSIONS);
RequestHandler handler = getSocketRequestHandlerFactory(clusterXml, storesXml, repository).getRequestHandler(requestFormat);
context.addServlet(new ServletHolder(new StoreServlet(handler)), "/stores");
server.start();
return context;
}
代码示例来源:origin: voldemort/voldemort
threadPool.setName("VoldemortHttp");
threadPool.setMaxThreads(this.numberOfThreads);
Server httpServer = new Server();
httpServer.setConnectors(new Connector[] { connector });
httpServer.setThreadPool(threadPool);
代码示例来源:origin: soabase/exhibitor
public ExhibitorMain(BackupProvider backupProvider, ConfigProvider configProvider, ExhibitorArguments.Builder builder, int httpPort, String listenAddress, SecurityHandler security, SecurityArguments securityArguments) throws Exception
{
HashUserRealm realm = makeRealm(securityArguments);
if ( securityArguments.getRemoteAuthSpec() != null )
{
addRemoteAuth(builder, securityArguments.getRemoteAuthSpec());
}
builder.shutdownProc(makeShutdownProc(this));
exhibitor = new Exhibitor(configProvider, null, backupProvider, builder.build());
exhibitor.start();
DefaultResourceConfig application = JerseySupport.newApplicationConfig(new UIContext(exhibitor));
ServletContainer container = new ServletContainer(application);
server = new Server();
SocketConnector http = new SocketConnector();
http.setHost(listenAddress);
http.setPort(httpPort);
server.addConnector(http);
Context root = new Context(server, "/", Context.SESSIONS);
root.addFilter(ExhibitorServletFilter.class, "/", Handler.ALL);
root.addServlet(new ServletHolder(container), "/*");
if ( security != null )
{
root.setSecurityHandler(security);
}
else if ( securityArguments.getSecurityFile() != null )
{
addSecurityFile(realm, securityArguments.getSecurityFile(), root);
}
}
代码示例来源:origin: rhuss/jolokia
private Server getServer(MuleAgentConfig pConfig) {
Server newServer = new Server();
Connector connector = new SelectChannelConnector();
if (pConfig.getHost() != null) {
connector.setHost(pConfig.getHost());
}
connector.setPort(pConfig.getPort());
newServer.setConnectors(new Connector[]{connector});
return newServer;
}
代码示例来源:origin: michel-kraemer/gradle-download-task
/**
* @return the HTTP server used for testing
*/
protected Server createServer() {
//run server on any free port
return new Server(0);
}
代码示例来源:origin: org.apache.avro/avro-ipc
/** Constructs a server to run with the given connector. */
public HttpServer(ResponderServlet servlet, Connector connector) throws IOException {
this.server = new org.mortbay.jetty.Server();
server.addConnector(connector);
new Context(server, "/").addServlet(new ServletHolder(servlet), "/*");
}
代码示例来源:origin: michel-kraemer/gradle-download-task
@Override
protected Server createServer() {
Server server = new Server();
SslSocketConnector connector = new SslSocketConnector();
connector.setKeystore(this.getClass().getResource("/keystore").toString());
connector.setKeyPassword("gradle");
//run server on any free port
connector.setPort(0);
server.setConnectors(new Connector[] { connector });
return server;
}
代码示例来源:origin: org.seleniumhq.selenium.grid/selenium-grid-webserver
protected void createHttpServer() {
final ContextHandlerCollection contexts;
final ServletHolder servletHolder;
final Context root;
httpServer = new Server(port);
contexts = new ContextHandlerCollection();
httpServer.setHandler(contexts);
root = new Context(contexts, "/", Context.SESSIONS);
servletHolder = new ServletHolder(new MainServlet());
servletHolder.setInitParameter("route_resolver", routeResolverClass().getName());
root.addServlet(servletHolder, "/*");
}
代码示例来源:origin: org.mortbay.jetty/jetty-embedded
public static void main(String[] args)
throws Exception
{
Server server = new Server();
Connector connector=new SocketConnector();
connector.setPort(8080);
server.setConnectors(new Connector[]{connector});
Handler handler=new HelloHandler();
server.setHandler(handler);
server.start();
server.join();
}
代码示例来源:origin: org.apache.axis2/axis2-transport-testkit
@Setup @SuppressWarnings("unused")
private void setUp(HttpTestEnvironment env) throws Exception {
server = new Server();
SocketListener listener = new SocketListener();
listener.setPort(env.getServerPort());
server.addListener(listener);
context = new HttpContext(server, Channel.CONTEXT_PATH + "/*");
server.start();
}
代码示例来源:origin: org.testatoo.openqa/selenium-server
protected void createJettyServer(boolean slowResources) {
final SocketListener socketListener;
server = new Server();
socketListener = new SocketListener();
socketListener.setMaxIdleTimeMs(60000);
socketListener.setMaxThreads(jettyThreads);
socketListener.setPort(getPort());
server.addListener(socketListener);
assembleHandlers(slowResources, configuration);
}
代码示例来源:origin: org.apache.avro/avro-ipc
public StatsServer(StatsPlugin plugin, int port) throws Exception {
this.httpServer = new Server(port);
this.plugin = plugin;
Context staticContext = new Context(httpServer, "/static");
staticContext.addServlet(new ServletHolder(new StaticServlet()), "/");
Context context = new Context(httpServer, "/");
context.addServlet(new ServletHolder(new StatsServlet(plugin)), "/");
httpServer.start();
}
内容来源于网络,如有侵权,请联系作者删除!