本文整理匯總了Java中java.net.BindException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java BindException.getMessage方法的具體用法?Java BindException.getMessage怎麽用?Java BindException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.net.BindException
的用法示例。
在下文中一共展示了BindException.getMessage方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import java.net.BindException; //導入方法依賴的package包/類
public void init()
throws Exception {
if (initialized)
return;
// Initialize thread count defaults for acceptor
if (acceptorThreadCount == 0) {
acceptorThreadCount = 1;
}
if (serverSocketFactory == null) {
serverSocketFactory = ServerSocketFactory.getDefault();
}
if (serverSocket == null) {
try {
if (address == null) {
serverSocket = serverSocketFactory.createSocket(port, backlog);
} else {
serverSocket = serverSocketFactory.createSocket(port, backlog, address);
}
} catch (BindException be) {
if (address == null) {
throw new BindException(be.getMessage() + "<null>:" + port);
} else {
throw new BindException(be.getMessage() + " " +
address.toString() + ":" + port);
}
}
}
//if( serverTimeout >= 0 )
// serverSocket.setSoTimeout( serverTimeout );
initialized = true;
}
示例2: bindExceptionHandler
import java.net.BindException; //導入方法依賴的package包/類
@ExceptionHandler(BindException.class)
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@ResponseBody
public Result<Object> bindExceptionHandler(BindException e){
String errorMsg="請求數據校驗不合法: ";
if(e!=null){
errorMsg=e.getMessage();
log.warn(errorMsg);
}
return new ResultUtil<>().setErrorMsg(errorMsg);
}
示例3: bind
import java.net.BindException; //導入方法依賴的package包/類
@Override
protected void bind(InetSocketAddress socketAddress) throws IOException {
initChannel();
try {
datagramSocket.bind(socketAddress);
} catch (BindException e) {
throw new BindException(e.getMessage() + " at " + socketAddress.getPort());
}
initSelectorLoops();
}
示例4: bind
import java.net.BindException; //導入方法依賴的package包/類
@Override
protected void bind(InetSocketAddress socketAddress) throws IOException {
initChannel();
initSelectorLoops();
initNioSessionMananger();
try {
this.serverSocket.bind(socketAddress, 50);
} catch (BindException e) {
throw new BindException(e.getMessage() + " at " + socketAddress.getPort());
}
}
示例5: bind
import java.net.BindException; //導入方法依賴的package包/類
@Override
public void bind() throws Exception {
// Initialize thread count defaults for acceptor
if (acceptorThreadCount == 0) {
acceptorThreadCount = 1;
}
// Initialize maxConnections
if (getMaxConnections() == 0) {
// User hasn't set a value - use the default
setMaxConnections(getMaxThreadsInternal());
}
if (serverSocketFactory == null) { //構造serverSocketFactory
if (isSSLEnabled()) {
serverSocketFactory =
handler.getSslImplementation().getServerSocketFactory(this);
} else {
serverSocketFactory = new DefaultServerSocketFactory(this);
}
}
if (serverSocket == null) {
try {
if (getAddress() == null) {
serverSocket = serverSocketFactory.createSocket(getPort(),
getBacklog());
} else {
serverSocket = serverSocketFactory.createSocket(getPort(),
getBacklog(), getAddress());
}
} catch (BindException orig) {
String msg;
if (getAddress() == null)
msg = orig.getMessage() + " <null>:" + getPort();
else
msg = orig.getMessage() + " " +
getAddress().toString() + ":" + getPort();
BindException be = new BindException(msg);
be.initCause(orig);
throw be;
}
}
}
示例6: bind
import java.net.BindException; //導入方法依賴的package包/類
@Override
public void bind() throws Exception {
// Initialize thread count defaults for acceptor
// 接收sokcet請求的線程的數量 非常輕量級 隻負責拿到後稍微包裝後轉發給processor 可以適量增大線程數 比如3個或者5個
if (acceptorThreadCount == 0) {
acceptorThreadCount = 1;
}
// Initialize maxConnections
// 如果server.xml中沒有配置maxConnections參數 默認為200
if (getMaxConnections() == 0) {
// User hasn't set a value - use the default
setMaxConnections(getMaxThreadsInternal());//200 所以tomcat默認的最大連接數量是200個
}
if (serverSocketFactory == null) {
if (isSSLEnabled()) {
serverSocketFactory =
handler.getSslImplementation().getServerSocketFactory(this);
} else {
//
serverSocketFactory = new DefaultServerSocketFactory(this);
}
}
if (serverSocket == null) {
try {
if (getAddress() == null) {
serverSocket = serverSocketFactory.createSocket(getPort(),
getBacklog());
} else {
serverSocket = serverSocketFactory.createSocket(getPort(),
getBacklog(), getAddress());
}
} catch (BindException orig) {
String msg;
if (getAddress() == null)
msg = orig.getMessage() + " <null>:" + getPort();
else
msg = orig.getMessage() + " " +
getAddress().toString() + ":" + getPort();
BindException be = new BindException(msg);
be.initCause(orig);
throw be;
}
}
}
示例7: bind
import java.net.BindException; //導入方法依賴的package包/類
@Override
public void bind() throws Exception {
// Initialize thread count defaults for acceptor
if (acceptorThreadCount == 0) {
acceptorThreadCount = 1;
}
// Initialize maxConnections
if (getMaxConnections() == 0) {
// User hasn't set a value - use the default
setMaxConnections(getMaxThreadsInternal());
}
if (serverSocketFactory == null) {
if (isSSLEnabled()) {
serverSocketFactory = handler.getSslImplementation().getServerSocketFactory(this);
} else {
serverSocketFactory = new DefaultServerSocketFactory(this);
}
}
if (serverSocket == null) {
try {
if (getAddress() == null) {
serverSocket = serverSocketFactory.createSocket(getPort(), getBacklog());
} else {
serverSocket = serverSocketFactory.createSocket(getPort(), getBacklog(), getAddress());
}
} catch (BindException orig) {
String msg;
if (getAddress() == null)
msg = orig.getMessage() + " <null>:" + getPort();
else
msg = orig.getMessage() + " " + getAddress().toString() + ":" + getPort();
BindException be = new BindException(msg);
be.initCause(orig);
throw be;
}
}
}