Re: high availability and failover for tcp/ip connections
On Sat, 18 May 2013 19:02:48 -0400, Arne Vajh?j wrote:
@Override
public synchronized int getReceiveBufferSize() throws SocketException {
throw new RuntimeException("Not supported by MultiSocket");
}
@Override
public void setKeepAlive(boolean on) throws SocketException {
throw new RuntimeException("Not supported by MultiSocket");
}
@Override
public boolean getKeepAlive() throws SocketException {
throw new RuntimeException("Not supported by MultiSocket");
}
[...several pages worth...]
You might want to look into Lombok(-pg):
-------------
@AutoGenMethodStub
With this annotation you can avoid cluttering your code with empty methods
that an interface forces you to implement. Just implement the ones you need
and lombok will create stubs for the rest.
-------------
For your use case:
-------------
@AutoGenMethodStub(throwException = true)
public class MultiSocket extends Socket { //...
-------------
Would then generate a bunch of methods looking like this, waiting for you
to only override the ones you use:
-------------
@Override
public int getTrafficClass() throws SocketException {
throw new java.lang.UnsupportedOperationException("This method is not
implemented yet.");
}
-------------
Lombok is also a compile-time library, so you need not ship it with your
product (with the exception of their weird function pointers, I believe).
More info at:
https://github.com/peichhorn/lombok-pg/wiki/%40AutoGenMethodStub
Because I love Lombok so much, I lombok'ed your class, so you can see them
next to each other:
Original (with slight auto-formatter changes):
http://pastebin.com/EJBcsVdZ
Lombok'd:
http://pastebin.com/rUFd47Hc
Things I changed: cut down the Destination class, cleaned up the remove()
method, and the aforementioned dummy implementations.
Liebe Gruesse,
Joerg
--
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.