Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace static SocketFactory by interface+implementations.
- Loading branch information
Showing
27 changed files
with
269 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package fitnesse.socketservice; | ||
|
||
import java.io.IOException; | ||
import java.net.Socket; | ||
|
||
public interface ClientSocketFactory { | ||
|
||
/** | ||
* Create a client socket. | ||
* @param hostName host to connect to. | ||
* @param port port to connect to. | ||
* @return A fresh socket. | ||
* @throws IOException Thrown if socket can not be opened. | ||
*/ | ||
Socket createSocket(String hostName, int port) throws IOException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package fitnesse.socketservice; | ||
|
||
import java.io.IOException; | ||
import java.net.Socket; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class PlainClientSocketFactory implements ClientSocketFactory { | ||
private static final Logger LOG = Logger.getLogger(PlainClientSocketFactory.class.getName()); | ||
|
||
@Override | ||
public Socket createSocket(final String hostName, final int port) throws IOException { | ||
LOG.log(Level.FINER, "Creating plain client: " + hostName + ":" + port); | ||
return new Socket(hostName, port); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package fitnesse.socketservice; | ||
|
||
import java.io.IOException; | ||
import java.net.ServerSocket; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class PlainServerSocketFactory implements ServerSocketFactory { | ||
private static final Logger LOG = Logger.getLogger(PlainServerSocketFactory.class.getName()); | ||
|
||
@Override | ||
public ServerSocket createServerSocket(final int port) throws IOException { | ||
LOG.log(Level.FINER, "Creating plain socket on port: " + port); | ||
return new ServerSocket(port); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package fitnesse.socketservice; | ||
|
||
import java.io.IOException; | ||
import java.net.ServerSocket; | ||
|
||
public interface ServerSocketFactory { | ||
|
||
/** | ||
* Create a new socket on the provided port number | ||
* | ||
* @param port port | ||
* @return A fresh socket. | ||
* @throws IOException Thrown if socket can not be created. | ||
*/ | ||
ServerSocket createServerSocket(int port) throws IOException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.