Skip to content

cherreman/AS3-DI-Metadata

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

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)

Most popular

Notes

About

An attempt to standardise AS3 DI Metadata tags

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published