Merge pull request #53 from jitsi/muxserversocketchannel-abandoned-cleanup
MuxServerSocketChannel abandoned cleanup
This commit is contained in:
commit
41ca35476e
@ -55,9 +55,10 @@ public class MuxServerSocketChannelFactory
|
||||
|
||||
/**
|
||||
* The name of the {@code boolean} property of the {@code socket} property
|
||||
* of the {@code ServerSocketChannel} returned by {@link #openAndBind(Map,
|
||||
* SocketAddress, int, DatagramPacketFilter)} which specifies the value of
|
||||
* the {@code SO_REUSEADDR} socket option.
|
||||
* of the {@code ServerSocketChannel} returned by
|
||||
* {@link #openAndBindMuxServerSocketChannel(Map, SocketAddress, int,
|
||||
* DatagramPacketFilter)} which specifies the value of the
|
||||
* {@code SO_REUSEADDR} socket option.
|
||||
*/
|
||||
public static final String SOCKET_REUSE_ADDRESS_PROPERTY_NAME
|
||||
= "socket.reuseAddress";
|
||||
@ -89,6 +90,7 @@ public class MuxServerSocketChannelFactory
|
||||
"ICE4J does not support sharing of listening endpoints"
|
||||
+ " (probably because it is not running on JDK 8).");
|
||||
}
|
||||
|
||||
Method method;
|
||||
|
||||
if (clazz == null)
|
||||
@ -128,6 +130,8 @@ public class MuxServerSocketChannelFactory
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
// The whole idea of the method is to close a specific Channel
|
||||
// without caring about any possible IOException.
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,7 +249,7 @@ public class MuxServerSocketChannelFactory
|
||||
if (value == null)
|
||||
on = false;
|
||||
else if (value instanceof Boolean)
|
||||
on = ((Boolean) value).booleanValue();
|
||||
on = (Boolean) value;
|
||||
else
|
||||
on = Boolean.valueOf(value.toString());
|
||||
|
||||
|
||||
79
src/main/java/org/ice4j/socket/jdk8/DatagramBuffer.java
Normal file
79
src/main/java/org/ice4j/socket/jdk8/DatagramBuffer.java
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
|
||||
*
|
||||
* Copyright @ 2015 Atlassian Pty Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.ice4j.socket.jdk8;
|
||||
|
||||
import java.net.*;
|
||||
import java.nio.*;
|
||||
|
||||
/**
|
||||
* Associates a {@link ByteBuffer} with a {@link DatagramPacket} so that the
|
||||
* {@code ByteBuffer} may be used for writing into a {@code byte} array and the
|
||||
* {@code DatagramPacket} may be used for reading from the same {@code byte}
|
||||
* array.
|
||||
*
|
||||
* @author Lyubomir Marinov
|
||||
*/
|
||||
class DatagramBuffer
|
||||
extends Timestamped<ByteBuffer>
|
||||
{
|
||||
/**
|
||||
* The {@code DatagramPacket} which is associated with the
|
||||
* {@link ByteBuffer} {@link #o} and shares its {@code data} with.
|
||||
*/
|
||||
private final DatagramPacket datagramPacket;
|
||||
|
||||
/**
|
||||
* Initializes a new {@code DatagramBuffer} instance with a specific
|
||||
* capacity of {@code byte}s shared between a {@code ByteBuffer} and a
|
||||
* {@code DatagramPacket}.
|
||||
*
|
||||
* @param capacity the maximum number of {@code byte}s to be written into
|
||||
* and read from the new instance
|
||||
*/
|
||||
public DatagramBuffer(int capacity)
|
||||
{
|
||||
super(ByteBuffer.allocate(capacity));
|
||||
|
||||
datagramPacket
|
||||
= new DatagramPacket(o.array(), /* offset */ 0, /* length */ 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@code ByteBuffer} (view) of this instance.
|
||||
*
|
||||
* @return the {@code ByteBuffer} (view) of this instance
|
||||
*/
|
||||
public ByteBuffer getByteBuffer()
|
||||
{
|
||||
return o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@code DatagramPacket} (view) of this instance. The
|
||||
* {@code length} of the {@code DatagramPacket} equals the {@code position}
|
||||
* of the {@code ByteBuffer} so that the {@code byte}s written into the
|
||||
* {@code ByteBuffer} may be read from the {@code DatagramPacket}.
|
||||
*
|
||||
* @return the {@code DatagramPacket} (view) of this instance
|
||||
*/
|
||||
public DatagramPacket getDatagramPacket()
|
||||
{
|
||||
datagramPacket.setLength(getByteBuffer().position());
|
||||
return datagramPacket;
|
||||
}
|
||||
}
|
||||
54
src/main/java/org/ice4j/socket/jdk8/MuxServerSocket.java
Normal file
54
src/main/java/org/ice4j/socket/jdk8/MuxServerSocket.java
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
|
||||
*
|
||||
* Copyright @ 2015 Atlassian Pty Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.ice4j.socket.jdk8;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import org.ice4j.socket.*;
|
||||
|
||||
/**
|
||||
* Represents a {@link ServerSocket} associated with a
|
||||
* {@code MuxServerSocketChannel}.
|
||||
*
|
||||
* @author Lyubomir Marinov
|
||||
*/
|
||||
class MuxServerSocket
|
||||
extends DelegatingServerSocket
|
||||
{
|
||||
/**
|
||||
* Initializes a new {@code MuxServerSocket} instance which delegates (its
|
||||
* method calls) to a specific {@code MuxingServerSocket} and is associated
|
||||
* with a specific {@code MuxServerSocketChannel}.
|
||||
*
|
||||
* @param delegate the {@code MuxingServerSocket} the new instance is to
|
||||
* delegate (its method calls) to. Technically, it is the {@code socket} of
|
||||
* the {@code delegate} of {@code channel}.
|
||||
* @param channel the {@code MuxServerSocketChannel} associated with the new
|
||||
* instance
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
public MuxServerSocket(
|
||||
MuxingServerSocket delegate,
|
||||
MuxServerSocketChannel channel)
|
||||
throws IOException
|
||||
{
|
||||
super(
|
||||
MuxServerSocketChannel.assertIsNotNull(delegate, "delegate"),
|
||||
MuxServerSocketChannel.assertIsNotNull(channel, "channel"));
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
54
src/main/java/org/ice4j/socket/jdk8/MuxingServerSocket.java
Normal file
54
src/main/java/org/ice4j/socket/jdk8/MuxingServerSocket.java
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
|
||||
*
|
||||
* Copyright @ 2015 Atlassian Pty Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.ice4j.socket.jdk8;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import org.ice4j.socket.*;
|
||||
|
||||
/**
|
||||
* Represents a {@link ServerSocket} associated with a
|
||||
* {@code MuxingServerSocketChannel}.
|
||||
*
|
||||
* @author Lyubomir Marinov
|
||||
*/
|
||||
class MuxingServerSocket
|
||||
extends DelegatingServerSocket
|
||||
{
|
||||
/**
|
||||
* Initializes a new {@code MuxingServerSocket} instance which delegates
|
||||
* (its method calls) to a specific {@code ServerSocket} and is associated
|
||||
* with a specific {@code MuxingServerSocketChannel}.
|
||||
*
|
||||
* @param delegate the {@code ServerSocket} the new instance is to delegate
|
||||
* (its method calls) to. Technically, it is the {@code socket} of the
|
||||
* {@code delegate} of {@code channel}.
|
||||
* @param channel the {@code MuxingServerSocketChannel} associated with the
|
||||
* new instance
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
public MuxingServerSocket(
|
||||
ServerSocket delegate,
|
||||
MuxingServerSocketChannel channel)
|
||||
throws IOException
|
||||
{
|
||||
super(
|
||||
MuxServerSocketChannel.assertIsNotNull(delegate, "delegate"),
|
||||
MuxServerSocketChannel.assertIsNotNull(channel, "channel"));
|
||||
}
|
||||
}
|
||||
1125
src/main/java/org/ice4j/socket/jdk8/MuxingServerSocketChannel.java
Normal file
1125
src/main/java/org/ice4j/socket/jdk8/MuxingServerSocketChannel.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -40,7 +40,7 @@ class PreReadSocketChannel
|
||||
|
||||
/**
|
||||
* Initializes a new {@code PreReadSocketChannel} instance which is to
|
||||
* prepend a specific {@link DatagrapPacket} to a specific
|
||||
* prepend a specific {@link DatagramPacket} to a specific
|
||||
* {@link SocketChannel}.
|
||||
*
|
||||
* @param preRead the {@code DatagramPacket} to prepend to {@code delegate}
|
||||
|
||||
66
src/main/java/org/ice4j/socket/jdk8/Timestamped.java
Normal file
66
src/main/java/org/ice4j/socket/jdk8/Timestamped.java
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
|
||||
*
|
||||
* Copyright @ 2015 Atlassian Pty Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.ice4j.socket.jdk8;
|
||||
|
||||
/**
|
||||
* Represents an {@code Object} with a timestamp.
|
||||
*
|
||||
* @param <T> the type of the {@code Object} which has a timestamp (associated)
|
||||
* @author Lyubomir Marinov
|
||||
*/
|
||||
class Timestamped<T>
|
||||
{
|
||||
/**
|
||||
* The {@code Object} associated with {@link #timestamp}.
|
||||
*/
|
||||
final T o;
|
||||
|
||||
/**
|
||||
* The timestamp (in milliseconds) associated with {@link #o}.
|
||||
*/
|
||||
long timestamp;
|
||||
|
||||
/**
|
||||
* Initializes a new {@code Timestamped} instance with a specific
|
||||
* {@code Object} and a default timestamp (value).
|
||||
*
|
||||
* @param o the {@code Object} to associate with a timestamp
|
||||
*/
|
||||
public Timestamped(T o)
|
||||
{
|
||||
this(o, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new {@code Timestamped} instance with a specific
|
||||
* {@code Object} and a specific timestamp (value).
|
||||
*
|
||||
* @param o the {@code Object} to associate with {@code timestamp}
|
||||
* @param timestamp the timestamp (in milliseconds) to associate with
|
||||
* {@code o}
|
||||
*/
|
||||
public Timestamped(T o, long timestamp)
|
||||
{
|
||||
// It makes no sense to associate a timestamp with a null.
|
||||
if (o == null)
|
||||
throw new NullPointerException("o");
|
||||
|
||||
this.o = o;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user