ラベル BlazeDS の投稿を表示しています。 すべての投稿を表示
ラベル BlazeDS の投稿を表示しています。 すべての投稿を表示

2009/01/13

BlazeDSとGuiceの連携

Google Codeにguice-blazedsというプロジェクトを見つけたので、ちょっと試してみました。

guice-blazeds(Guice injection for BlazeDS)
http://code.google.com/p/guice-blazeds/

ソースコードを覗いてみたら、とってもシンプル。2クラスだけしかありません。
uk.co.chasetechnology.guice_blazeds.AbstractGuiceFactory.java
uk.co.chasetechnology.guice_blazeds.GuiceFactoryInstance.java

BlazeDS用のFactoryクラスのベースを提供してくれるだけのようです。

guice-blazedsアプリの作成手順としては、まず、リモートサービスを定義。
package net.air_life.guice_blazeds.service;

public class HelloWorldService {
public String sayHello() {
return "Hello World.";
}
}
次にBlazeDSで使用するFactoryを作るために、guice-blazedsが提供してくれてるAbstractGuiceFactoryのサブクラスを定義。
package net.air_life.guice_blazeds.factory;

import uk.co.chasetechnology.guice_blazeds.AbstractGuiceFactory;
import com.google.inject.Guice;
import com.google.inject.Injector;

public class GuiceFactory extends AbstractGuiceFactory {
private Injector injector;

public GuiceFactory() {
injector = Guice.createInjector();
}

public <T> T createInjectedObject(Class<T> clazz) {
return injector.getInstance(clazz);
}
}
あとはBlazeDS側の設定services-config.xmlに上記のFactoryを追加。
<services-config>
....
<factories>
<factory id="guice" class="net.air_life.guice_blazeds.factory.GuiceFactory"/>
</factories>
</services-config>
最後にremoting-config.xmlにHelloWorldServiceを追加。

....
<destination id="helloWorld">
<properties>
<source>net.air_life.guice_blazeds.service.HelloWorldService</source>
<factory>guice</factory>
</properties>
</destination>
あとはクライアント側からhelloWorld宛にサービス呼び出しをかけると、HelloWorldという文字列を受け取れます。

2008/12/22

Spring BlazeDS IntegrationもApache Ivy使ってる

Spring BlazeDS IntegrationもApache Ivy使ってるみたい。
アーカイブを展開したらIvy関連のファイルが見当たった。

ライブラリの依存関係に関する面倒くささを解消したいだけであれば、MavenよりIvyだよなと思う。

2008/12/18

Spring BlazeDS Integration 1.0.0.M1リリース

Using Spring BlazeDS Integration 1.0.0.M1
http://blog.springsource.com/2008/12/17/using-spring-blazeds-integration-m1/

SpringSourceはこのニュースで書かれていた「Spring BlazeDS Integration」を宣言通り12月中旬にリリースしてきた。

米AdobeとSpringSource、エンタープライズ向けJava RIAで提携
http://www.itmedia.co.jp/enterprise/articles/0812/09/news104.html

ソースコードを覗いてみるとS2BlazeDSと同じくたったの4クラス。
パッと見た感じSeasar2環境でのS2BlazeDSと同じことをSpring環境に提供するんだから偶然でもないのか。

2008/12/10

AdobeとSpringSourceの蜜月、そしてPranaは変化

BlazeDSとの統合を目的としたSpring BlazeDS Integrationの開発が進められるらしい。

米AdobeとSpringSource、エンタープライズ向けJava RIAで提携
http://www.itmedia.co.jp/enterprise/articles/0812/09/news104.html

それとPrana frameworkがSpring ActionScriptに変わるようだ。
SpringOne Brings a New Tomcat Server, VMware Partnership, and ActionScript Offerings
http://www.infoq.com/news/2008/12/springone-2008
Spring/Adobe - The Spring ecosystem continued to broaden at SpringOne with two key Flex related announcements. The Prana framework was officially renamed Spring Actionscript. As part of the move the project gains official SpringFramework.org forums, JIRA access, and Fisheye integration. SpringSource also announced a partnership with Adobe integrating Spring with BlazeDS:

