Added some missing @Overrides and finals.

cleanup_build_scripts
Paul Speed 9 years ago
parent 388a8a8bd7
commit 197ed33c9e
  1. 34
      jme3-networking/src/main/java/com/jme3/network/base/DefaultClient.java
  2. 56
      jme3-networking/src/main/java/com/jme3/network/base/DefaultServer.java
  3. 2
      jme3-networking/src/main/java/com/jme3/network/base/MessageProtocol.java
  4. 2
      jme3-networking/src/main/java/com/jme3/network/service/ServiceManager.java

@ -67,18 +67,18 @@ public class DefaultClient implements Client
private static final int CH_UNRELIABLE = 1; private static final int CH_UNRELIABLE = 1;
private static final int CH_FIRST = 2; private static final int CH_FIRST = 2;
private ThreadLocal<ByteBuffer> dataBuffer = new ThreadLocal<ByteBuffer>(); private final ThreadLocal<ByteBuffer> dataBuffer = new ThreadLocal<ByteBuffer>();
private int id = -1; private int id = -1;
private boolean isRunning = false; private boolean isRunning = false;
private CountDownLatch connecting = new CountDownLatch(1); private final CountDownLatch connecting = new CountDownLatch(1);
private String gameName; private String gameName;
private int version; private int version;
private MessageListenerRegistry<Client> messageListeners = new MessageListenerRegistry<Client>(); private final MessageListenerRegistry<Client> messageListeners = new MessageListenerRegistry<Client>();
private List<ClientStateListener> stateListeners = new CopyOnWriteArrayList<ClientStateListener>(); private final List<ClientStateListener> stateListeners = new CopyOnWriteArrayList<ClientStateListener>();
private List<ErrorListener<? super Client>> errorListeners = new CopyOnWriteArrayList<ErrorListener<? super Client>>(); private final List<ErrorListener<? super Client>> errorListeners = new CopyOnWriteArrayList<ErrorListener<? super Client>>();
private Redispatch dispatcher = new Redispatch(); private final Redispatch dispatcher = new Redispatch();
private List<ConnectorAdapter> channels = new ArrayList<ConnectorAdapter>(); private final List<ConnectorAdapter> channels = new ArrayList<ConnectorAdapter>();
private ConnectorFactory connectorFactory; private ConnectorFactory connectorFactory;
@ -129,6 +129,7 @@ public class DefaultClient implements Client
throw new IllegalStateException( "Client is not started." ); throw new IllegalStateException( "Client is not started." );
} }
@Override
public void start() public void start()
{ {
if( isRunning ) if( isRunning )
@ -180,6 +181,7 @@ public class DefaultClient implements Client
} }
} }
@Override
public boolean isStarted() { public boolean isStarted() {
return isRunning; return isRunning;
} }
@ -196,31 +198,37 @@ public class DefaultClient implements Client
} }
} }
@Override
public boolean isConnected() public boolean isConnected()
{ {
return id != -1 && isRunning; return id != -1 && isRunning;
} }
@Override
public int getId() public int getId()
{ {
return id; return id;
} }
@Override
public String getGameName() public String getGameName()
{ {
return gameName; return gameName;
} }
@Override
public int getVersion() public int getVersion()
{ {
return version; return version;
} }
@Override
public ClientServiceManager getServices() public ClientServiceManager getServices()
{ {
return services; return services;
} }
@Override
public void send( Message message ) public void send( Message message )
{ {
if( log.isLoggable(Level.FINER) ) { if( log.isLoggable(Level.FINER) ) {
@ -233,6 +241,7 @@ public class DefaultClient implements Client
} }
} }
@Override
public void send( int channel, Message message ) public void send( int channel, Message message )
{ {
if( log.isLoggable(Level.FINER) ) { if( log.isLoggable(Level.FINER) ) {
@ -282,6 +291,7 @@ public class DefaultClient implements Client
channels.get(channel).write(buffer); channels.get(channel).write(buffer);
} }
@Override
public void close() public void close()
{ {
checkRunning(); checkRunning();
@ -322,41 +332,49 @@ public class DefaultClient implements Client
services.terminate(); services.terminate();
} }
@Override
public void addClientStateListener( ClientStateListener listener ) public void addClientStateListener( ClientStateListener listener )
{ {
stateListeners.add( listener ); stateListeners.add( listener );
} }
@Override
public void removeClientStateListener( ClientStateListener listener ) public void removeClientStateListener( ClientStateListener listener )
{ {
stateListeners.remove( listener ); stateListeners.remove( listener );
} }
@Override
public void addMessageListener( MessageListener<? super Client> listener ) public void addMessageListener( MessageListener<? super Client> listener )
{ {
messageListeners.addMessageListener( listener ); messageListeners.addMessageListener( listener );
} }
@Override
public void addMessageListener( MessageListener<? super Client> listener, Class... classes ) public void addMessageListener( MessageListener<? super Client> listener, Class... classes )
{ {
messageListeners.addMessageListener( listener, classes ); messageListeners.addMessageListener( listener, classes );
} }
@Override
public void removeMessageListener( MessageListener<? super Client> listener ) public void removeMessageListener( MessageListener<? super Client> listener )
{ {
messageListeners.removeMessageListener( listener ); messageListeners.removeMessageListener( listener );
} }
@Override
public void removeMessageListener( MessageListener<? super Client> listener, Class... classes ) public void removeMessageListener( MessageListener<? super Client> listener, Class... classes )
{ {
messageListeners.removeMessageListener( listener, classes ); messageListeners.removeMessageListener( listener, classes );
} }
@Override
public void addErrorListener( ErrorListener<? super Client> listener ) public void addErrorListener( ErrorListener<? super Client> listener )
{ {
errorListeners.add( listener ); errorListeners.add( listener );
} }
@Override
public void removeErrorListener( ErrorListener<? super Client> listener ) public void removeErrorListener( ErrorListener<? super Client> listener )
{ {
errorListeners.remove( listener ); errorListeners.remove( listener );
@ -470,11 +488,13 @@ public class DefaultClient implements Client
protected class Redispatch implements MessageListener<Object>, ErrorListener<Object> protected class Redispatch implements MessageListener<Object>, ErrorListener<Object>
{ {
@Override
public void messageReceived( Object source, Message m ) public void messageReceived( Object source, Message m )
{ {
dispatch( m ); dispatch( m );
} }
@Override
public void handleError( Object source, Throwable t ) public void handleError( Object source, Throwable t )
{ {
// Only doing the DefaultClient.this to make the code // Only doing the DefaultClient.this to make the code

@ -66,26 +66,26 @@ public class DefaultServer implements Server
private static final int CH_FIRST = 2; private static final int CH_FIRST = 2;
private boolean isRunning = false; private boolean isRunning = false;
private AtomicInteger nextId = new AtomicInteger(0); private final AtomicInteger nextId = new AtomicInteger(0);
private String gameName; private String gameName;
private int version; private int version;
private KernelFactory kernelFactory = KernelFactory.DEFAULT; private final KernelFactory kernelFactory = KernelFactory.DEFAULT;
private KernelAdapter reliableAdapter; private KernelAdapter reliableAdapter;
private KernelAdapter fastAdapter; private KernelAdapter fastAdapter;
private List<KernelAdapter> channels = new ArrayList<KernelAdapter>(); private final List<KernelAdapter> channels = new ArrayList<KernelAdapter>();
private List<Integer> alternatePorts = new ArrayList<Integer>(); private final List<Integer> alternatePorts = new ArrayList<Integer>();
private Redispatch dispatcher = new Redispatch(); private final Redispatch dispatcher = new Redispatch();
private Map<Integer,HostedConnection> connections = new ConcurrentHashMap<Integer,HostedConnection>(); private final Map<Integer,HostedConnection> connections = new ConcurrentHashMap<Integer,HostedConnection>();
private Map<Endpoint,HostedConnection> endpointConnections private final Map<Endpoint,HostedConnection> endpointConnections
= new ConcurrentHashMap<Endpoint,HostedConnection>(); = new ConcurrentHashMap<Endpoint,HostedConnection>();
// Keeps track of clients for whom we've only received the UDP // Keeps track of clients for whom we've only received the UDP
// registration message // registration message
private Map<Long,Connection> connecting = new ConcurrentHashMap<Long,Connection>(); private final Map<Long,Connection> connecting = new ConcurrentHashMap<Long,Connection>();
private MessageListenerRegistry<HostedConnection> messageListeners private final MessageListenerRegistry<HostedConnection> messageListeners
= new MessageListenerRegistry<HostedConnection>(); = new MessageListenerRegistry<HostedConnection>();
private List<ConnectionListener> connectionListeners = new CopyOnWriteArrayList<ConnectionListener>(); private final List<ConnectionListener> connectionListeners = new CopyOnWriteArrayList<ConnectionListener>();
private HostedServiceManager services; private HostedServiceManager services;
@ -112,21 +112,25 @@ public class DefaultServer implements Server
services.addService(new ServerSerializerRegistrationsService()); services.addService(new ServerSerializerRegistrationsService());
} }
@Override
public String getGameName() public String getGameName()
{ {
return gameName; return gameName;
} }
@Override
public int getVersion() public int getVersion()
{ {
return version; return version;
} }
@Override
public HostedServiceManager getServices() public HostedServiceManager getServices()
{ {
return services; return services;
} }
@Override
public int addChannel( int port ) public int addChannel( int port )
{ {
if( isRunning ) if( isRunning )
@ -165,6 +169,7 @@ public class DefaultServer implements Server
} }
} }
@Override
public void start() public void start()
{ {
if( isRunning ) if( isRunning )
@ -186,11 +191,13 @@ public class DefaultServer implements Server
services.start(); services.start();
} }
@Override
public boolean isRunning() public boolean isRunning()
{ {
return isRunning; return isRunning;
} }
@Override
public void close() public void close()
{ {
if( !isRunning ) if( !isRunning )
@ -215,11 +222,13 @@ public class DefaultServer implements Server
} }
} }
@Override
public void broadcast( Message message ) public void broadcast( Message message )
{ {
broadcast( null, message ); broadcast( null, message );
} }
@Override
public void broadcast( Filter<? super HostedConnection> filter, Message message ) public void broadcast( Filter<? super HostedConnection> filter, Message message )
{ {
if( log.isLoggable(Level.FINER) ) { if( log.isLoggable(Level.FINER) ) {
@ -242,6 +251,7 @@ public class DefaultServer implements Server
} }
} }
@Override
public void broadcast( int channel, Filter<? super HostedConnection> filter, Message message ) public void broadcast( int channel, Filter<? super HostedConnection> filter, Message message )
{ {
if( log.isLoggable(Level.FINER) ) { if( log.isLoggable(Level.FINER) ) {
@ -260,46 +270,55 @@ public class DefaultServer implements Server
channels.get(channel+CH_FIRST).broadcast( adapter, buffer, true, false ); channels.get(channel+CH_FIRST).broadcast( adapter, buffer, true, false );
} }
@Override
public HostedConnection getConnection( int id ) public HostedConnection getConnection( int id )
{ {
return connections.get(id); return connections.get(id);
} }
@Override
public boolean hasConnections() public boolean hasConnections()
{ {
return !connections.isEmpty(); return !connections.isEmpty();
} }
@Override
public Collection<HostedConnection> getConnections() public Collection<HostedConnection> getConnections()
{ {
return Collections.unmodifiableCollection((Collection<HostedConnection>)connections.values()); return Collections.unmodifiableCollection((Collection<HostedConnection>)connections.values());
} }
@Override
public void addConnectionListener( ConnectionListener listener ) public void addConnectionListener( ConnectionListener listener )
{ {
connectionListeners.add(listener); connectionListeners.add(listener);
} }
@Override
public void removeConnectionListener( ConnectionListener listener ) public void removeConnectionListener( ConnectionListener listener )
{ {
connectionListeners.remove(listener); connectionListeners.remove(listener);
} }
@Override
public void addMessageListener( MessageListener<? super HostedConnection> listener ) public void addMessageListener( MessageListener<? super HostedConnection> listener )
{ {
messageListeners.addMessageListener( listener ); messageListeners.addMessageListener( listener );
} }
@Override
public void addMessageListener( MessageListener<? super HostedConnection> listener, Class... classes ) public void addMessageListener( MessageListener<? super HostedConnection> listener, Class... classes )
{ {
messageListeners.addMessageListener( listener, classes ); messageListeners.addMessageListener( listener, classes );
} }
@Override
public void removeMessageListener( MessageListener<? super HostedConnection> listener ) public void removeMessageListener( MessageListener<? super HostedConnection> listener )
{ {
messageListeners.removeMessageListener( listener ); messageListeners.removeMessageListener( listener );
} }
@Override
public void removeMessageListener( MessageListener<? super HostedConnection> listener, Class... classes ) public void removeMessageListener( MessageListener<? super HostedConnection> listener, Class... classes )
{ {
messageListeners.removeMessageListener( listener, classes ); messageListeners.removeMessageListener( listener, classes );
@ -493,12 +512,12 @@ public class DefaultServer implements Server
protected class Connection implements HostedConnection protected class Connection implements HostedConnection
{ {
private int id; private final int id;
private boolean closed; private boolean closed;
private Endpoint[] channels; private Endpoint[] channels;
private int setChannelCount = 0; private int setChannelCount = 0;
private Map<String,Object> sessionData = new ConcurrentHashMap<String,Object>(); private final Map<String,Object> sessionData = new ConcurrentHashMap<String,Object>();
public Connection( int channelCount ) public Connection( int channelCount )
{ {
@ -532,21 +551,25 @@ public class DefaultServer implements Server
return setChannelCount == channels.length; return setChannelCount == channels.length;
} }
@Override
public Server getServer() public Server getServer()
{ {
return DefaultServer.this; return DefaultServer.this;
} }
@Override
public int getId() public int getId()
{ {
return id; return id;
} }
@Override
public String getAddress() public String getAddress()
{ {
return channels[CH_RELIABLE] == null ? null : channels[CH_RELIABLE].getAddress(); return channels[CH_RELIABLE] == null ? null : channels[CH_RELIABLE].getAddress();
} }
@Override
public void send( Message message ) public void send( Message message )
{ {
if( log.isLoggable(Level.FINER) ) { if( log.isLoggable(Level.FINER) ) {
@ -560,6 +583,7 @@ public class DefaultServer implements Server
} }
} }
@Override
public void send( int channel, Message message ) public void send( int channel, Message message )
{ {
if( log.isLoggable(Level.FINER) ) { if( log.isLoggable(Level.FINER) ) {
@ -588,6 +612,7 @@ public class DefaultServer implements Server
fireConnectionRemoved( this ); fireConnectionRemoved( this );
} }
@Override
public void close( String reason ) public void close( String reason )
{ {
// Send a reason // Send a reason
@ -608,6 +633,7 @@ public class DefaultServer implements Server
} }
} }
@Override
public Object setAttribute( String name, Object value ) public Object setAttribute( String name, Object value )
{ {
if( value == null ) if( value == null )
@ -616,11 +642,13 @@ public class DefaultServer implements Server
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override
public <T> T getAttribute( String name ) public <T> T getAttribute( String name )
{ {
return (T)sessionData.get(name); return (T)sessionData.get(name);
} }
@Override
public Set<String> attributeNames() public Set<String> attributeNames()
{ {
return Collections.unmodifiableSet(sessionData.keySet()); return Collections.unmodifiableSet(sessionData.keySet());
@ -636,6 +664,7 @@ public class DefaultServer implements Server
protected class Redispatch implements MessageListener<HostedConnection> protected class Redispatch implements MessageListener<HostedConnection>
{ {
@Override
public void messageReceived( HostedConnection source, Message m ) public void messageReceived( HostedConnection source, Message m )
{ {
dispatch( source, m ); dispatch( source, m );
@ -644,13 +673,14 @@ public class DefaultServer implements Server
protected class FilterAdapter implements Filter<Endpoint> protected class FilterAdapter implements Filter<Endpoint>
{ {
private Filter<? super HostedConnection> delegate; private final Filter<? super HostedConnection> delegate;
public FilterAdapter( Filter<? super HostedConnection> delegate ) public FilterAdapter( Filter<? super HostedConnection> delegate )
{ {
this.delegate = delegate; this.delegate = delegate;
} }
@Override
public boolean apply( Endpoint input ) public boolean apply( Endpoint input )
{ {
HostedConnection conn = getConnection( input ); HostedConnection conn = getConnection( input );

@ -53,7 +53,7 @@ import java.util.LinkedList;
*/ */
public class MessageProtocol public class MessageProtocol
{ {
private LinkedList<Message> messages = new LinkedList<Message>(); private final LinkedList<Message> messages = new LinkedList<Message>();
private ByteBuffer current; private ByteBuffer current;
private int size; private int size;
private Byte carry; private Byte carry;

@ -48,7 +48,7 @@ public abstract class ServiceManager<T> {
static final Logger log = Logger.getLogger(ServiceManager.class.getName()); static final Logger log = Logger.getLogger(ServiceManager.class.getName());
private List<Service<T>> services = new CopyOnWriteArrayList<Service<T>>(); private final List<Service<T>> services = new CopyOnWriteArrayList<Service<T>>();
private volatile boolean started = false; private volatile boolean started = false;
protected ServiceManager() { protected ServiceManager() {

Loading…
Cancel
Save