本文整理汇总了Java中java.nio.channels.NotYetBoundException类的典型用法代码示例。如果您正苦于以下问题:Java NotYetBoundException类的具体用法?Java NotYetBoundException怎么用?Java NotYetBoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NotYetBoundException类属于java.nio.channels包,在下文中一共展示了NotYetBoundException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSerializationSelf
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
/**
* @tests serialization/deserialization compatibility.
*/
@TestTargets({
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "Verifies serialization/deserialization compatibility.",
method = "!SerializationSelf",
args = {}
),
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Verifies serialization/deserialization compatibility.",
method = "NotYetBoundException",
args = {}
)
})
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new NotYetBoundException());
}
示例2: testSerializationCompatibility
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
/**
* @tests serialization/deserialization compatibility with RI.
*/
@TestTargets({
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "Verifies serialization/deserialization compatibility.",
method = "!SerializationGolden",
args = {}
),
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "Verifies serialization/deserialization compatibility.",
method = "NotYetBoundException",
args = {}
)
})
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new NotYetBoundException());
}
示例3: associations
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
@Override
public Set<Association> associations()
throws ClosedChannelException, NotYetBoundException {
synchronized (stateLock) {
if (!isOpen())
throw new ClosedChannelException();
if (!isBound())
throw new NotYetBoundException();
return Collections.unmodifiableSet(associationMap.keySet());
}
}
示例4: accept
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
public SocketChannel accept () throws IOException
{
if (!isOpen())
throw new ClosedChannelException();
if (!serverSocket.isBound())
throw new NotYetBoundException();
boolean completed = false;
try
{
begin();
VMChannel client = channel.accept();
if (client == null)
return null;
else
{
completed = true;
return new SocketChannelImpl(provider(), client, false);
}
}
finally
{
end (completed);
}
}
示例5: accept
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
public SocketChannel accept () throws IOException
{
if (!isOpen())
throw new ClosedChannelException();
if (!serverSocket.isBound())
throw new NotYetBoundException();
boolean completed = false;
try
{
begin();
VMChannel client = channel.accept();
if (client == null)
return null;
else
{
completed = true;
return new SocketChannelImpl(provider(), client, false);
}
}
finally
{
end (completed);
}
}
示例6: accept
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
@Override
public SocketChannel accept() throws IOException {
if (!isOpen()) {
throw new ClosedChannelException();
}
if (!socket.isBound()) {
throw new NotYetBoundException();
}
// Create an empty socket channel. This will be populated by ServerSocketAdapter.implAccept.
SocketChannelImpl result = new SocketChannelImpl(provider(), false);
try {
begin();
synchronized (acceptLock) {
try {
socket.implAccept(result);
} catch (SocketTimeoutException e) {
if (shouldThrowSocketTimeoutExceptionFromAccept(e)) {
throw e;
}
// Otherwise, this is a non-blocking socket and there's nothing ready, so we'll
// fall through and return null.
}
}
} finally {
end(result.isConnected());
}
return result.isConnected() ? result : null;
}
示例7: test_Constructor
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
/**
* @tests {@link java.nio.channels.NotYetBoundException#NotYetBoundException()}
*/
public void test_Constructor() {
NotYetBoundException e = new NotYetBoundException();
assertNull(e.getMessage());
assertNull(e.getLocalizedMessage());
assertNull(e.getCause());
}
示例8: testAccept_Block_NotYetBound
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
public void testAccept_Block_NotYetBound() throws IOException {
assertTrue(this.serverChannel.isOpen());
assertTrue(this.serverChannel.isBlocking());
try {
this.serverChannel.accept();
fail("Should throw NotYetBoundException");
} catch (NotYetBoundException e) {
// correct
}
}
示例9: testAccept_NonBlock_NotYetBound
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
public void testAccept_NonBlock_NotYetBound() throws IOException {
assertTrue(this.serverChannel.isOpen());
this.serverChannel.configureBlocking(false);
try {
this.serverChannel.accept();
fail("Should throw NotYetBoundException");
} catch (NotYetBoundException e) {
// correct
}
}
示例10: accept
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
@Override public SocketChannel accept() throws IOException {
if (!isOpen()) {
throw new ClosedChannelException();
}
if (!isBound) {
throw new NotYetBoundException();
}
// TODO: pass in the SelectorProvider used to create this ServerSocketChannelImpl?
// Create an empty socket channel. This will be populated by ServerSocketAdapter.accept.
SocketChannelImpl result = new SocketChannelImpl(SelectorProvider.provider(), false);
Socket resultSocket = result.socket();
try {
begin();
synchronized (acceptLock) {
synchronized (blockingLock()) {
boolean isBlocking = isBlocking();
if (!isBlocking) {
int[] tryResult = new int[1];
boolean success = Platform.getNetworkSystem().select(
new FileDescriptor[] { fd },
new FileDescriptor[0], 1, 0, 0, tryResult);
if (!success || 0 == tryResult[0]) {
// no pending connections, returns immediately.
return null;
}
}
// do accept.
do {
try {
socket.accept(resultSocket, result);
// select successfully, break out immediately.
break;
} catch (SocketTimeoutException e) {
// continue to accept if the channel is in blocking mode.
}
} while (isBlocking);
}
}
} finally {
end(resultSocket.isConnected());
}
return result;
}
示例11: accept
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
public SocketChannel accept() throws IOException {
if (!isOpen()) {
throw new ClosedChannelException();
}
if (!isBound) {
throw new NotYetBoundException();
}
SocketChannel sockChannel = new SocketChannelImpl(SelectorProvider.provider(), false);
Socket socketGot = sockChannel.socket();
try {
begin();
synchronized (acceptLock) {
boolean isBlocking = isBlocking();
if (!isBlocking) {
// for non blocking mode, use select to see whether
// there are any pending connections.
int[] tryResult = new int[1];
boolean success = Platform.getNetworkSystem().select(
new FileDescriptor[] { this.fd },
new FileDescriptor[0], 1, 0, 0, tryResult);
if (!success || 0 == tryResult[0]) {
// no pending connections, returns immediately.
return null;
}
}
// do accept.
do {
try {
((ServerSocketAdapter) socket).accept(socketGot,
(SocketChannelImpl) sockChannel);
// select successfully, break out immediately.
break;
} catch (SocketTimeoutException e) {
// continue to accept if the channel is in blocking
// mode.
}
} while (isBlocking);
}
} finally {
end(socketGot.isConnected());
}
return sockChannel;
}
示例12: testSerializationSelf
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
/**
* @tests serialization/deserialization compatibility.
*/
public void testSerializationSelf() throws Exception {
SerializationTest.verifySelf(new NotYetBoundException());
}
示例13: testSerializationCompatibility
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
/**
* @tests serialization/deserialization compatibility with RI.
*/
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this, new NotYetBoundException());
}
示例14: accept
import java.nio.channels.NotYetBoundException; //导入依赖的package包/类
public SocketChannel accept() throws IOException {
if (!isOpen()) {
throw new ClosedChannelException();
}
if (!isBound) {
throw new NotYetBoundException();
}
SocketChannel sockChannel = SocketChannel.open();
Socket socketGot = sockChannel.socket();
try {
begin();
synchronized (acceptLock) {
synchronized (blockingLock()) {
boolean isBlocking = isBlocking();
if (!isBlocking) {
// for non blocking mode, use select to see whether
// there are any pending connections.
int[] tryResult = Platform.getNetworkSystem().select(
new FileDescriptor[] { this.fd },
new FileDescriptor[0], 0);
if (0 == tryResult.length || 0 == tryResult[0]) {
// no pending connections, returns immediately.
return null;
}
}
// do accept.
do {
try {
((ServerSocketAdapter) socket).accept(socketGot,
(SocketChannelImpl) sockChannel);
// select successfully, break out immediately.
break;
} catch (SocketTimeoutException e) {
// continue to accept if the channel is in blocking
// mode.
}
} while (isBlocking);
}
}
} finally {
end(socketGot.isConnected());
}
return sockChannel;
}