cairngorm 2.2 의 FDS의 의존성을 제거한 버전 + 오픈리모팅 컴포넌트를 쓰는 환경에서, service.mxml 을 대체하는 클래스를 만들어봤다.
몇일전에 모 카페에 올렸던 글이기도 하다.
NetConnectionEx.as
---------------------------------------------------------
package com.adobe.cairngorm.samples.store.business
{
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
import com.adobe.cairngorm.CairngormError;
import com.adobe.cairngorm.CairngormMessageCodes;
public class NetConnectionEx extends NetConnection
{
private static var instance:NetConnectionEx;
private static var GATEWAY_URL:String = "http://localhost:8080/gateway";
//AS 3.0 은 private 생성자를 지원하지 않는다.아래처럼 캔곰 에러를 발생 시킬수 있지만,
//SingletonEnforcer 클래스를 써서 처리할 수도 있다.
/* public function NetConnectionEx()
{
super();
if ( instance != null )
{
throw new CairngormError( CairngormMessageCodes.SINGLETON_EXCEPTION, "NetConnectionEx" );
}
instance = this;
}
public static function getInstance():NetConnectionEx
{
if ( instance == null )
{
instance = new NetConnectionEx();
}
return instance;
} */
public function NetConnectionEx(enforcer:SingletonEnforcer)
{
super();
}
public static function getInstance():NetConnectionEx
{
if ( instance == null )
{
instance = new NetConnectionEx(new SingletonEnforcer());
instance.objectEncoding = ObjectEncoding.AMF3;
instance.connect(GATEWAY_URL,null);
}
return instance;
}
}
}
class SingletonEnforcer{}
Flex를 오픈소스로 정책 전환한다는 그 즈음에 Cairngorm 2.2가 발표되었다.
가장 눈에 띄이는건 FDS의 의존성을 제거한 버전과 FDS를 포함하는 엔터프라이즈 버전으로 나뉜점이다.
자체 리모팅 컴포넌트를 사용하는 개발사에게는 대 환영할만한 일이다.

댓글을 달아 주세요
댓글 RSS 주소 : http://iamyhs.com/tc/rss/comment/69