本文整理汇总了Java中org.mortbay.jetty.bio.SocketConnector.setHost方法的典型用法代码示例。如果您正苦于以下问题:Java SocketConnector.setHost方法的具体用法?Java SocketConnector.setHost怎么用?Java SocketConnector.setHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.bio.SocketConnector
的用法示例。
在下文中一共展示了SocketConnector.setHost方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startServer
import org.mortbay.jetty.bio.SocketConnector; //导入方法依赖的package包/类
/**
* Starts the Jetty server at a specified port.
*
* Will try up to 10 ports to find an available port to use.
*
* @param portno
* Port number.
* @throws Exception
* When an error occurs.
*/
private void startServer(int portno) throws Exception {
SocketConnector listener = new SocketConnector();
listener.setHost("127.0.0.1");
server.addConnector(listener);
for (int p = portno; p < portno + 10; p++) {
port = portno;
listener.setPort(port);
try {
server.start();
break;
} catch (Exception e) {
if (p == portno + 9) {
throw e;
}
}
}
}
示例2: getServer
import org.mortbay.jetty.bio.SocketConnector; //导入方法依赖的package包/类
/**
* Creates a new JettyServer with one static root context
*
* @param port
* port to listen to
* @param staticContent
* folder where static content lives
* @throws UnknownHostException
*/
public static Server getServer(int port, String staticContent)
throws UnknownHostException {
Server webServer = new org.mortbay.jetty.Server();
SocketConnector listener = new SocketConnector();
listener.setPort(port);
listener.setHost("127.0.0.1");
webServer.addConnector(listener);
ContextHandler staticContext = new ContextHandler();
staticContext.setContextPath("/");
staticContext.setResourceBase(staticContent);
staticContext.addHandler(new ResourceHandler());
webServer.addHandler(staticContext);
return webServer;
}
示例3: startServer
import org.mortbay.jetty.bio.SocketConnector; //导入方法依赖的package包/类
/**
* Starts the Jetty server at a specified port.
*
* @param portno Port number.
* @throws Exception When an error occurs.
*/
private void startServer(int portno) throws Exception {
port = portno;
SocketConnector listener = new SocketConnector();
listener.setHost("127.0.0.1");
listener.setPort(port);
server.addConnector(listener);
server.start();
}
示例4: getServer
import org.mortbay.jetty.bio.SocketConnector; //导入方法依赖的package包/类
/**
* Creates a new JettyServer with one static root context
*
* @param port port to listen to
* @param staticContent folder where static content lives
* @throws UnknownHostException
*/
public static Server getServer(int port, String staticContent) throws UnknownHostException{
Server webServer = new org.mortbay.jetty.Server();
SocketConnector listener = new SocketConnector();
listener.setPort(port);
listener.setHost("127.0.0.1");
webServer.addConnector(listener);
ContextHandler staticContext = new ContextHandler();
staticContext.setContextPath("/");
staticContext.setResourceBase(staticContent);
staticContext.addHandler(new ResourceHandler());
webServer.addHandler(staticContext);
return webServer;
}
示例5: startServer
import org.mortbay.jetty.bio.SocketConnector; //导入方法依赖的package包/类
/**
* Start embedded server.
* @throws Exception
*/
public void startServer() throws Exception {
SocketConnector connector = new SocketConnector();
connector.setPort(0);
connector.setHost("127.0.0.1");
webServer.addConnector(connector);
webServer.start();
port = connector.getLocalPort();
host = connector.getHost();
}
示例6: createListeners
import org.mortbay.jetty.bio.SocketConnector; //导入方法依赖的package包/类
private void createListeners()
{
SocketConnector connector = new SocketConnector();
connector.setPort(port);
connector.setHost(hostname);
connector.setName(Messages.getString("WebServer.Log.KettleHTTPListener",hostname));
log.logBasic(toString(), Messages.getString("WebServer.Log.CreateListener",hostname,""+port));
server.setConnectors( new Connector[] { connector });
}
示例7: go
import org.mortbay.jetty.bio.SocketConnector; //导入方法依赖的package包/类
public void go() {
QueuedThreadPool pool = new QueuedThreadPool();
pool.setMinThreads(2); // debug server doesn't need many threads.
pool.setMaxThreads(10);
pool.setName("DebugServer(port" + port + ")");
pool.setDaemon(true);
server.setThreadPool(pool);
SocketConnector connector = new SocketConnector();
connector.setPort(port);
connector.setHost(host);
connector.setMaxIdleTime(60000); // 1 min
server.addConnector(connector);
context.setContextPath("/");
context.setBaseResource(Resource.newClassPathResource("/org/cloudera/stethoscope"));
server.setHandler(context);
addServlet(new DefaultServlet(), "/");
addServlet(new DataServlet(), "/json/*");
addServlet(new TracerServlet(inst), "/tracer/*");
addServlet(new EvaluateServlet(), "/evaluate");
addServlet(new PoorMansProfileServlet(), "/poorMansProfiler");
addServlet(new JMXJsonServlet(), "/jmx");
// addServlet(new LoggerServlet(), "/logging");
try {
server.start();
} catch (Exception e) {
// avoiding logging in this context.
e.printStackTrace(System.err);
}
}
示例8: createListeners
import org.mortbay.jetty.bio.SocketConnector; //导入方法依赖的package包/类
private void createListeners()
{
SocketConnector connector = new SocketConnector();
connector.setPort(port);
connector.setHost(hostname);
connector.setName(BaseMessages.getString(PKG, "WebServer.Log.KettleHTTPListener",hostname));
log.logBasic(BaseMessages.getString(PKG, "WebServer.Log.CreateListener",hostname,""+port));
server.setConnectors( new Connector[] { connector });
}
示例9: createListeners
import org.mortbay.jetty.bio.SocketConnector; //导入方法依赖的package包/类
private void createListeners() {
SocketConnector connector = new SocketConnector();
connector.setPort(port);
connector.setHost(hostname);
connector.setName(BaseMessages.getString(PKG, "WebServer.Log.KettleHTTPListener", hostname));
log.logBasic(BaseMessages.getString(PKG, "WebServer.Log.CreateListener", hostname, "" + port));
server.setConnectors(new Connector[] { connector });
}
示例10: createConnector
import org.mortbay.jetty.bio.SocketConnector; //导入方法依赖的package包/类
private static Connector createConnector(HostAndPort address) {
SocketConnector connector = new SocketConnector();
connector.setHost(address.getHost());
connector.setPort(address.getPortOrDefault(DEFAULT_PORT));
return connector;
}