본문 바로가기

[Flex]spring + ibatis 환경 설정

혹시라도 잘못 되거나 더 좋은 방법 있으시면 댓글 남겨주세요.

제가 초보라 틀릴 경우가 농후함.

글 업데이트 로그
2009.11.10 처음 씀.
2009.11.11 web.xml, applicatonContext.xml 설명

예정 : 각 파일마다 설명 달자.

자바 이것저것 할 때 마다 늘 느끼는거지만 초반 잘 모를 때 이것저것 설정하는게 젤 짜증난다.

물론 알고나면 괜찮지만 모를땐 정말 갑갑한..

왜 인터넷에 있는 모든 강좌는 조금씩 틀리며 따라 해도 잘 안되는걸까.

결국 할때 마다 내가 성공한 환경으로 메뉴얼을 새로 만든다. 이번에도 그러하군.

설정을 좀 많이 해야 하는구나. 시간 좀 걸리겠는걸.

목표는! jsp + bean + spring + ibatis in eclipse
           flex + remobject + blazeDS + spring + ibatis

아래는 Flex + remobject + spring + ibatis + blazeDS임.

1.Eclipse 갈릴레오 버전 받는다(2009.11.10 현재 버전)

2.Eclipse 에서 tomcat 설치
  Server -> new -> Tomcat 6.0 -> download and install




설명 및 쭉 순서대로 설정 하자.
※ 각 설정 파일 설명

 01.web.xml
     - 머하는 놈 : 기본적인 환경 설정.
     - 위치       : 보통 /WEB-INF


 Flex Project를 생성 하면 기본적으로 아래와 같이 생성된다.

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 <display-name>firstFlex</display-name>

 <context-param>
  <param-name>flex.class.path</param-name>
  <param-value>/WEB-INF/flex/hotfixes,/WEB-INF/flex/jars</param-value>
 </context-param>

 <!-- Http Flex Session attribute and binding listener support -->
 <listener>
  <listener-class>flex.messaging.HttpFlexSession</listener-class>
 </listener>

 <!-- MessageBroker Servlet -->
 <servlet>
  <servlet-name>MessageBrokerServlet</servlet-name>
  <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
  <init-param>
   <param-name>services.configuration.file</param-name>
   <param-value>/WEB-INF/flex/services-config.xml</param-value>
  </init-param>
  <init-param>
   <param-name>flex.write.path</param-name>
   <param-value>/WEB-INF/flex</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
 </servlet>

 <servlet-mapping>
  <servlet-name>MessageBrokerServlet</servlet-name>
  <url-pattern>/messagebroker/*</url-pattern>
 </servlet-mapping>
 <welcome-file-list>
  <welcome-file>index.html</welcome-file>
  <welcome-file>index.htm</welcome-file>
  <welcome-file>index.jsp</welcome-file>
  <welcome-file>default.html</welcome-file>
  <welcome-file>default.htm</welcome-file>
  <welcome-file>default.jsp</welcome-file>
 </welcome-file-list>

 <!-- for WebSphere deployment, please uncomment -->
 <!--
  <resource-ref>
  <description>Flex Messaging WorkManager</description>
  <res-ref-name>wm/MessagingWorkManager</res-ref-name>
  <res-type>com.ibm.websphere.asynchbeans.WorkManager</res-type>
  <res-auth>Container</res-auth>
  <res-sharing-scope>Shareable</res-sharing-scope>
 </resource-ref>
 -->
</web-app>


우리는 Spring을 사용할 것이기 때문에 빨간색 부분을 아래와 같이 바꿔준다.

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 <display-name>firstFlex</display-name>

<!--  원본
 <context-param>
  <param-name>flex.class.path</param-name>
  <param-value>/WEB-INF/flex/hotfixes,/WEB-INF/flex/jars</param-value>
 </context-param>

-->
<!-- 변경 -->
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext*.xml</param-value>
 </context-param>

 <!-- Http Flex Session attribute and binding listener support -->
 <listener>
  <listener-class>flex.messaging.HttpFlexSession</listener-class>
 </listener>

<!-- 변경-->
<listener>
  <listener-class> org.springframework.web.context.ContextLoaderListener  </listener-class>
 </listener>

 <!-- MessageBroker Servlet -->
 <servlet>
  <servlet-name>MessageBrokerServlet</servlet-name>
  <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
  <init-param>
   <param-name>services.configuration.file</param-name>
   <param-value>/WEB-INF/flex/services-config.xml</param-value>
  </init-param>
  <init-param>
   <param-name>flex.write.path</param-name>
   <param-value>/WEB-INF/flex</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
 </servlet>

 <servlet-mapping>
  <servlet-name>MessageBrokerServlet</servlet-name>
  <url-pattern>/messagebroker/*</url-pattern>
 </servlet-mapping>
 <welcome-file-list>
  <welcome-file>index.html</welcome-file>
  <welcome-file>index.htm</welcome-file>
  <welcome-file>index.jsp</welcome-file>
  <welcome-file>default.html</welcome-file>
  <welcome-file>default.htm</welcome-file>
  <welcome-file>default.jsp</welcome-file>
 </welcome-file-list>

 <!-- for WebSphere deployment, please uncomment -->
 <!--
  <resource-ref>
  <description>Flex Messaging WorkManager</description>
  <res-ref-name>wm/MessagingWorkManager</res-ref-name>
  <res-type>com.ibm.websphere.asynchbeans.WorkManager</res-type>
  <res-auth>Container</res-auth>
  <res-sharing-scope>Shareable</res-sharing-scope>
 </resource-ref>
 -->
</web-app>

* 참조
  원래는 applicationContext.xml이지만. 난 ibatis도 같이 할 것이기 때문에
  applicationContext-ibatis.xml
  applicationContext.xml

  두개가 있어서 *.xml로 했음.

* 설명 :
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext*.xml</param-value>
 </context-param>

<listener>
  <listener-class> org.springframework.web.context.ContextLoaderListener  </listener-class>
 </listener>

applicationContext.xml에 Bean을 추가해 놓으면
서버가 시작되면서 ContextLoaderListener클래스가 초기화 된다.
listener를 스프링으로 변경 하면 서버가 시작되면서 자동으로 ContextLoaderListener 클래스가 초기화 된다.
.java 클래스 생성자에 System.out.println찍어본결과
서버 시작되면서 applicationContext.xml에 등록한 bean도 자동으로 생성 되는듯 함.

applicatonContext.xml에 대해선 아래에 추가 설명.



02.applicatonContext.xml
    - 머하는놈 : 
                   보통 Bean을 등록해 놓고 관리한다.getter, setter 지지고 볶고
    - 위치      : 보통 WEB-INF/applicationContext.xml

잠시 테스트를 위해 Bean을 생성해 보자.
 


의존 관계에 있어서 주입 방식은 생성자 방식과 프로퍼티 방식이 있다.
발췌:최범균의 스프링 2.5 프로그래밍
org.springframework.context.A





01.crossdomain.xml : 
02.applicationContext-ibatis.xml
03.messaging-config.xml
04.proxy-config.xml
05.proxy-config.xml
06.services-config.xml
07.database.properties
08.sqlmap-config.xml