AMFPHP, OpenAMF, XML,JSON,TEXT에 대한 전체 속도 테스트에 관련된 내용은 http://blog.jidolstar.com/167 를 참고한다. http://www.openamf.com/
OpenAMF는 Flash Remoting 기술중에 하나로 Java
Open
source이다. 이것을 이용하면 AMFPHP와 마찬가지로 데이터를 Object형태로 Flash나 Flex로 송신할
수
있다.
나는 AMFPHP에 이어 Java를 이용한 AMF인 OpenAMF의 속도를
테스트 해봤다. 참고로 AMFPHP는 http://blog.jidolstar.com/164 를 참고한다.
설치방법
1. OpenAMF 다운로드 받기
http://sourceforge.net/project/showfiles.php?group_id=77268&package_id=78178&release_id=407511 OpenAMF 1.0RC12-examples 을 다운로드 받아서 openamf.war 을 web
root에 복사한다. 이렇게 하면 Tomcat이 자동으로 압축을 풀어 openamf 를 생성시킨다.
2. web.xml 수정
Web_Root/openamf/WEB-INF/web.xml 파일을 열어서 아래 내용을 <!-- -->로 주석처리한다.
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
3. 접속확인
http://자신의 IP:8080/openamf/gateway 를 접속하여 백색화면이 나오는지 확인한다. 404에러가 뜨면
설정이 잘못된 것이니 확인하기 바란다.
4. 테스트 프로그램 설치
Web_Root/openamf/classes 에 sample 폴더를 만든다.
위의 파일을 다운로드 받아 압축을 푼뒤
java파일만 위에서 만든
Web_Root/openamf/classes/sample 폴더에 위치시킨다.
그
다음
Web_Root/openamf/classes/ 에서
javac ./sample/Sample.java 명령어로 컴파일을
실시한다.
아래는 java 코드이다.
SampleVO.java (Language : java)
package sample;
import java.io.Serializable; public class SampleVO
implements Serializable { private static final long serialVersionUID = -6219985333071453603L;
private String a;
private String b;
private String c;
public String getCol1
( ) { return a;
} public String getCol2
( ) { return b;
} public String getCol3
( ) { return c;
} public void setCol1
( String col1
) { this .
a = col1;
} public void setCol2
( String col2
) { this .
b = col2;
} public void setCol3
( String col3
) { this .
c = col3;
} }
Sample.java (Language : java)
package sample;
import java.util.ArrayList; import java.util.List; public class Sample
{ public List getList
( int num
) { int i;
List<SampleVO> list =
new ArrayList<SampleVO>
( ) ;
SampleVO vo;
for ( i =
0 ; i < num ; i++
) { vo =
new SampleVO
( ) ;
vo.
setCol1 ( "This is row" + i
) ;
vo.
setCol2 ( "10000000" ) ;
vo.
setCol3 ( "More text to add to this row." ) ;
list.
add ( vo
) ;
} return list;
} }
5. Flex 프로그램
Flex Bulider에서
AMFTest라는 프로젝트를 만들고 압축푼 폴더에 AMFTest.mxml 과 RemotingConnection.as 파일을 프로젝트 폴더에
덮어쓴다음 실행한다. 아래는 Flex 소스 코드이다.
AMFTest.mxml (Language : java)
<?xml version=
"1.0" encoding=
"utf-8" ?>
<mx:Application xmlns:mx=
"http://www.adobe.com/2006/mxml" creationComplete=
"init()" >
<mx:Script>
<!
[ CDATA
[ import mx.controls.Alert; import mx.collections.ArrayCollection; import mx.utils.ObjectUtil; import mx.managers.CursorManager; import mx.utils.ArrayUtil; private var gateway : RemotingConnection;
private var baseURL :
String =
"http://jidolstar.com:8080/openamf_test/" ;
[ Bindable
] public var startTime:
Date ;
[ Bindable
] public var endTime:
Date ;
[ Bindable
] public var elapsedTime:
Number ;
[ Bindable
] public var acData:ArrayCollection =
new ArrayCollection;
public var responder:Responder;
public function init
( ) :
void { responder =
new Responder
( onOpenAMFResult, onOpenAMFStatus
) gateway =
new RemotingConnection
( baseURL+
"gateway" ) ;
} public function sendOpenAMF
( ) :
void { startTime =
new Date ( ) ;
gateway.
call ( "sample.Sample.getList" , responder,
int ( txtNum.
text ) ) ;
CursorManager.
setBusyCursor ( ) ;
} public function onOpenAMFResult
( obj:
Array ) :
void { //acData.source = ArrayUtil.toArray( obj ); acData.
source = obj;
endTime =
new Date ( ) ;
elapsedTime = endTime.
getTime ( ) - startTime.
getTime ( ) ;
CursorManager.
removeBusyCursor ( ) ;
} public function onOpenAMFStatus
( event:
Object ) :
void { msg.
text = ObjectUtil.
toString ( event
) ;
CursorManager.
removeBusyCursor ( ) ;
} ] ] >
</mx:Script>
<mx:VBox width=
"100%" >
<mx:HBox>
<mx:
Button label=
"OpenAMF" click=
"sendOpenAMF()" width=
"72" />
<mx:TextInput width=
"56" id=
"txtNum" maxChars=
"30000" text=
"1000" />
<mx:
Label text=
"건" />
</mx:HBox>
<mx:DataGrid id=
"datagrid" right=
"10" left=
"10" top=
"50" width=
"100%" dataProvider=
"{acData}" >
<mx:columns>
<mx:DataGridColumn headerText=
"Column 1" dataField=
"col1" />
<mx:DataGridColumn headerText=
"Column 2" dataField=
"col2" />
<mx:DataGridColumn headerText=
"Column 3" dataField=
"col3" />
</mx:columns>
</mx:DataGrid>
<mx:
TextArea id=
"msg" x=
"10" y=
"452" width=
"100%" height=
"92" />
</mx:VBox>
<mx:VBox width=
"100%" >
<mx:Text text=
"{startTime}" />
<mx:Text text=
"{endTime}" />
<mx:HBox>
<mx:Text text=
"{elapsedTime}" />
<mx:
Label text=
"msec" />
</mx:HBox>
</mx:VBox>
</mx:Application>
RemoteConnection.as (Language : java)
package { import flash.net.NetConnection; import flash.net.ObjectEncoding; public class RemotingConnection
extends NetConnection
{ public function RemotingConnection
( sURL:
String ) { objectEncoding = ObjectEncoding.
AMF0 ;
if ( sURL
) connect
( sURL,
null ) ;
} public function AppendToGatewayUrl
( s :
String ) :
void { // } } }
실행결과 화면
나는 이미
http://blog.jidolstar.com/164 에서 AMFPHP와 Text, XML, JSON 속도테스트를
마쳤다.
JSON, XML, AMFPHP보다는 빠르다는 것을 볼 수 있었다.
하지만 Text방식보다는
느리다.
종합 테스트 결과는
http://blog.jidolstar.com/167 를 참고하기 바란다.
참고사이트
OpenAMF 공식사이트 :
http://www.openamf.com/ OpenAMF 다운로드 :
http://sourceforge.net/projects/openamf OpenAMF소개 글 :
http://www.flash-db.com/Tutorials/helloOpenamf/index.php 으쌰님의 OpenAMF+AMF3 Upgrade :
http://blog.naver.com/lmy20/20034270418 글쓴이 : 지돌스타(
http://blog.jidolstar.com/166 )