|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.lang.Thread
org.wegra.net.Server
¹ü¿ëÀûÀÎ ¼¹öÃø ¼ÒÄÏÀ¸·Î Ŭ¶óÀÌ¾ðÆ® °ü·Ã ÀÛ¾÷µéÀ» ÀÚü ½º·¹µå¿¡¼ ó¸® ÇÑ´Ù. ´ÙÀ½°ú °°ÀÌ »ç¿ëÇÏ¸é µÈ´Ù.
class ConnectionStrategy implenents ClientSocket {
protected void communicate( Socket socket ) {
// Ŭ¶óÀÌ¾ðÆ®¿¡ ´ëÇÑ Ä¿³Ø¼ÇÀÌ ¸Î¾îÁú ¶§¸¶´Ù È£ÃâµÈ´Ù.
// ÀÌ ¸Þ¼Òµå´Â ÀϾ¾ß ÇÒ Åë½Å¿¡ ´ëÇÑ ¸ðµç °ÍÀ» ĸ½¶ÈÇÑ´Ù.
// ÀÌ ¸Þ¼Òµå´Â º°µµÀÇ ½º·¹µå¿¡¼ ½ÇÇàµÇ¸ç
// ClientSocket °´Ã¼´Â ´ÙÀ½ Ä¿³Ø¼ÇÀ» À§ÇØ ÀçȰ¿ëµÈ´Ù.
// µû¶ó¼, ClientSocket °´Ã¼´Â ¾ðÁ¦³ª communicate() ¸Þ¼Òµå
//°¡Àå óÀ½¿¡ ÃʱâȵǾî¾ß ÇÑ´Ù.
}
public Object replicate() {
return new ConnectionStrategy();
}
};
Server echoServer = new Server( portNumber,
expectedConnectionCount,
new ConnectionStrategy(),
new SocketServer.Death);
| Nested Class Summary | |
static class |
Server.Test
Å×½ºÆ®¿ë Ŭ·¡½º. |
| Field Summary |
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
Server(int portNumber,
int expectedConnections,
Client connectionStrategy,
ShutdownOperation shutdownStrategy)
¼¹ö ¼ÒÄÏ ½º·¹µå¸¦ ¸¸µé°Å ¼¹ö ¼ÒÄÏÀ» ¸¸µé¾î À¯ÁöÇÑ´Ù. |
|
| Method Summary | |
void |
kill()
SocketServer ½º·¹µå¸¦ ¾ÈÀüÇÏ°Ô Á¾·á½ÃŲ´Ù. |
void |
run()
"accept" ¼øÈ¯¹®À» ±¸ÇöÇÑ´Ù. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Server(int portNumber,
int expectedConnections,
Client connectionStrategy,
ShutdownOperation shutdownStrategy)
throws java.lang.InstantiationException
portNumber - ¼¹ö ¼ÒÄÏÀÇ Æ÷Æ® ¹øÈ£expectedConnections - ¿¹»óµÇ´Â µ¿½Ã Á¢¼ÓÀÚ ¼ö
¿©±â¼ ÁöÁ¤ÇÏ´Â °ªº¸´Ù ¸¹Àº Ä¿³Ø¼ÇÀ»
ó¸®ÇÒ ¼ö´Â ÀÖÁö¸¸ ÀÌ °æ¿ì Ŭ¶óÀÌ¾ðÆ®°¡
Á¢¼ÓµÉ ¶§ »õ·Ó°Ô ½º·¹µå¸¦ ¸¸µé¾î¾ß ÇÑ´Ù.connectionStrategy - ClientSocket À» »ó¼Ó¹Þ´Â Ŭ·¡½ºÀÇ ÀνºÅϽº
¸¦ ³Ö¾îÁÖ¸é µÇ¸ç ¿©±â¿¡¼´Â °¢ Ŭ¶óÀ̾ðÆ®
Ä¿³Ø¼Ç¿¡¼ ÇØ¾ßÇÒ ÀϵéÀ» ĸ½¶ÈÇÑ´Ù.
ÀÌ °´Ã¼´Â Çʿ信 µû¶ó º¹Á¦µÇ¸ç ÀÌ·¯ÇÑ º¹Á¦´Â
GoF Ã¥ÀÇ ÇÁ·ÎÅäŸÀÔ ÆÐÅÏÀ» Àû¿ëÇÑ °ÍÀÌ´Ù.
Áï, connectionStrategy °´Ã¼´Â ½ÇÁ¦·Î »ç¿ëµÉ
°´Ã¼¿¡ ´ëÇÑ ÇÁ·ÎÅäŸÀÔÀÎ ¼ÀÀÌ´Ù.shutdownStrategy - ShutdownOperation Àº ¼¹ö ½º·¹µå°¡ Á¾·áµÉ ¶§
ÇÒ ÀÏÀ» ĸ½¶ÈÇÑ´Ù(kill() ¿¡ ÀÇÇØ Á¾·áµÇ°Å³ª
³»ºÎÀûÀ¸·Î Á¾·áµÇ´Â °æ¿ì ¸ðµÎ ½ÇÇàµÈ´Ù).
java.lang.InstantiationError - ¸¸¾à °´Ã¼°¡ ¾î¶°ÇÑ ÀÌÀ¯¿¡¼°Ç ¼º°øÀûÀ¸·Î
»ý¼ºµÇÁö ¸øÇß´Ù¸é ¹ß»ýÇÑ´Ù(¼ÒÄÏÀÌ ¿¸®Áö
¸øÇϰųª Ŭ¶óÀ̾ðÆ®ÀÇ ÀÛ¾÷ÀÌ »ý¼ºµÉ ¼ö ¾øÀ»
°æ¿ì µî).
¹ß»ýÇÑ´Ù.
java.lang.InstantiationException| Method Detail |
public final void kill()
public void run()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||