rath.msnm
Class AbstractProcessor

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--rath.msnm.AbstractProcessor
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
DispatchProcessor, NotificationProcessor, SwitchboardSession

public abstract class AbstractProcessor
extends Thread

°¢ DS, NS, SSÀÇ °øÅëÀÌ µÇ´Â ºÎºÐÀ» Ãß»óÀûÀ¸·Î ¹­¾î³õÀº Ŭ·¡½ºÀÌ´Ù.

Âü°í·Î ÇØ´ç Processor´Â Á×±âÀü¿¡ ¹«Á¶°Ç OUTÀ» º¸³½´Ù. º¸³»Áö ¾Ê°Ô ÇÏ·Á¸é setAutoOutSend(false) ¸¦ Ç϶ó.

Version:
$Id: AbstractProcessor.java,v 1.2 2002/03/04 05:30:59 xrath Exp $ , since 2001/11/07
Author:
Jang-Ho Hwang, rath@xrath.com

Field Summary
protected  HashMap callbackMap
           
protected  BufferedReader in
           
protected  boolean isLive
           
 MSNMessenger msn
           
protected  PrintWriter out
           
protected  Socket socket
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected AbstractProcessor(MSNMessenger msn)
          Client processor°¡ ¾Æ´Ñ Server processor·Î »ç¿ëÇÒ¶§ Áï, ServerInfo°¡ ÇÊ¿ä¾øÀ»¶§ ÀÌ »ý¼ºÀÚ¸¦ ÅëÇÏ¿© ÀνºÅϽº¸¦ »ý¼ºÇϵµ·Ï ÇÑ´Ù.
protected AbstractProcessor(MSNMessenger msn, ServerInfo info)
          ÁÖ¾îÁø ServerInfo¸¦ °¡Áö´Â Processor¸¦ »ý¼ºÇÑ´Ù.
protected AbstractProcessor(MSNMessenger msn, ServerInfo info, int trId)
          ÁÖ¾îÁø ServerInfo¸¦ °¡Áö°í trId¸¦ ÃÖÃÊ Æ®·£Àè¼Ç ¾ÆÀ̵ð·Î °¡Áö´Â Processor¸¦ »ý¼ºÇÑ´Ù.
 
Method Summary
abstract  void cleanUp()
          ½º·¹µå°¡ Á¾·áµÇ°í ½ºÆ®¸²À» ´Ý±â Á÷Àü¿¡ È£ÃâµÈ´Ù.
 int getCurrentTransactionId()
          ´ÙÀ½¿¡ Àü¼ÛµÇ¾î¾ßÇÒ trId¸¦ ¹ÝȯÇÑ´Ù.
 String getServerName()
           
abstract  void init()
          ¼­¹ö¿ÍÀÇ ¿¬°áÀÌ ¸Î¾îÁø ÈÄ ÇØÁÖ¾î¾ß ÇÒ ÀÏÀÌ ÀÖ´Ù¸é ÀÌ°÷¿¡ ÇØÁÖµµ·Ï ÇÑ´Ù.
 boolean isAutoOutSend()
          ÇØ´ç processor°¡ Á¾·áµÉ¶§ OUT ¸Þ½ÃÁö¸¦ ÀÚµ¿Àü¼ÛÇÏ°Ô µÇ¾îÀÖ´ÂÁö È®ÀÎÇÑ´Ù.
protected  Method lookupMethod(Callback cb)
           
protected  void makeConnection()
          ÇØ´ç server¿Í tcp/ip ¿¬°áÀ» ¸Î°í, ÀÔÃâ·Â ½ºÆ®¸²µéÀ» »ý¼ºÇÑ´Ù.
 void markTransactionId(OutgoingMessage msg)
          ÇØ´ç ¸Þ½ÃÁö¿¡ ÀûÀýÇÑ trId¸¦ ¼³Á¤ÇØÁØ´Ù.
 void processError(Throwable e)
          ÇØ´ç Processor¿¡¼­ ¹ß»ýµÇ´Â ¸ðµç ¿¹¿Ü´Â ÀÌ°÷¿¡¼­ ó¸®ÇÑ´Ù.
 void processMessage(IncomingMessage msg)
          ¼­¹ö·ÎºÎÅÍ µµÂøÇÏ´Â ¸Þ½ÃÁö (ÀϹæÀûÀÎ push°¡ ¾Æ´Ñ)¸¦ ó¸®ÇÏ´Â ºÎºÐÀÌ´Ù.
 void processNotifyMessage(IncomingMessage msg)
          Server·ÎºÎÅÍ ÀϹæÀûÀ¸·Î notifyµÇ´Â ¸Þ½ÃÁöµéÀ» ó¸®ÇÏ´Â ºÎºÐÀÌ´Ù.
