Visualization 때문에 시작하게된.. Flex와 Java 연동...
차례차례 셋팅 하면서... 마지막 목표까지... ㄱㄱ!
1. BlazeDS에 대하여..
(1) 정의 : 데이터 서비스를 모아 둔 것.
(2) 서비스의 종류 3가지
- 리모팅 서비스(Remoting Service) : Flex 어플리케이션이 직접 어플리케이션 서비에 동작하는 Java 객체의 메소드를 호출 할 수 있게 해 준다.
- 메시지 서비스(Message Service) : 실시간 데이터 Push와 Collaborative 어플리케이션을 가능하게 하기 위해 Flex 어플리케이션이 메시지 Publish 하고 Subscribe 할 수 있도록 Publish/Subscribe Infrastructure 제공.
- 프락시 서비스(Proxy Service) : Flex 어플리케이션이 안전하고 제어되는 방법으로 크로스 도메인 서비스 리퀘스트를 생성할 수 있게 합니다. 즉, Proxy Service를 통해 Flex 어플리케이션은 다른 도메인의 서비스에 접근할 수 있습니다.
2. BlazeDS 환경 설정
(1) 설치
※ Tomcat Ver. 6.0.14
- BlazeDS Turnkey Download & 압축 풀기
- Command 창 실행(실행 -> cmd)
- /blazeds/tomcat/bin 으로 이동 (dir 이용)
- catalina run 실행
(2) Flex Builder 3 Plug in 설치
- http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3email
(하단의 Adobe® Flex® Builder 3 Professional Eclipse Plug-in (60 day trial) 를 선택 하여 다운)
- http://slothink.tistory.com/64 <- 설치 방법 참조..
(3) Java 프로젝트 생성
- Flie > New > Project > Java Project 선택 > Next
- 프로젝트 이름(blazeds-server) 입력 하고 C:\blazeds\tomcat\webapps\samples\web-inf 입력 또는 선택
- Default output folder 가 "blazeds-server/classes" 임을 확인 하고 Finish 클릭
※ Source : WEB-INF/src ::::: Class : WEB-INF/classes 에 자동 컴파일 됨.
3. 리모팅 서비스(Remoting Service) 어플리케이션 만들기
(1) Java 쪽 설정
※ 가상 설정으로.. Access에서 데이터를 가져와서 Flex로 보낼 것이다.
- Access로 데이터를 보내기 위해.. 간단한 구조인 Class를 만든다. (keyword.java)
package dataset;
public class Keywords {
private String keyword;
private String synset;
private int weight;
public String getKeywords()
{
return keyword;
}
public void setKeywords(String keyword)
{
this.keyword = keyword;
}
public String getSynset()
{
return synset;
}
public void setSynset(String synset)
{
this.synset = synset;
}
public int getWeight()
{
return weight;
}
public void setWeight(int weight)
{
this.weight = weight;
}
}
- 직접 Access와 연동 되어야 하는 Class를 만든다. (keywordDAO.java)
import java.util.*;
import dataset.Keywords;
public void dbConn()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException ee)
{
System.exit(0);
}
}
public List getKeywords() throws SQLException
{
dbConn();
String url = "Jdbc:Odbc:DomainVisual";
List list = new ArrayList();
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
String sql_query = "Select * from DOC_KEYWORDS";
try
{
con = DriverManager.getConnection(url);
stmt = con.createStatement();
rs = stmt.executeQuery(sql_query);
while(rs.next())
{
Keywords kw = new Keywords();
kw.setKeywords(rs.getString("KEYWORD1"));
kw.setSynset(rs.getString("SYNSET1"));
kw.setWeight(rs.getInt("WEIGHT1"));
list.add(kw);
}
}finally{
con.close();
}
return list;
}
}
(2) Remoting Service 설정 하기
- remoting-config.xml 파일을 열어 다음의 내용을 하단에 추가 한다.
<properties>
<source>[package명.java파일명]</source>
</properties>
</destination>
(3) Flex Project 생성
- File > New > Project > Flex Builder > Flex Project > Next
- 프로젝트 이름 입력
- Use default location 선택 여부 확인
- 서버 종류 J2EE 선택
- Create combined Java/Flex project using WTP 선택 해제
- LiveCycle Data Services의 루트 폴더 확인
Root Folder : C:\blazeds\tomcat\webapps\samples
Root URL : http://localhost:8400/samples/
Context Root : /samples
- Validate Configuration을 눌러 테스트가 완료 되면, Finish를 눌러 생성 한다.
(4) Flex Project 테스트
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:RemoteObject id="ro" destination="[서비스 id 명 입력]"/>
<mx:DataGrid dataProvider="{ro.[자바메소드].lastResult}" width="100%" height="100%"/>
<mx:Button label="Get Data" click="ro.[자바메소드]"/>
</mx:Application>
완료가 되는 것이다.
1일째.. 테스트 완료!
이제 직접 내가 하고 있는 프로젝트에 적용 및 응용을 해보도록 하자! ^^
댓글 없음:
댓글 쓰기