gembin

OSGi, Eclipse Equinox, ECF, Virgo, Gemini, Apache Felix, Karaf, Aires, Camel, Eclipse RCP

HBase, Hadoop, ZooKeeper, Cassandra

Flex4, AS3, Swiz framework, GraniteDS, BlazeDS etc.

There is nothing that software can't fix. Unfortunately, there is also nothing that software can't completely fuck up. That gap is called talent.

About Me

 

AS3-DI-Metadata

What a Metamess

Spring Actionscript, Dawn, SmartyPants, Swiz, Spicelib (used by Parsley) and SwiftSuspenders (used by Robotlegs) perform Dependency Injection.

Moreover they can all perform automatic DI by parsing class metadata. It would be grand if the common DI related metadata tags could be standardised. That way we really could write code that is decoupled from any particular framework.

Injection by Type

Dawn, Swiz, Spicelib, SwiftSuspenders, SmartyPants: [Inject] (above property, setter or method)
Spring AS: [Autowire] (above property, setter or method)

Most popular

[Inject] by 5

Notes

[Inject] is clear and simple and used by almost all of the libraries. It also directly correlates to @Inject from the JSR-330 Dependency Injection for Java specification. Let’s use it.

Injection by Name/Id

Dawn, SwiftSuspenders, SmartyPants: [Inject(name=“SomeName”)] (above property, setter or method)
Swiz: [Inject(source=“SomeName”)] (above property, setter or method)
Spicelib: [Inject(id=“SomeName”)] (above property, setter or method)
Spring AS: [Autowired(name=“SomeName”)] (above property, setter or method)

Most popular

[Inject(name=“SomeName”)] by 3

Notes

Since you can define default attributes best practice could be to leave out the attribute: [Inject(“SomeName”)]

Constructor Injection:

SwiftSuspenders: [Inject] (above class)
Spicelib: [InjectConstructor] (above class)
Swiz, Spring AS, Dawn: ?

Most popular

?

Notes

I don’t see the need for an extra tag ([InjectConstructor]) when we could simply use [Inject].

Object Lifecycle – Post Injection:

Dawn, SwiftSuspenders, SmartyPants, Swiz: [PostConstruct] (above method)
Spicelib: [Init] (above method)

Most popular

[PostConstruct] by 4

Notes

@PostConstruct is used in Java for the same purpose. Let’s use the most popular, established one.

Object Lifecycle – Teardown:

SwiftSuspenders, SmartyPants, Dawn: none?
Swiz: [PreDestroy] (above method)
Spicelib: [Destroy] (above method)

Most popular

Notes

@PreDestroy is used in Java for the same purpose. Let’s use the most familiar, established one.

Factory/Provider:

SwiftSuspenders, SmartyPants, Swiz: none?
Dawn: [Provider] (above method)
Spicelib: [Factory] (above method)

posted on 2010-11-12 14:44 gembin 阅读(509) 评论(0)  编辑  收藏 所属分类: ActionScript3


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿(6)

随笔分类(440)

随笔档案(378)

文章档案(6)

新闻档案(1)

相册

收藏夹(9)

Adobe

Android

AS3

Blog-Links

Build

Design Pattern

Eclipse

Favorite Links

Flickr

Game Dev

HBase

Identity Management

IT resources

JEE

Language

OpenID

OSGi

SOA

Version Control

最新随笔

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜

free counters