Commons-Digester
I. Digester ?
digester´Â XMLÆÄÀÏ·Î ÀúÀåµÈ Á¤º¸¸¦ java °´Ã¼¿¡ ¸ÅÇÎÇØ ÁÖ´Â APIÀÔ´Ï´Ù. ÇÏÁö¸¸ ±× ¹Ý´ë±â´ÉÀº µÇÁö ¾Ê½À´Ï´Ù.
º¸ÅëÀº XMLÆÄÀÏÀ» parsingÇÒ¶§ SAX¿Í DOMÀ» ÀÌ¿ëÇÏ¿´Áö¸¸ DOMÀº ¼º´ÉÀÌ Á» ´À¸®°í, SAX´Â DOMº¸´Ù´Â ºü¸£Áö¸¸ Äڵ尡 ³ÀâÇØ Áý´Ï´Ù. digester´Â SAX±â¹ÝÀÌÁö¸¸ pattern ¸ÅĪÀ¸·Î ¾ÆÁÖ ½±°í ºü¸£°Ô XML ÆÄÀÏÀ» parsingÇÕ´Ï´Ù
¿ø·¡ digester´Â strutsÀÇ struts-config.xml Á¤º¸¸¦ ·ÎµùÇϱâÀ§ÇØ °³¹ßµÇ¾î strutsÀÇ ÇÑ ºÎºÐÀ̾ú´Âµ¥ µ¶¸³ÀûÀ¸·Î commons project·Î ºÐ¸®µÇ¾ú½À´Ï´Ù.
II. Áغñ¹°
digester¸¦ »ç¿ëÇϱâ À§Çؼ´Â ´ÙÀ½ 4°¡Áö Áغñ¹°ÀÌ ÇÊ¿äÇÕ´Ï´Ù
commons-digester http://jakarta.apache.org/site/downloads/downloads_commons-digester.cgi
commons-beanutils http://jakarta.apache.org/site/downloads/downloads_commons-beanutils.cgi
commons-collections http://jakarta.apache.org/site/downloads/downloads_commons-collections.cgi
commons-logging http://jakarta.apache.org/site/downloads/downloads_commons-logging.cgi
¸¸¾à digester´Â SAX API¸¦ »ç¿ëÇϱ⠶§¹®¿¡ jdk1.4 ÀÌ»óÀÇ ¹öÁ¯ÀÌ ¾Æ´Ï¶ó¸é Xerces°°Àº XML parser°¡ ÇÊ¿äÇÕ´Ï´Ù
¾Æ·¡¿¹Á¦¸¦ ½ÇÇàÇÏ·Á¸é dbcp °ü·Ã ÆÄÀϵµ ÇÊ¿äÇϸç ÀÌ´Â Commons-dbcp ÆíÀ» ÂüÁ¶Çϼ¼¿ä~
Âü°í »çÀÌÆ®
commons-digester API http://jakarta.apache.org/commons/digester/commons-digester-1.6/docs/api/index.html
commons-digester Guide http://jakarta.apache.org/commons/digester/apidocs/org/apache/commons/digester/package-summary.html
III. ½ÃÀÛÇϱâ Àü¿¡..
º¸Åë digester´Â ¿©·¯ ¼³Á¤°ªµéÀ» xml¿¡ Á¤ÀÇÇØ ³õ°í À̸¦ ¾îÇø®ÄÉÀ̼ǿ¡¼ ·ÎµåÇÏ´Â ¹æ½ÄÀ¸·Î ¸¹ÀÌ ÀÌ¿ëµË´Ï´Ù. ÀÌ °Á¿¡¼µµ µ¥ÀÌÅͺ£À̽º Á¤º¸¸¦ xml¿¡ Á¤ÀÇÇØ ³õ°í À̸¦ ·ÎµùÇÏ¿© µ¥ÀÌÅͺ£À̽º¿¡ ¿¬°áÇÏ´Â ¿¹Á¦¸¦ °ÀÇÇÒ °ÍÀÔ´Ï´Ù.
½ÃÀÛÇϱâ Àü¿¡ XML¿¡ ´ëÇÑ ¾î´ÀÁ¤µµ ±âº» Áö½ÄÀÌ ÇÊ¿äÇÕ´Ï´Ù.
¨ç ÁÖ¿äÇÔ¼ö
´Ù¸¥ ÇÔ¼öµéµµ ¸¹À̸¸ °¡Àå ¸¹ÀÌ »ç¿ëµÇ´Â ´ÙÀ½ 4°¡Áö¸¸ µü ´«À¸·Î ÀÍÈ÷°í °©½Ã´Ù
´ë°Àº ÀÌ·± ¶æÀ¸·Î ¾Ë°í ³Ñ¾î °©½¬´Ù~!
±×·³ element °æ·Î°¡ ¸Õ°¡¿ä? ´ÙÀ½¿¡ ³ª¿É´Ï´Ù
¨è Element Matching Pattern
XML¿¡ elementµéÀÇ path¸¦ patternÀ¸·Î ÀνÄÇÏ´Â ¹æ¹ý¸¸ ÀÍÈü½Ã´Ù.
À§ XMLÀ» º¸¸é element a°¡ ÃÖ»óÀ§ ·çÆ® element ÀÔ´Ï´Ù.
ÀÌ°ÍÀº "a"·Î ¸ÅĪµÇ¸ç ±×´ÙÀ½ aÀÇ ¼ºê element b´Â "a/b" ·Î ¸ÅĪÇÕ´Ï´Ù
±×´ÙÀ½Àº .. "a/b/c"..
½±ÁÒ?
Áï ÃÖ»óÀ§¸¸ "/"°¡ ºÙÁö ¾ÊÀ¸¸ç ±× ÀÌÇÏ´Â Æ®¸®±¸Á¶Ã³·³ "/"¸¦ ºÙ¿©ÁÖ¸é µË´Ï´Ù
ÀÚ ±×·³ Á»Àü¿¡ º¸¾Ò´ø ÇÔ¼öµé°ú ¿¬°üÁö¾î º¸¸é..
¿ä·¸°Ô ¾²ÀÔ´Ï´Ù.
IV. Digester¸¦ ÀÌ¿ëÇÏ¿© µ¥ÀÌÅͺ£À̽º Ä¿³Ø¼Ç Á¤º¸¸¦ DBCP·Î ¸ÖƼ ¼³Á¤ÇÏ¿© À¥¿¡¼ »ç¿ëÇØ º¸ÀÚ!
ÀÚ ÀÌÁ¦ ½ÇÁúÀûÀÎ ¿¹Á¦¸¦ º¾½Ã´Ù~
¹«¾ùÀ» ÇÏ·Á°í ÇÏ·Á¸é mysql°ú oracle jdbcÁ¤º¸¸¦ xml ÆÄÀÏ¿¡ ±â·ÏÇØ µÎ°í À̸¦ µü Çѹø¸¸ ÀÐ¾î¼ ÀÌÁ¤º¸¸¦ µ¥ÀÌÅͺ£À̽º Ä¿³Ø¼ÇÇ®ÀÎ dbcp¿¡ ¼³Á¤ÇÒ °ÍÀÔ´Ï´Ù
¨ç XML ÆÄÀÏ
´ÙÀ½°ú °°Àº XML ÆÄÀÏÀÌ ÀÖ½À´Ï´Ù. ÀÌ ÆÄÀÏÀº mysql°ú oracleÀ» ¿¬°áÇÏ´Â Ä¿³Ø¼Ç Á¤º¸¸¦ °¡Áö°í ÀÖ½À´Ï´Ù
ÀÌ ÆÄÀÏÀ̸§Àº C:\Tomcat 5.0\webapps\ROOT\WEB-INF\classes\config.xmlÀÔ´Ï´Ù
mysql°ú oracle µÎ°³ÀÇ jdbc poolÀ» dbcp·Î ¼³Á¤ÇÒ °ÍÀÔ´Ï´Ù.
ÀÌ ÆÄÀÏÀº Á¦°¡ ÀÓÀÇ·Î Á¤Çؼ ¸¸µç°Ì´Ï´Ù.
¨è web.xml
À¥ ¹èÄ¡ÆÄÀÏ¿¡ ÀÇÇØ db.ConnectionInitialize.java¸¦ Ãʱ⠼ºí¸´ ÄÁÅ×ÀÌ³Ê ·Îµù½Ã ½ÇÇàÇÏ¿© XMLÁ¤º¸¸¦ DBCP·Î ¼¼ÆÃÇÒ °ÍÀÔ´Ï´Ù
config.xml ÆÄÀÏ°æ·Î¸¦ config ÆĶó¹ÌÅÍ¿¡ ¼³Á¤ÇÕ´Ï´Ù
¨é db.jdbc.ConnectionSources.java
XML ÆÄÀÏ¿¡¼µµ º¸¸é ¾Ë¼öÀÖµíÀÌ connection-sources ¼ºê¿ä¼ÒÀÎ description°ú JDBCConnectionPoolÀ» ÀúÀåÇÏ´Â °´Ã¼ÀÔ´Ï´Ù. º¯¼ö¸¦ ´«¿©°Ü º¾½Ã´Ù
addSource ÇÔ¼ö´Â ¿©·¯ JDBCConnectionPool Á¤º¸¸¦ ConnectionSourcec ÀÇ source¿¡ ÀúÀåÇÕ´Ï´Ù. ÀÌ ÇÔ¼ö´Â ¹Ø¿¡¼ ´Ù½Ã ³ª¿À´Ï ´«¿©°Ü º¾½Ã´Ù
¨ê db.jdbc.JDBCConnectionPool.java
º¯¼ö¿¡ ´ëÇØ ´Ü¼øÈ÷ setter, getter·Î ÀÌ·ç¾îÁ® ÀÖ½À´Ï´Ù.
XML ÆÄÀÏÀ» º¸¸éJDBCConnectionPool ÀÇ ¼ºê elementµéÀ» ÀúÀåÇÏ´Â °´Ã¼À̸ç XMLÆÄÀÏ°ú ÀÌ java º¯¼ö¸íµé°ú ¸ÅĪµÇ´Â°ÍÀ» ¾Ë¼ö ÀÖÀ»°Ì´Ï´Ù.
´ë° °¨ÀÌ ¿À³ª¿ä? ¤Ñ.¤Ñ? °¨ÁºÁ¾²~?
¨ë db.ConnectionInitialize.java
ÀÚ ÀÌÁ¦ ¿©±â°¡ ÇÙ½É Å¬·¡½ºÀÔ´Ï´Ù. À§ºÎºÐÀÌ ¸ðµÎÀÌÇØ°¡ µÇ¾úÀ¸¸é ´ÙÀ½ ¼Ò½ºÄڵ带 »ìÆ캾½Ã´Ù
web.xml¿¡¼ Á¤ÀÇÇÑ config.xmlÀ» ·ÎµùÇÏ¿© ÆĽÌÇÏ°í ±× Á¤º¸¸¦ DBCP¿¡ ¼³Á¤ÇÕ´Ï´Ù
mysql°ú oracle µÎ°³ÀÇ jdbc¸¦ ¼³Á¤Çϵµ·Ï xml¿¡ Á¤ÀÇÇÏ¿´¾ú½À´Ï´Ù.
¨ì ±×·³ ÀÌ·¸°Ô ¼³Á¤ÇÑ DBCP´Â ¾î¶»°Ô »ç¿ëÇÒ±î¿ä?
ÀÌÀü°Á¿¡¼ º¸¾Ò´ø ConnectionContext.java¿Í ConnectionResource.java¸¦ ´Ù½Ã »ç¿ëÇغ¾½Ã´Ù
ConectionContext¸¦ ±¸ÇöÇÑ ConnectionResource´Â Ç®À̸§À» ¹Þ¾Æ ó¸®Çϴ°ÍÀ¸·Î ¼öÁ¤ÇÏ¿´½À´Ï´Ù
¨í jsp ÆÄÀÏ
¸¶Áö¸·À¸·Î ConnectionContext´Â Ç®À̸§°ú ÇÔ²² »ç¿ëÇÏ¸é µÇ°Ú³×¿ä
DBCP ºÎºÐÀº ÀÌÀü °ÁÂÀÎ Commons-dbcp (http://www.jakartaproject.com/article/jakarta/1111890409958 )ºÎºÐÀ» ÂüÁ¶Çϼ¼¿ä~
ps. ÈÞ =3 ´Ù½è´ç ^_^
Èì.. ½±°Ô¾´´Ù°í À̸® Àú¸® ÇÏ·çÁ¾ÀÏ ½è´Âµ¥ ¼³¸íÀÌ ¸¹ÀÌ ºÎÁ·ÇÑ°Í °°³×¿ä
±×¹Û¿¡ »çÇ×Àº ¾Ë¾Æ¼ ã¾Æº¸±â~!
digester IIź¿¡¼´Â xml ¼³Á¤ÆÄÀϷκÎÅÍ ±ÔÄ¢À» Àоî xmlÀ» ÆĽÌÇÏ´Â ¹æ¹ýÀ» ¾Ë¾Æº¸°Ú½À´Ï´Ù~
=============================================
º»¹®¼´Â ÀÚÀ¯·Ó°Ô ¹èÆ÷/º¹»ç ÇÒ¼ö ÀÖÁö¸¸
À̹®¼ÀÇ ÀúÀÚ¿¡ ´ëÇÑ ¾ð±ÞÀ» »èÁ¦ÇÏ½Ã¸é ¾ÈµË´Ï´Ù
ÀúÀÚ : GoodBug (unicorn@jakartaproject.com)
ÃÖÃÊ : http://www.jakartaproject.com
=============================================