Daejeon IT Developer Conference Web Service Practice

1,124 views

Published on

Daejeon IT Developer Conference Web Service Practice

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,124
On SlideShare
0
From Embeds
0
Number of Embeds
101
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Daejeon IT Developer Conference Web Service Practice

  1. 1. 본 문서의 배포 및 변경 , 출력 및 활용에 관한 모든 권리는 작성자에 있습니다 . 본 서비스는 제 1 회 대전 IT 개발자 커뮤니티 참석자를 위해 제공됩니다 .
  2. 2. 웹 서비스 개발 실습 심익찬 대전개발자커뮤니티 September 28 th , 2008
  3. 3. 목차 <ul><li>Choice </li></ul><ul><li>Practical </li></ul><ul><li>Web Develope Environment </li></ul><ul><li>Before & After </li></ul><ul><li>Summary </li></ul>
  4. 4. Choice <ul><li>XDoclet </li></ul>Document Focus <ul><li>Struts </li></ul><ul><li>Spring </li></ul><ul><li>Hibernate </li></ul><ul><li>iBATIS </li></ul>Framework Focus <ul><li>Subversion </li></ul><ul><li>Bug </li></ul>Team Focus <ul><li>Mantis </li></ul><ul><li>Builder </li></ul><ul><li>UI Tools </li></ul>Developement Focus Choice
  5. 5. Practical Practical
  6. 6. Web Develope Environment Tomcat 6 JDK 6 Windows XP Ant 1.7 Struts 2 Subversion Hibernate 3 Eclipse 3.4 iBATIS 2 or <ul><li>Create Project </li></ul><ul><li>Make Source Folder </li></ul><ul><li>Configuration </li></ul><ul><li>web.xml </li></ul><ul><li>hibernate.cfg.xml </li></ul><ul><li>struts.xml </li></ul><ul><li>etc... </li></ul>개발 환경
  7. 7. Web Develope Environment 프로젝트 소스 폴더 Xxx.hbm.xml hbm vo community net src project XxxService.java service community net src project IXxxService.java iface service community net src project XxxHibernateDao.java XxxIbatisDao.java persistence community net src project IXxxDao.java iface persistence community net src project ActionXxx.java action community net src project HibernateSessionFactory.java hibernate common community net src project Struts2Dispatcher.java filter common community net src project hibernate.cfg.xml struts.xml struts.properties message.properties project web.xml WEB-INF WebContent project Xxx.java vo community net src project Step 5 Step 4 Step 3 Step 2 Step 7 Step 6 Step 1
  8. 8. Practical <ul><li>Eclipse IDE </li></ul>프로젝트 소스 폴더 (Eclipse IDE)
  9. 9. Practical <ul><li>Eclipse IDE </li></ul>프로젝트 소스 폴더 (Eclipse IDE)
  10. 10. Practical <filter> <filter-name>struts2</filter-name> <filter-class> type.company.common.filter.Struts2Dispatcher </filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> web.xml
  11. 11. Practical <?xml version= '1.0' encoding= 'utf-8' ?> <!DOCTYPE hibernate-configuration PUBLIC &quot;-//Hibernate/Hibernate Configuration DTD//EN&quot; &quot;http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd&quot;> <hibernate-configuration> <session-factory> <!-- <property name=&quot;connection.driver_class&quot;> com.mysql.jdbc.Driver </property> <property name=&quot;connection.url&quot;> jdbc:mysql://localhost:3306/community </property> <property name=&quot;connection.username&quot;> root </property> <property name=&quot;connection.password&quot;> mysql </property> <property name=&quot;dialect&quot;> org.hibernate.dialect.MySQLDialect </property> --> hibernate.cfg.xml
  12. 12. Practical <property name= &quot;hibernate.connection.datasource&quot; > java:/comp/env/jdbc/community </property> <property name= &quot;hibernate.show_sql&quot; > true </property> <property name= &quot;hibernate.format_sql&quot; > true </property> <property name= &quot;connection.useUnicode&quot; > true </property> <property name= &quot;connection.characterEncoding&quot; > utf8 </property> <property name= &quot;current_session_context_class&quot; > thread </property> <property name= &quot;hibernate.transaction.factory_class&quot; > org.hibernate.transaction.JDBCTransactionFactory </property> <mapping resource= &quot; type/company/vo/hbm/User.hbm.xml &quot; /> </session-factory> </hibernate-configuration> 정보 : Starting Servlet Engine: Apache Tomcat/6.0.16 AbandonedObjectPool is used (org.apache.tomcat.dbcp.dbcp.AbandonedObjectPool@14d1d41) LogAbandoned: true RemoveAbandoned: true RemoveAbandonedTimeout: 60 hibernate.cfg.xml
  13. 13. Practical <?xml version= &quot;1.0&quot; encoding= &quot;UTF-8&quot; ?> <!DOCTYPE struts PUBLIC &quot;-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quot; &quot;http://struts.apache.org/dtds/struts-2.0.dtd&quot;> <struts> <package name= &quot; struts2 &quot; extends= &quot; struts-default &quot; > </package> </struts> struts.xml
  14. 14. Before & After <ul><li>VO (Value Object) or Domain </li></ul><ul><li>public class User implements Serializable { </li></ul><ul><li>private int userNumber; // 회원 번호 </li></ul><ul><li>private String userId; // 회원 ID </li></ul><ul><li>private String userPassword; // 회원 비밀번호 </li></ul><ul><li>private String koreaName; // 회원 성명 ( 한글 ) </li></ul><ul><li>private String englishName; // 회원 성명 ( 영문 ) </li></ul><ul><li>private String emailAddress; // 이메일 주소 </li></ul><ul><li>private String messengerAddress; // 메신저 주소 </li></ul><ul><li>private String phoneNumber; // 전화 번호 </li></ul><ul><li>.... </li></ul><ul><li>} </li></ul>VO
  15. 15. Before & After <ul><li>hbm.xml </li></ul><ul><li><?xml version= &quot;1.0&quot; ?> </li></ul><ul><li><!DOCTYPE hibernate-mapping PUBLIC &quot;-//Hibernate/Hibernate Mapping DTD 3.0//EN&quot; </li></ul><ul><li>&quot;http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd&quot;> </li></ul><ul><li><hibernate-mapping> </li></ul><ul><li><class name= &quot; type.company.vo.User &quot; table= &quot; user &quot; > </li></ul><ul><li><id name= &quot;userNumber&quot; type= &quot;int&quot; column= &quot;user_number&quot; length= &quot;10&quot; > </li></ul><ul><li><generator class= &quot;identity&quot; /> </li></ul><ul><li></id> </li></ul><ul><li><property name= &quot;userId&quot; type= &quot;string&quot; column= &quot;user_id“ length= &quot;40&quot; /> </li></ul><ul><li><property name= &quot;userPassword&quot; type= &quot;string“ column= &quot;user_password&quot; length= &quot;40&quot; /> </li></ul><ul><li><property name= &quot;koreaName&quot; type= &quot;string&quot; column= &quot;korea_name&quot; length= &quot;60&quot; /> </li></ul><ul><li><property name= &quot;englishName&quot; type= &quot;string&quot; column= &quot;english_name&quot; length= &quot;60&quot; /> </li></ul><ul><li>... </li></ul>hbm.xml
  16. 16. Before & After <ul><li>iface </li></ul><ul><li>public interface IUcujucDao { </li></ul><ul><li>// 인원 가입 정보 관리 ( 입력 ) </li></ul><ul><li>public void ucujucc(User user); </li></ul><ul><li>// 인원 가입 정보 관리 ( 조회 ) </li></ul><ul><li>public User ucujucr(int userNumber); </li></ul><ul><li>// 인원 가입 정보 관리 ( 검색 ) </li></ul><ul><li>public List<User> ucujucrs(int userNumber); </li></ul><ul><li>// 인원 가입 정보 관리 ( 수정 ) </li></ul><ul><li>public void ucujucu(User user); </li></ul><ul><li>// 인원 가입 정보 관리 ( 삭제 ) </li></ul><ul><li>public void ucujucd(int userNumber); </li></ul><ul><li>} </li></ul>Persistence
  17. 17. Before & After <ul><li>dao (Select) </li></ul><ul><li>private User ucujuc; </li></ul><ul><li>// 인원 가입 정보 관리 ( 조회 ) </li></ul><ul><li>public void ucujucc(User user) { </li></ul><ul><li>Session session = HibernateSessionFactory. getSession (); </li></ul><ul><li>Transaction transaction = null; </li></ul><ul><li>try { </li></ul><ul><li>session.beginTransaction(); </li></ul><ul><li>Query query = session.createQuery(&quot;from User as user &quot; </li></ul><ul><li>+ &quot;left join fetch user.userRankType as userRankType &quot; </li></ul><ul><li>+ &quot;left join fetch user.organizationDivision as organizationDivision &quot; </li></ul><ul><li>+ &quot;left join fetch user.organization as organization &quot; </li></ul><ul><li>+ &quot;left join fetch user.company as company &quot; </li></ul><ul><li>+ &quot;where user.userNumber = :userNumber&quot;); </li></ul><ul><li>query.setInteger(&quot;userNumber&quot;, userNumber); </li></ul><ul><li>return (User) query.uniqueResult(); </li></ul><ul><li>} catch (RuntimeException e) { </li></ul><ul><li>if (transaction != null) { </li></ul><ul><li>transaction.rollback(); </li></ul><ul><li>} </li></ul><ul><li>throw e; </li></ul><ul><li>... </li></ul>Persistence
  18. 18. Before & After <ul><li>dao (Insert) </li></ul><ul><li>private User ucujuc; </li></ul><ul><li>// 인원 가입 정보 관리 ( 입력 ) </li></ul><ul><li>public void ucujucc(User user) { </li></ul><ul><li>Session session = HibernateSessionFactory. getSession (); </li></ul><ul><li>Transaction transaction = null; </li></ul><ul><li>try { </li></ul><ul><li>transaction = session.beginTransaction(); </li></ul><ul><li>session.save(user); </li></ul><ul><li>transaction.commit(); </li></ul><ul><li>} catch (RuntimeException e) { </li></ul><ul><li>if (transaction != null) { </li></ul><ul><li>transaction.rollback(); </li></ul><ul><li>} </li></ul><ul><li>throw e; </li></ul><ul><li>} finally { </li></ul><ul><li>session.close(); </li></ul><ul><li>} </li></ul><ul><li>... </li></ul>Persistence
  19. 19. Before & After <ul><li>dao (Update) </li></ul><ul><li>private User ucujuc; </li></ul><ul><li>// 인원 가입 정보 관리 ( 수정 ) </li></ul><ul><li>public void ucujucc(User user) { </li></ul><ul><li>Session session = HibernateSessionFactory. getSession (); </li></ul><ul><li>Transaction transaction = null; </li></ul><ul><li>try { </li></ul><ul><li>transaction = session.beginTransaction(); </li></ul><ul><li>session.update(user); </li></ul><ul><li>transaction.commit(); </li></ul><ul><li>} catch (RuntimeException e) { </li></ul><ul><li>if (transaction != null) { </li></ul><ul><li>transaction.rollback(); </li></ul><ul><li>} </li></ul><ul><li>throw e; </li></ul><ul><li>} finally { </li></ul><ul><li>session.close(); </li></ul><ul><li>} </li></ul><ul><li>... </li></ul>Persistence
  20. 20. Before & After <ul><li>dao (Delete) </li></ul><ul><li>private User ucujuc; </li></ul><ul><li>// 인원 가입 정보 관리 ( 삭제 ) </li></ul><ul><li>public void ucujucc(User user) { </li></ul><ul><li>Session session = HibernateSessionFactory. getSession (); </li></ul><ul><li>Transaction transaction = null; </li></ul><ul><li>try { </li></ul><ul><li>transaction = session.beginTransaction(); </li></ul><ul><li>ucujuc = (User) session.get(User.class, userNumber); </li></ul><ul><li>session.delete(ucujuc); </li></ul><ul><li>} catch (RuntimeException e) { </li></ul><ul><li>if (transaction != null) { </li></ul><ul><li>transaction.rollback(); </li></ul><ul><li>} </li></ul><ul><li>throw e; </li></ul><ul><li>} finally { </li></ul><ul><li>session.close(); </li></ul><ul><li>} </li></ul><ul><li>... </li></ul>Persistence
  21. 21. Before & After <ul><li>iface </li></ul><ul><li>public interface IUcujucService { </li></ul><ul><li>// 인원 가입 정보 관리 ( 입력 ) </li></ul><ul><li>public void ucujucc(User user); </li></ul><ul><li>// 인원 가입 정보 관리 ( 조회 ) </li></ul><ul><li>public User ucujucr(int userNumber); </li></ul><ul><li>// 인원 가입 정보 관리 ( 검색 ) </li></ul><ul><li>public List<User> ucujucrs(int userNumber); </li></ul><ul><li>// 인원 가입 정보 관리 ( 수정 ) </li></ul><ul><li>public void ucujucu(User user); </li></ul><ul><li>// 인원 가입 정보 관리 ( 삭제 ) </li></ul><ul><li>public void ucujucd(int userNumber); </li></ul><ul><li>} </li></ul>Service
  22. 22. Before & After <ul><li>service </li></ul><ul><li>public UcujucService() { </li></ul><ul><li>this.ucujucDao = new UcujucHibernateDao(); </li></ul><ul><li>} </li></ul><ul><li>// 인원 가입 정보 관리 ( 입력 ) </li></ul><ul><li>public void ucujucc(User user) { </li></ul><ul><li>ucujucDao.ucujucc(user); </li></ul><ul><li>} </li></ul><ul><li>// 인원 가입 정보 관리 ( 조회 ) </li></ul><ul><li>public User ucujucr(int userNumber) { </li></ul><ul><li>return ucujucDao.ucujucr(userNumber); </li></ul><ul><li>} </li></ul><ul><li>// 인원 가입 정보 관리 ( 수정 ) </li></ul><ul><li>public void ucujucu(User user) { </li></ul><ul><li>ucujucDao.ucujucu(user); </li></ul><ul><li>} </li></ul><ul><li>// 인원 가입 정보 관리 ( 삭제 ) </li></ul><ul><li>public void ucujucd(int userNumber) { </li></ul><ul><li>ucujucDao.ucujucd(userNumber); </li></ul><ul><li>} </li></ul>Service
  23. 23. Before & After <action name= &quot;ucualcrf&quot; method= &quot;ucualcrf“ class= &quot;type.company.action.uc.ua.UcualcAction&quot; > <result name= &quot;success&quot; > /uc/ua/lc/ucualcrf.jsp</ result> </action> <action name= &quot;ucualcrs&quot; method= &quot;ucualcrs&quot; class= &quot;type.company.action.uc.ua.UcualcAction&quot; > <result name= &quot;success &quot;> /uc/ua/lc/ucualcr.jsp </result> <result name= &quot;input &quot;> /uc/ua/lc/ucualcrf.jsp </result> </action> <action name= &quot;ucujucc&quot; method= &quot;ucujucc&quot; class= &quot;type.company.action.uc.uj.UcujucAction&quot; > <result name= &quot;success&quot; type= &quot;redirect-action&quot; > ucujusrList </result> <result name= &quot;input&quot; type= &quot;chain&quot; > ucujuccf </result> </action> <action name= &quot;ucujucr&quot; method= &quot;ucujucr&quot; class= &quot;type.company.action.uc.uj.UcujucAction&quot; > <result name= &quot;success &quot;>/uc/uj/uc/ucujucr.jsp </result> </action> struts.xml
  24. 24. 영상
  25. 25. 감사합니다 .

×