Designing Servers to Use Dynamic Class Loading
If you spend much time creating socket-based network programs, it won't take long for you to notice a simple pattern. You usually create a main class that listens for incoming socket connections. You then create a separate class (or an inner class) to handle the new connection in a separate thread. Because the only thing that really changes is the way you handle the clients, why not create a generic socket service to make it easier to create socket applications?
You start by creating a common interface for client handlers, like the one shown in Listing 40.4.
Code Listing 40.4. Source Code for ClientHandler.java
package usingj2ee.dynclass; import java.net.*; public interface ClientHandler extends ... |
Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.