Nothing really, mostly applies formatting.

This commit is contained in:
lubomir.marinov 2010-07-09 14:58:05 +00:00
parent 0e0e0086d1
commit cad31b0304
12 changed files with 66 additions and 75 deletions

View File

@ -7,14 +7,15 @@
package org.ice4j;
/**
* A StunException is thrown when a general STUN exception is encountered.
* A <tt>StunException</tt> is thrown when a general STUN exception is
* encountered.
*
* @author Emil Ivov
*/
public class StunException extends Exception
{
/**
* Serial version UID for this Serializable class.
* Serial version UID for this <tt>Serializable</tt> class.
*/
private static final long serialVersionUID = 35367793L;

View File

@ -265,7 +265,7 @@ public class TransportAddress
}
}
//may add more unreachability condition here in the future;
//may add more unreachability conditions here in the future;
return true;
}

View File

@ -101,18 +101,13 @@ public class DataAttribute
}
/**
* Returns a (cloned) byte array containg the data value of the data
* Returns a (cloned) byte array containing the data value of the data
* attribute.
* @return the binary array containing the data.
*/
public byte[] getData()
{
if (data == null)
return null;
byte[] copy = new byte[data.length];
System.arraycopy(data, 0, copy, 0, data.length);
return data;
return (data == null) ? null : data.clone();
}
/**

View File

@ -1341,7 +1341,7 @@ public class Agent
{
if (terminationThread == null)
{
terminationThread = new TerminationThread(this);
terminationThread = new TerminationThread();
terminationThread.start();
}
}
@ -1356,23 +1356,16 @@ public class Agent
* This <tt>TerminationThread</tt> is scheduling such a termination and
* garbage collection in three seconds.
*/
private static class TerminationThread
private class TerminationThread
extends Thread
{
/**
* The parent agent that created us.
*/
private final Agent parentAgent;
/**
* Creates a new termination timer.
*
* @param parentAgent the <tt>Agent</tt> that created us.
*/
private TerminationThread(Agent parentAgent)
private TerminationThread()
{
super("TerminationThread");
this.parentAgent = parentAgent;
}
/**
@ -1380,6 +1373,7 @@ public class Agent
* interval the user has specified) and then moves this <tt>Agent</tt>
* into the terminated state and frees all non-nominated candidates.
*/
@Override
public synchronized void run()
{
long terminationDelay = Integer.getInteger(
@ -1401,7 +1395,7 @@ public class Agent
}
}
parentAgent.terminate(IceProcessingState.TERMINATED);
terminate(IceProcessingState.TERMINATED);
}
}
@ -1417,9 +1411,7 @@ public class Agent
{
// free candidates
for(IceMediaStream stream : getStreams())
{
removeStream(stream);
}
// stop listening for checks
connCheckClient.stop();

View File

@ -106,17 +106,17 @@ class ConnectivityCheckClient
*/
private TransactionID startCheckForPair(CandidatePair candidatePair)
{
LocalCandidate localCandidate = candidatePair.getLocalCandidate();
//we don't need to do a canReach() verification here as it has been
//already verified during the gathering process.
DatagramSocket stunSocket
= candidatePair.getLocalCandidate().getStunSocket(null);
DatagramSocket stunSocket = localCandidate.getStunSocket(null);
Request request = MessageFactory.createBindingRequest();
//the priority we'd like the remote party to use for a peer reflexive
//candidate if one is discovered as a consequence of this check.
PriorityAttribute priority = AttributeFactory.createPriorityAttribute(
candidatePair.getLocalCandidate().computePriorityForType(
localCandidate.computePriorityForType(
CandidateType.PEER_REFLEXIVE_CANDIDATE));
request.addAttribute(priority);
@ -148,7 +148,7 @@ class ConnectivityCheckClient
request.addAttribute(unameAttr);
//todo: also implement SASL prepare
// TODO Also implement SASL prepare
MessageIntegrityAttribute msgIntegrity = AttributeFactory
.createMessageIntegrityAttribute(localUserName);
@ -159,26 +159,30 @@ class ConnectivityCheckClient
try
{
stunStack.sendRequest(request,
candidatePair.getRemoteCandidate().getTransportAddress(),
candidatePair.getLocalCandidate().getTransportAddress(),
this, tran);
tran
= stunStack.sendRequest(request,
candidatePair
.getRemoteCandidate().getTransportAddress(),
localCandidate.getTransportAddress(),
this,
tran);
if(logger.isLoggable(Level.FINEST))
logger.finest("checking pair " + candidatePair + " with tran="
+ tran);
return tran;
{
logger.finest(
"checking pair " + candidatePair
+ " with tran=" + tran);
}
}
catch (Exception exception)
catch (Exception ex)
{
logger.log( Level.INFO,
"Failed to send " + request + " through "
+ stunSocket.getLocalSocketAddress(),
exception);
return null;
logger.log(
Level.INFO,
"Failed to send " + request
+ " through " + stunSocket.getLocalSocketAddress(),
ex);
tran = null;
}
return tran;
}
/**
@ -193,7 +197,7 @@ class ConnectivityCheckClient
public void processResponse(StunResponseEvent evt)
{
CandidatePair checkedPair
= ((CandidatePair)evt.getTransactionID().getApplicationData());
= (CandidatePair) evt.getTransactionID().getApplicationData();
//make sure that the response came from the right place.
if (!checkSymmetricAddresses(evt))
@ -296,8 +300,8 @@ class ConnectivityCheckClient
Response response = evt.getResponse();
Request request = evt.getRequest();
CandidatePair checkedPair = ((CandidatePair)evt.getTransactionID()
.getApplicationData());
CandidatePair checkedPair
= (CandidatePair) evt.getTransactionID().getApplicationData();
if(! response.containsAttribute(Attribute.XOR_MAPPED_ADDRESS))
{

View File

@ -14,32 +14,33 @@ package org.ice4j.message;
*
* @author Sebastien Vincent
*/
public class Indication extends Message
public class Indication
extends Message
{
/**
* Constructor.
*/
Indication()
{
}
/**
* Checks whether indicationType is a valid response type and if yes sets it
* as the type of the current instance.
* Checks whether indicationType is a valid indication type and if yes sets
* it as the type of this instance.
*
* @param indicationType the type to set
* @throws IllegalArgumentException if indicationType is not a valid
* response type
* indication type
*/
@Override
public void setMessageType(char indicationType)
throws IllegalArgumentException
{
if(!isIndicationType(indicationType))
throw new IllegalArgumentException(
(int)(indicationType)
+ " - is not a valid response type.");
+ " - is not a valid indication type.");
super.setMessageType(indicationType);
}
}

View File

@ -15,7 +15,7 @@ import org.ice4j.*;
*
* @author Emil Ivov
*/
interface MessageEventHandler
public interface MessageEventHandler
{
/**
* Called when an incoming message has been received, parsed and is ready

View File

@ -44,7 +44,7 @@ class MessageProcessor
/**
* The flag that indicates whether we are still running.
*/
private boolean isRunning = false;
private boolean running = false;
/**
* A reference to the thread that we use to execute ourselves.
@ -93,7 +93,7 @@ class MessageProcessor
//avoid having dead threads in our pools.
try
{
while (isRunning)
while (running)
{
RawMessage rawMessage;
try
@ -127,7 +127,7 @@ class MessageProcessor
}
catch (StunException ex)
{
errorHandler.handleError("Failed to decode a stun mesage!",
errorHandler.handleError("Failed to decode a stun message!",
ex);
continue; //let this one go and for better luck next time.
@ -153,20 +153,19 @@ class MessageProcessor
*/
void start()
{
this.isRunning = true;
this.running = true;
runningThread = new Thread(this, "Stun4J Message Processor");
runningThread.setDaemon(true);
runningThread.start();
}
/**
* Shut down the message processor.
*/
void stop()
{
this.isRunning = false;
this.running = false;
runningThread.interrupt();
}
@ -178,6 +177,6 @@ class MessageProcessor
*/
boolean isRunning()
{
return isRunning;
return running;
}
}

View File

@ -143,18 +143,20 @@ class NetAccessManager
*/
protected void addSocket(DatagramSocket socket)
{
//no null check - let it through a null pointer exception
TransportAddress localAddr = new TransportAddress(
socket.getLocalAddress(), socket.getLocalPort(), Transport.UDP);
//no null check - let it through as a NullPointerException
TransportAddress localAddr
= new TransportAddress(
socket.getLocalAddress(),
socket.getLocalPort(),
Transport.UDP);
if(netAccessPoints.containsKey(localAddr))
return;
if (!netAccessPoints.containsKey(localAddr))
{
Connector ap = new Connector(socket, messageQueue, this);
Connector ap = new Connector(socket, messageQueue, this);
netAccessPoints.put(localAddr, ap);
ap.start();
netAccessPoints.put(localAddr, ap);
ap.start();
}
}
/**

View File

@ -324,7 +324,6 @@ class StunClientTransaction
}
}
/**
* Cancels the transaction. Once this method is called the transaction is
* considered terminated and will stop retransmissions.

View File

@ -32,7 +32,6 @@ import org.ice4j.message.*;
*
* @author Emil Ivov
*/
class StunServerTransaction
implements Runnable
{

View File

@ -18,11 +18,10 @@ import org.ice4j.stack.*;
/**
* The class provides basic means of discovering a public IP address. All it
* does is send a binding request through a specified port and return the
* mapped address it got back or <tt>null</tt> if there was no reponse.
* mapped address it got back or <tt>null</tt> if there was no response.
*
* @author Emil Ivov
*/
public class SimpleAddressDetector
{
/**