本文整理匯總了Java中org.mortbay.jetty.Connector.setHost方法的典型用法代碼示例。如果您正苦於以下問題:Java Connector.setHost方法的具體用法?Java Connector.setHost怎麽用?Java Connector.setHost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.mortbay.jetty.Connector
的用法示例。
在下文中一共展示了Connector.setHost方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startup
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
public void startup() {
if (adminPort > 0) {
Connector httpConnector = new SelectChannelConnector();
httpConnector.setHost(adminHost);
httpConnector.setPort(adminPort);
adminServer.addConnector(httpConnector);
}
if (adminServer.getConnectors() == null
|| adminServer.getConnectors().length == 0) {
adminServer = null;
log.warn("Admin console not started due to configuration error.");
return;
}
adminServer
.setHandlers(new Handler[] { contexts, new DefaultHandler() });
try {
adminServer.start();
httpStarted = true;
log.debug("Admin console started.");
} catch (Exception e) {
log.error("Could not start admin conosle server", e);
}
}
示例2: getRedirectUri
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
@Override
public String getRedirectUri() throws IOException {
if (port == -1) {
port = getUnusedPort();
}
server = new Server(port);
for (Connector c : server.getConnectors()) {
c.setHost(host);
}
server.addHandler(new CallbackHandler());
try {
server.start();
} catch (Exception e) {
Throwables.propagateIfPossible(e);
throw new IOException(e);
}
return "http://" + host + ":" + port + CALLBACK_PATH;
}
示例3: putUpJettyServer
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
private void putUpJettyServer() throws IOException {
if (!conf.getBoolean("hbase.master.infoserver.redirect", true)) {
return;
}
int infoPort = conf.getInt("hbase.master.info.port.orig",
HConstants.DEFAULT_MASTER_INFOPORT);
// -1 is for disabling info server, so no redirecting
if (infoPort < 0 || infoServer == null) {
return;
}
RedirectServlet.regionServerInfoPort = infoServer.getPort();
masterJettyServer = new org.mortbay.jetty.Server();
Connector connector = new SelectChannelConnector();
connector.setHost(conf.get("hbase.master.info.bindAddress", "0.0.0.0"));
connector.setPort(infoPort);
masterJettyServer.addConnector(connector);
masterJettyServer.setStopAtShutdown(true);
Context context = new Context(masterJettyServer, "/", Context.NO_SESSIONS);
context.addServlet(RedirectServlet.class, "/*");
try {
masterJettyServer.start();
} catch (Exception e) {
throw new IOException("Failed to start redirecting jetty server", e);
}
}
示例4: getRedirectUri
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
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";
}
示例5: putUpJettyServer
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
private int putUpJettyServer() throws IOException {
if (!conf.getBoolean("hbase.master.infoserver.redirect", true)) {
return -1;
}
int infoPort = conf.getInt("hbase.master.info.port.orig",
HConstants.DEFAULT_MASTER_INFOPORT);
// -1 is for disabling info server, so no redirecting
if (infoPort < 0 || infoServer == null) {
return -1;
}
String addr = conf.get("hbase.master.info.bindAddress", "0.0.0.0");
if (!Addressing.isLocalAddress(InetAddress.getByName(addr))) {
String msg =
"Failed to start redirecting jetty server. Address " + addr
+ " does not belong to this host. Correct configuration parameter: "
+ "hbase.master.info.bindAddress";
LOG.error(msg);
throw new IOException(msg);
}
RedirectServlet.regionServerInfoPort = infoServer.getPort();
if(RedirectServlet.regionServerInfoPort == infoPort) {
return infoPort;
}
masterJettyServer = new org.mortbay.jetty.Server();
Connector connector = new SelectChannelConnector();
connector.setHost(addr);
connector.setPort(infoPort);
masterJettyServer.addConnector(connector);
masterJettyServer.setStopAtShutdown(true);
Context context = new Context(masterJettyServer, "/", Context.NO_SESSIONS);
context.addServlet(RedirectServlet.class, "/*");
try {
masterJettyServer.start();
} catch (Exception e) {
throw new IOException("Failed to start redirecting jetty server", e);
}
return connector.getLocalPort();
}
示例6: putUpJettyServer
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
private int putUpJettyServer() throws IOException {
if (!conf.getBoolean("hbase.master.infoserver.redirect", true)) {
return -1;
}
int infoPort = conf.getInt("hbase.master.info.port.orig",
HConstants.DEFAULT_MASTER_INFOPORT);
// -1 is for disabling info server, so no redirecting
if (infoPort < 0 || infoServer == null) {
return -1;
}
String addr = conf.get("hbase.master.info.bindAddress", "0.0.0.0");
if (!Addressing.isLocalAddress(InetAddress.getByName(addr))) {
String msg =
"Failed to start redirecting jetty server. Address " + addr
+ " does not belong to this host. Correct configuration parameter: "
+ "hbase.master.info.bindAddress";
LOG.error(msg);
throw new IOException(msg);
}
RedirectServlet.regionServerInfoPort = infoServer.getPort();
masterJettyServer = new org.mortbay.jetty.Server();
Connector connector = new SelectChannelConnector();
connector.setHost(addr);
connector.setPort(infoPort);
masterJettyServer.addConnector(connector);
masterJettyServer.setStopAtShutdown(true);
Context context = new Context(masterJettyServer, "/", Context.NO_SESSIONS);
context.addServlet(RedirectServlet.class, "/*");
try {
masterJettyServer.start();
} catch (Exception e) {
throw new IOException("Failed to start redirecting jetty server", e);
}
return connector.getLocalPort();
}
示例7: build
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
public HttpServer2 build() throws IOException {
Preconditions.checkNotNull(name, "name is not set");
Preconditions.checkState(!endpoints.isEmpty(), "No endpoints specified");
if (hostName == null) {
hostName = endpoints.get(0).getHost();
}
if (this.conf == null) {
conf = new Configuration();
}
HttpServer2 server = new HttpServer2(this);
if (this.securityEnabled) {
server.initSpnego(conf, hostName, usernameConfKey, keytabConfKey);
}
for (URI ep : endpoints) {
final Connector listener;
String scheme = ep.getScheme();
if ("http".equals(scheme)) {
listener = HttpServer2.createDefaultChannelConnector();
} else if ("https".equals(scheme)) {
listener = createHttpsChannelConnector();
} else {
throw new HadoopIllegalArgumentException(
"unknown scheme for endpoint:" + ep);
}
listener.setHost(ep.getHost());
listener.setPort(ep.getPort() == -1 ? 0 : ep.getPort());
server.addListener(listener);
}
server.loadListeners();
return server;
}
示例8: startServer
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
/**
* Starts Jetty.
*
* @param host the host to bound.
* @param port the port to bound.
* @param contextPath the context path to bound.
*/
private static void startServer(final String host, final int port, final String contextPath) {
final Logger log = LoggerFactory.getLogger(JaptProxyServer.class);
log.info("Starting Japt-Proxy {} on host {} port {} using context path '{}'",
Util.VERSION, StringUtils.defaultIfEmpty(host, "*"), port, contextPath);
// Spring startup
final ClassPathXmlApplicationContext classPathXmlApplicationContext =
new ClassPathXmlApplicationContext("master.xml", "standalone.xml");
classPathXmlApplicationContext.registerShutdownHook();
// Jetty startup
final Server server = new Server();
final Connector connector = new BlockingChannelConnector();
if (!StringUtils.isBlank(host)) {
connector.setHost(host);
}
connector.setPort(port);
server.setConnectors(new Connector[]{connector});
server.setStopAtShutdown(true);
final Context root = new Context(server, contextPath);
final JaptProxyServlet japtProxyServlet =
classPathXmlApplicationContext
.getBean("japtProxyServlet", JaptProxyServlet.class);
root.addServlet(new ServletHolder(japtProxyServlet), "/*");
try {
server.start();
} catch (final Exception e) {
// shame on Jetty's exception handling
throw new IllegalStateException("Couldn't start HTTP engine", e);
}
}
示例9: startup
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
/**
* Starts the Jetty server instance.
*/
public void startup() {
if (adminPort > 0) {
Connector httpConnector = new SelectChannelConnector();
httpConnector.setHost(adminHost);
httpConnector.setPort(adminPort);
adminServer.addConnector(httpConnector);
}
if (adminServer.getConnectors() == null
|| adminServer.getConnectors().length == 0) {
adminServer = null;
log.warn("Admin console not started due to configuration error.");
return;
}
adminServer
.setHandlers(new Handler[] { contexts, new DefaultHandler() });
try {
adminServer.start();
httpStarted = true;
log.debug("Admin console started.");
} catch (Exception e) {
log.error("Could not start admin conosle server", e);
}
}
示例10: startup
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
public void startup() {
// Create connector for http traffic if it's enabled.
if (adminPort > 0) {
Connector httpConnector = new SelectChannelConnector();
httpConnector.setHost(adminHost);
httpConnector.setPort(adminPort);
adminServer.addConnector(httpConnector);
}
// Make sure that at least one connector was registered.
if (adminServer.getConnectors() == null
|| adminServer.getConnectors().length == 0) {
adminServer = null;
log.warn("Admin console not started due to configuration error.");
return;
}
adminServer
.setHandlers(new Handler[] { contexts, new DefaultHandler() });
try {
adminServer.start();
httpStarted = true;
log.debug("Admin Console started.");
} catch (Exception e) {
log.error("Could not start admin conosle server", e);
}
}
示例11: getRedirectUri
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
@Override
public String getRedirectUri() throws Exception {
int port = LocalServerReceiver.getUnusedPort();
this.server = new Server(port);
for (Connector c : this.server.getConnectors()) {
c.setHost("localhost");
}
this.server.addHandler(new CallbackHandler());
this.server.start();
return "http://localhost:" + port + LocalServerReceiver.CALLBACK_PATH;
}
示例12: tryPort
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
private Server tryPort(final int portNumber) throws Exception {
Server srv = new Server();
final Connector connector = new SocketConnector();
connector.setHost(addressProvider.getLocalAddress());
connector.setPort(portNumber);
srv.addConnector(connector);
try {
srv.start();
LOG.log(Level.INFO, "Jetty Server started with port: {0}", portNumber);
} catch (final BindException ex) {
srv = null;
LOG.log(Level.FINEST, "Cannot use port: {0}. Will try another", portNumber);
}
return srv;
}
示例13: createConnector
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
/**
*
* @param host localhost, 127.0.0.1 or 0.0.0.0.
* @param port port
* @return jetty connector
*/
protected Connector createConnector(String host, int port){
Connector connector = new SelectChannelConnector();
if(host != null){
connector.setHost(host);
}
connector.setPort( port );
connector.setMaxIdleTime(MAX_IDLE_TIME);
return connector;
}
示例14: startUp
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
@Override
protected void startUp() throws Exception {
// setup the jetty config
ServletHolder sh = new ServletHolder(ServletContainer.class);
sh.setInitParameter("com.sun.jersey.config.property.packages", "com.twitter.hraven.rest");
sh.setInitParameter(JSONConfiguration.FEATURE_POJO_MAPPING, "true");
server = new Server();
Connector connector = new SelectChannelConnector();
connector.setPort(this.port);
connector.setHost(address);
server.addConnector(connector);
// TODO: in the future we may want to provide settings for the min and max threads
// Jetty sets the default max thread number to 250, if we don't set it.
//
QueuedThreadPool threadPool = new QueuedThreadPool();
server.setThreadPool(threadPool);
server.setSendServerVersion(false);
server.setSendDateHeader(false);
server.setStopAtShutdown(true);
// set up context
Context context = new Context(server, "/", Context.SESSIONS);
context.addServlet(sh, "/*");
// start server
server.start();
}
示例15: startServer
import org.mortbay.jetty.Connector; //導入方法依賴的package包/類
private void startServer() throws Exception {
server = new Server(port);
for (Connector c : server.getConnectors()) {
c.setHost(host);
}
server.addHandler(new CallbackHandler());
try {
server.start();
} catch (Exception e) {
throw new IOException(e);
}
}