protected  void registerCallback(Integer trId, Callback cb)
          ¼öµ¿À¸·Î callbackÀ» µî·Ï½ÃŲ´Ù.
 void removeInfiniteTransactionId(int trId)
          ¹«ÇÑ Callback ÀÌ¿´´ø trId¿¡ ´ëÇØ Á¾·á½ÃÁ¡ÀÌ µÇ¸é ÀÌ ¸Þ¼Òµå¸¦ ÅëÇØ ´õÀÌ»ó callback map¿¡ Á¸ÀçÇÏÁö ¾Êµµ·Ï ÇØÁ¦ÇÏ¿©¾ß ÇÑ´Ù.
 void run()
          Thread loop ºÎºÐ
 void sendCHLResponse(OutgoingMessage msg, String hash)
           
 void sendMessage(OutgoingMessage msg)
          º¸³»°íÀÚ ÇÏ´Â ¸Þ½ÃÁö¸¦ Àü¼ÛÇÏ°í, trId¸¦ Çϳª Áõ°¡½ÃŲ´Ù.
 void sendMimeMessage(OutgoingMessage msg, MimeMessage mime)
          MIME¸Þ½ÃÁö¸¦ º¸³¾ ¶§ »ç¿ëÇÑ´Ù.
 void setAutoOutSend(boolean autoOut)
          ÇØ´ç processor°¡ Á¾·áµÉ¶§ OUT ¸Þ½ÃÁö¸¦ ÀÚµ¿Àü¼ÛÇÒ °ÍÀÎÁö ¼³Á¤ÇÑ´Ù.
 void setServerName(String name)
           
 
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
 

Field Detail

msn

public final MSNMessenger msn

callbackMap

protected HashMap callbackMap

socket

protected Socket socket

isLive

protected boolean isLive

in

protected BufferedReader in

out

protected PrintWriter out
Constructor Detail

AbstractProcessor

protected AbstractProcessor(MSNMessenger msn)
Client processor°¡ ¾Æ´Ñ Server processor·Î »ç¿ëÇÒ¶§ Áï, ServerInfo°¡ ÇÊ¿ä¾øÀ»¶§ ÀÌ »ý¼ºÀÚ¸¦ ÅëÇÏ¿© ÀνºÅϽº¸¦ »ý¼ºÇϵµ·Ï ÇÑ´Ù.


AbstractProcessor

protected AbstractProcessor(MSNMessenger msn,
                            ServerInfo info)
ÁÖ¾îÁø ServerInfo¸¦ °¡Áö´Â Processor¸¦ »ý¼ºÇÑ´Ù. ±âº»ÀûÀ¸·Î Æ®·£Àè¼Ç ¾ÆÀ̵ð´Â 0ºÎÅÍ ½ÃÀ۵ȴÙ.


AbstractProcessor

protected AbstractProcessor(MSNMessenger msn,
                            ServerInfo info,
                            int trId)
ÁÖ¾îÁø ServerInfo¸¦ °¡Áö°í trId¸¦ ÃÖÃÊ Æ®·£Àè¼Ç ¾ÆÀ̵ð·Î °¡Áö´Â Processor¸¦ »ý¼ºÇÑ´Ù.

Method Detail

setServerName

public void setServerName(String name)

getServerName

public String getServerName()

setAutoOutSend

public void setAutoOutSend(boolean autoOut)
ÇØ´ç processor°¡ Á¾·áµÉ¶§ OUT ¸Þ½ÃÁö¸¦ ÀÚµ¿Àü¼ÛÇÒ °ÍÀÎÁö ¼³Á¤ÇÑ´Ù. ±âº»°ªÀº falseÀÌ´Ù.


isAutoOutSend

public boolean isAutoOutSend()
ÇØ´ç processor°¡ Á¾·áµÉ¶§ OUT ¸Þ½ÃÁö¸¦ ÀÚµ¿Àü¼ÛÇÏ°Ô µÇ¾îÀÖ´ÂÁö È®ÀÎÇÑ´Ù.


makeConnection

protected void makeConnection()
                       throws IOException
