org.mortbay.jetty.Server.setConnectors()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中org.mortbay.jetty.Server.setConnectors()方法的一些代码示例,展示了Server.setConnectors()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.setConnectors()方法的具体详情如下:
包路径:org.mortbay.jetty.Server
类名称:Server
方法名:setConnectors

Server.setConnectors介绍

[英]Set the connectors for this server. Each connector has this server set as it's ThreadPool and its Handler.
[中]

代码示例

代码示例来源:origin: twitter/ambrose

connector.setPort(port);
server = new Server();
server.setConnectors(new Connector[]{connector});

代码示例来源:origin: voldemort/voldemort

threadPool.setMaxThreads(this.numberOfThreads);
Server httpServer = new Server();
httpServer.setConnectors(new Connector[] { connector });
httpServer.setThreadPool(threadPool);
httpServer.setSendServerVersion(false);

代码示例来源: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: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

/**
 * Conveniance method which calls {@link #getConnectors()} and {@link #setConnectors(Connector[])} to 
 * remove a connector.
 * @param connector The connector to remove.
 */
public void removeConnector(Connector connector) {
  setConnectors((Connector[])LazyList.removeFromArray (getConnectors(), connector));
}

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

public void addConnector(Connector connector)
{
  setConnectors((Connector[])LazyList.addToArray(getConnectors(), connector, Connector.class));
}

代码示例来源:origin: net.disy.legato/legato-testing

public JettyWebServerEnvironment(final int port) {
 this.server = new Server();
 this.connector = new SelectChannelConnector();
 connector.setPort(port);
 this.server.setConnectors(new Connector[]{ connector });
 // this.webAppContext = new WebAppContext();
 // webAppContext.setContextPath(contextPath);
 // webAppContext.setConfigurationClasses(DEFAULT_CONFIGURATION_CLASSES);
 // webAppContext.setWar(location);
}

代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server

/** Convenience constructor
 * Creates server and a {@link SocketConnector} at the passed port.
 */
public Server(int port)
{
  setServer(this);
  Connector connector=new SocketConnector();
  connector.setPort(port);
  setConnectors(new Connector[]{connector});
}

代码示例来源:origin: org.mortbay.jetty/jetty-embedded

public static void main(String[] args)
    throws Exception
  {
    String jetty_default=new java.io.File("./start.jar").exists()?".":"../..";;
    String jetty_home = System.getProperty("jetty.home",jetty_default);

    Server server = new Server();
    
    Connector connector=new SelectChannelConnector();
    connector.setPort(Integer.getInteger("jetty.port",8080).intValue());
    server.setConnectors(new Connector[]{connector});
    
    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath("/");
    webapp.setWar(jetty_home+"/webapps/test");
    webapp.setDefaultsDescriptor(jetty_home+"/etc/webdefault.xml");
    
    server.setHandler(webapp);
    
    server.start();
    server.join();
  }
}

代码示例来源: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.jolokia/jolokia-mule

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: 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.mortbay.jetty/jetty-embedded

public static void main(String[] args)
throws Exception
{
  Server server = new Server();
  Connector connector=new SelectChannelConnector();
  connector.setPort(8080);
  server.setConnectors(new Connector[]{connector});
  
  ContextHandler context = new ContextHandler();
  context.setContextPath("/");
  context.setResourceBase(".");
  context.setClassLoader(Thread.currentThread().getContextClassLoader());
  server.setHandler(context);
  
  Handler handler=new HelloHandler();
  context.setHandler(handler);
  
  server.start();
  server.join();
}

代码示例来源: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});
  
  ServletHandler handler=new ServletHandler();
  server.setHandler(handler);
  
  handler.addServletWithMapping("org.mortbay.jetty.example.MinimalServlets$HelloServlet", "/");
  
  server.start();
  server.join();
}

代码示例来源:origin: performancecopilot/parfait