こちらはPranaの日本語紹介記事。
ActionScript 3 を使ったアプリケーション開発をサポートする Prana フレームワーク
http://www.infoq.com/jp/news/2008/11/prana-framework-actionscript-3

BlazeDS 3.2が先月リリースされてたっぽい

昨日、ふらっとAdobe Open SourceにあるBlazeDSのwikiを見たところリリースビルドが3.2.0.3978に更新されてることに気付いた。
ページのLast Modifiedを見ると先月20日になっているので、リリースされてからだいぶ時間が経っていたみたい。
気づいてなかったんで、さっそく更新してみたよ。

BlazeDS 3.2リリースノート
http://opensource.adobe.com/wiki/display/blazeds/Release+Notes

BlazeDS 3.2 Fixed Issues
http://opensource.adobe.com/wiki/display/blazeds/Release+Notes#ReleaseNotes-BlazeDS3.2FixedIssues

BlazeDSの以前のリリースビルドは確か3.0.0.544。
Adobe LiveCycle Data Services ES 2.6.1のリリースノートにBlazeDS関連の修正を含めた日本語訳があったよ。
英語読解が面倒なときはこちらを見るとイイ。
http://help.adobe.com/ja_JP/livecycle/8.2/lcds_releasenotes.html

2008/08/19

RemoteObjectサービスの負荷テスト - BlazeDS

JMeter 2.3.2からAMFのキャプチャが出来るようになりました。

JMeter - Changes
http://jakarta.apache.org/jmeter/changes.html
Improvements
The Proxy server can now record binary requests. By default the content types application/x-amf and application/x-java-serialized-object will be treated as binary and saved in a file. To change the content types, update the property proxy.binary.types .

これでJava + Tomcat + Seasar2 +S2BlazeDS環境のRemoteObjectサービスについて負荷テストができます。
試したところ結構やりづらいですけど・・・。

2008/07/31

BlazeDS Developer Guideが更新されたらしい

BlazeDS Developer Guide Updated
http://blogs.adobe.com/flexdoc/2008/07/blazeds_developer_guide_update.html

注意を見たらPDFバージョンは更新したけど、Livedocs HTMLはまだ更新してないみたい。

2008/01/19

BlazeDS + Seasar2(S2Flex) + Flex(Cairngorm)


AdobeからBlazeDS(現時点ではβだけど)が公開されたので、これを機にSeasar2と連携させてみた。
今まではS2FlexのGatewayを使っていたけど、そこんとこをBlazeDS任せにする。
BlazeDSはFlex Data Servicesとベースは一緒なので、S2Factory for FDS2を試したところ、S2Containerにサービスのインスタンスを登録するのはそのままイケた。

手順としてはこんな感じ。

1. BlazeDS一式をダウンロード、展開。

BlazeDS
http://labs.adobe.com/technologies/blazeds/

2008年1月19日現在はblazeds_b1_121307.zipというアーカイブファイルで提供されている。
この中にはBlazeDSの空コンテキストやサンプルアプリケーションコンテキスト等が含まれている。

2. BlazeDSアプリケーションの設定。

展開後のblazeds_b1_121307\tomcat\webapps\blazeds に空コンテキストがあるので、それをベースにBlazeDSアプリケーションを構築していく。

2.1. web.xmlの設定。
blazeds\WEB-INF\web.xmlにs2filterの設定を追加する。

<filter>
<filter-name>s2filter</filter-name>
<filter-class>org.seasar.framework.container.filter.S2ContainerFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>s2filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

2.2. Flexコンパイルオプション -context-root, -services の設定。

FlexBuilderでFlexコンパイラのオプションを設定する。
FDSと違って、このコンパイルオプションを指定しないとRemoteObjectの呼び出しで失敗してしまった。

blazedsというコンテキストであれば下記のように指定する。