ÇØ´ç server¿Í tcp/ip ¿¬°áÀ» ¸Î°í, ÀÔÃâ·Â ½ºÆ®¸²µéÀ» »ý¼ºÇÑ´Ù. ÇöÀç´Â UTF-8 ÀÎÄÚµùÀ» ±âº»ÀûÀ¸·Î Çϵµ·Ï µÇ¾îÀÖ´Ù.

IOException

init

public abstract void init()
                   throws IOException
¼­¹ö¿ÍÀÇ ¿¬°áÀÌ ¸Î¾îÁø ÈÄ ÇØÁÖ¾î¾ß ÇÒ ÀÏÀÌ ÀÖ´Ù¸é ÀÌ°÷¿¡ ÇØÁÖµµ·Ï ÇÑ´Ù.

IOException

sendMessage

public void sendMessage(OutgoingMessage msg)
                 throws IOException
º¸³»°íÀÚ ÇÏ´Â ¸Þ½ÃÁö¸¦ Àü¼ÛÇÏ°í, trId¸¦ Çϳª Áõ°¡½ÃŲ´Ù.

IOException

sendMimeMessage

public void sendMimeMessage(OutgoingMessage msg,
                            MimeMessage mime)
                     throws IOException
MIME¸Þ½ÃÁö¸¦ º¸³¾ ¶§ »ç¿ëÇÑ´Ù.

IOException

sendCHLResponse

public void sendCHLResponse(OutgoingMessage msg,
                            String hash)
                     throws IOException
IOException

markTransactionId

public void markTransactionId(OutgoingMessage msg)
ÇØ´ç ¸Þ½ÃÁö¿¡ ÀûÀýÇÑ trId¸¦ ¼³Á¤ÇØÁØ´Ù. ³»ºÎÀûÀ¸·Î trId´Â Á¤¼öÇüÀ¸·Î 1¾¿ Áõ°¡ÇÏ°Ô µÈ´Ù.


getCurrentTransactionId

public int getCurrentTransactionId()
´ÙÀ½¿¡ Àü¼ÛµÇ¾î¾ßÇÒ trId¸¦ ¹ÝȯÇÑ´Ù.


lookupMethod

protected Method lookupMethod(Callback cb)
                       throws NoSuchMethodException,
                              SecurityException
NoSuchMethodException
SecurityException

registerCallback

protected void registerCallback(Integer trId,
                                Callback cb)
¼öµ¿À¸·Î callbackÀ» µî·Ï½ÃŲ´Ù.


processMessage

public void processMessage(IncomingMessage msg)
                    throws Exception
¼­¹ö·ÎºÎÅÍ µµÂøÇÏ´Â ¸Þ½ÃÁö (ÀϹæÀûÀÎ push°¡ ¾Æ´Ñ)¸¦ ó¸®ÇÏ´Â ºÎºÐÀÌ´Ù.

Exception

processNotifyMessage

public void processNotifyMessage(IncomingMessage msg)
                          throws Exception
Server·ÎºÎÅÍ ÀϹæÀûÀ¸·Î notifyµÇ´Â ¸Þ½ÃÁöµéÀ» ó¸®ÇÏ´Â ºÎºÐÀÌ´Ù. ÀÌ ¸Þ¼Òµå¸¦ Á÷Á¢ È£ÃâÇÏÁö´Â ¸»µµ·Ï Ç϶ó.

Exception

removeInfiniteTransactionId

public void removeInfiniteTransactionId(int trId)
¹«ÇÑ Callback ÀÌ¿´´ø trId¿¡ ´ëÇØ Á¾·á½ÃÁ¡ÀÌ µÇ¸é ÀÌ ¸Þ¼Òµå¸¦ ÅëÇØ ´õÀÌ»ó callback map¿¡ Á¸ÀçÇÏÁö ¾Êµµ·Ï ÇØÁ¦ÇÏ¿©¾ß ÇÑ´Ù.


run

public final void run()
Thread loop ºÎºÐ

Specified by:
run in interface Runnable
Overrides:
run in class Thread

cleanUp

public abstract void cleanUp()
½º·¹µå°¡ Á¾·áµÇ°í ½ºÆ®¸²À» ´Ý±â Á÷Àü¿¡ È£ÃâµÈ´Ù.


processError

public void processError(Throwable e)
ÇØ´ç Processor¿¡¼­ ¹ß»ýµÇ´Â ¸ðµç ¿¹¿Ü´Â ÀÌ°÷¿¡¼­ ó¸®ÇÑ´Ù. ¸¸¾à »ö´Ù¸¥ 󸮸¦ ÇÏ°í ½Í´Ù¸é, overridingÇ϶ó.