protected void run() {
  LOG.debug("Starting Server");
  server = new org.mortbay.jetty.Server();
  SelectChannelConnector connector = new SelectChannelConnector();
  connector.setPort(9080);
  server.setConnectors(new Connector[] { connector });
  WebAppContext webappcontext = new WebAppContext();
  String contextPath = null;
  try {
    contextPath = getClass().getResource(".").toURI().getPath();
  } catch (URISyntaxException e1) {
    e1.printStackTrace();
  }
  System.out.println(contextPath);
  webappcontext.setContextPath("/api");
  webappcontext.setWar(contextPath);
  HandlerCollection handlers = new HandlerCollection();
  handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
  server.setHandler(handlers);
  try {
    server.start();
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: org.mortbay.jetty/jetty-embedded

public static void main(String[] args)
  throws Exception
{
  Server server = new Server();
  Connector connector=new SelectChannelConnector();
  connector.setPort(8080);
  server.setConnectors(new Connector[]{connector});
  
  Handler param=new ParamHandler();
  Handler hello=new HelloHandler();
  
  HandlerCollection handlers = new HandlerCollection();
  handlers.setHandlers(new Handler[]{param,hello});
  server.setHandler(handlers);
  
  server.start();
  server.join();
}

代码示例来源:origin: ch.cern.hadoop/hadoop-kms

private static Server createJettyServer(String keyStore, String password, int inPort) {
 try {
  boolean ssl = keyStore != null;
  InetAddress localhost = InetAddress.getByName("localhost");
  String host = "localhost";
  ServerSocket ss = new ServerSocket((inPort < 0) ? 0 : inPort, 50, localhost);
  int port = ss.getLocalPort();
  ss.close();
  Server server = new Server(0);
  if (!ssl) {
   server.getConnectors()[0].setHost(host);
   server.getConnectors()[0].setPort(port);
  } else {
   SslSelectChannelConnector c = new SslSelectChannelConnectorSecure();
   c.setHost(host);
   c.setPort(port);
   c.setNeedClientAuth(false);
   c.setKeystore(keyStore);
   c.setKeystoreType("jks");
   c.setKeyPassword(password);
   server.setConnectors(new Connector[]{c});
  }
  return server;
 } catch (Exception ex) {
  throw new RuntimeException("Could not start embedded servlet container, "
    + ex.getMessage(), ex);
 }
}

代码示例来源:origin: org.apache.geronimo.ext.openejb/openejb-http

Connector connector = new SelectChannelConnector();
connector.setPort(port);
server.setConnectors(new Connector[]{connector});

代码示例来源:origin: NGDATA/hbase-indexer

private void startHttpServer() throws Exception {
  server = new Server();
  SelectChannelConnector selectChannelConnector = new SelectChannelConnector();
  selectChannelConnector.setPort(11060);
  server.setConnectors(new Connector[]{selectChannelConnector});
  PackagesResourceConfig packagesResourceConfig = new PackagesResourceConfig("com/ngdata/hbaseindexer/rest");
  ServletHolder servletHolder = new ServletHolder(new ServletContainer(packagesResourceConfig));
  servletHolder.setName("HBase-Indexer");
  Context context = new Context(server, "/", Context.NO_SESSIONS);
  context.addServlet(servletHolder, "/*");
  context.setContextPath("/");
  context.setAttribute("indexerModel", indexerModel);
  context.setAttribute("indexerSupervisor", indexerSupervisor);
  server.setHandler(context);
  server.start();
}

代码示例来源:origin: org.mortbay.jetty/jetty-embedded

public static void main(String[] args)
  throws Exception
{
  Server server = new Server();
  Connector connector=new SelectChannelConnector();
  connector.setPort(8080);
  server.setConnectors(new Connector[]{connector});
  
  ContextHandler context0 = new ContextHandler();
  context0.setContextPath("/zero");
  Handler handler0=new HelloHandler();
  context0.setHandler(handler0);
  ContextHandler context1 = new ContextHandler();
  context1.setContextPath("/one");
  Handler handler1=new HelloHandler();
  context1.setHandler(handler1);   
  
  ContextHandlerCollection contexts = new ContextHandlerCollection();
  contexts.setHandlers(new Handler[]{context0,context1});
  
  HandlerCollection handlers = new HandlerCollection();
  handlers.setHandlers(new Handler[]{contexts,new DefaultHandler()});
  
  server.setHandler(handlers);
  
  server.start();
  server.join();
}

代码示例来源:origin: org.apache.taverna.engine/taverna-credential-manager-impl

server.setConnectors(new Connector[] { connector });
ConstraintMapping cm = new ConstraintMapping();
Constraint constraint = new Constraint();

相关文章