-context-root /blazeds -services=C:\blazeds\WEB-INF\flex\services-config.xml

BlazeDSではなく、FDS(LCDS)を使う場合はWeb層コンパイラにコンテキスト名を渡す必要がそもそもないのでこのようなコンパイルオプションは不要っぽい。

BlazeDSではWeb層コンパイラや他いろいろが提供されていないので、上記のオプションが必要。
FlexBuilderコンパイラはflex-config.xmlは使用しないので、コンパイルオプションにload-configオプションの指定をする。

http://livedocs.adobe.com/flex/2_jp/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001490.html

外部ファイル内部でcontext-root, servicesを記述して、コンパイラにその外部ファイルをロードさせる形でもOK。
その場合のコンパイルオプションはこんな感じにした。

-load-config+=C:\blazeds\WEB-INF\flex\flex-config-ext.xml

load-configのところが += ってしてあるのは、FlexBuilderが内包するデフォルト設定(flex-config.xml)に追加する形とするため。

flex-config-ext.xml

<flex-config>
<compiler>
<context-root>/blazeds</context-root>
<services>services-config.xml</services>
</compiler>

<metadata>
<title>blazeds with Seasar2</title>
<description>blazeds with S2 application</description>
<publisher>infy2c</publisher>
<creator>infy2c</creator>
<language>JA</language>
</metadata>
</flex-config>

3. S2Factory for FDS2, S2Flex2, S2Container2 2.4をダウンロード、展開。

S2Factory for FDS2
http://akabana.sandbox.seasar.org/ja/products/fds/

前提条件に
・Flex Data Services2
・S2Flex2
・S2Container2 2.4
が挙げられているけど、今回はBlazeDSを使うので、Flex Data Services2はいらない。

S2Factory for FDS2を通してFlexクライアントのリクエストに応えるインスタンスを生成する。

Flex2開発ガイドのファクトリメカニズムの使用を参照。
ファクトリメカニズムの使用
http://www.adobe.com/livedocs/flex/201_jp/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=ent_services_config_097_26.html

3.1. FlexFactoryの設定。

C:\blazeds\WEB-INF\flex\services-config.xml にFlexFactoryの設定を追加する。

<factories>
<factory id="s2" class="org.seasar.flex2.rpc.remoting.service.fds2.factory.Seasar2Factory" />
</factories>

3.2. RemoteObjectの設定。

C:\blazeds\WEB-INF\flex\remoting-config.xml にRemoteObjectのdestinationを追加する。

下記のような記述をRemoteObjectの数分だけ必要になる。
factoryには3.1. で指定したs2を使う。

<destination id="hogeService">
<properties>
<factory>s2</factory>
</properties>
</destination>

なお、クライアント側はFDSを使っていたときのものでOK。
私はCairngormを使用しているので、下記のような感じになる。

ServiceLocatorとBusinessDelegateを例に挙げておく。
コマンドクラスをresponderに指定して、BusinessDelegateのメソッドを呼んでください。
Services.xml(ServiceLocator)

<?xml version="1.0" encoding="utf-8"?>
<cairngorm:ServiceLocator
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:cairngorm="com.adobe.cairngorm.business.*">
<mx:RemoteObject
id="hogeService"
destination="hogeService"
result="event.token.resultHandler(event);"
fault="event.token.faultHandler(event);">
</mx:RemoteObject>
</cairngorm:ServiceLocator>

hogeDelegate.as(BusinessDelegate)

package hoge {
import com.adobe.cairngorm.business.ServiceLocator;

import mx.rpc.AbstractService;
import mx.rpc.AsyncToken;
import mx.rpc.IResponder;

public class hogeDelegate {
private var responder:IResponder;
private var service:AbstractService;

public function hogeDelegate(responder:IResponder) {
this.service = ServiceLocator.getInstance().getService("hogeService");
this.responder = responder;
}

public function hoge():void {
var token:AsyncToken = service.hoge();
token.resultHandler = responder.result;
token.faultHandler = responder.fault;
}
}

かなり手抜きだけど以上。