On Sep 5, 2006, at 2:10 PM, Jean-Sebastien Delfino wrote:
Jim Marino wrote:
Option 2:
- You don't want to write an SCDL componentType file
- In your JavaScript object constructor you do the following:
function Calculator() {
scaproperty(this.precision)
scareference(this.divideService)
}
- This tells the Tuscany runtime what properties and references
to consider, the runtime initializes them on return from the
constructor.
Couldn't the same thing be done by declaring properties/references
as constructor parameters, which would be consistent with SCA
assembly's use of dependency injection?
Jim,
Both field setting/use of setter methods and constructor based
injection are consistent with the SCA spec. I am thinking about
starting with the field/setter based approach first as I'm not sure
yet how to map (untyped) constructor parameters to references and
properties.
Of course setter injection is consistent. I was simply saying for
constructors it would be consistent to pass in references and/or
properties as parameters. I would map untyped parameters similar to
what we do in the Java spec: there is an algorithm we added based on
Jeremy's original CDI proposal and if none of the rules apply,
parameters can be properties or references. We updated the Java spec
with the algorithm as part of the July release. Since most ECMAScript
VMs are not strongly typed (except the Actionscript 3 VM), most of
the time I would imagine that the rules will fall through to a
parameter being a reference or property.
There is an interesting Actionscript project that implements an IoC
container. I've used its AOP framework a couple of years ago and it
may be worth looking at:
http://www.as2lib.org/
http://www.simonwacker.com/blog/archives/cat_flash.php
I think it would also be interesting to support metadata
annotations through JavaScript comments (similar to XDoclet) by
writing a script parser using regex (or something similar) as in:
http://dotnetjunkies.com/WebLog/anoras/archive/2004/08/09/21502.aspx
What I'm proposing here is a simple alternative to annotations for
now. I did a lot of Javascript development in the past and I
personally prefer a simple script function to an annotation that
does not directly translate to executable code, but I'll welcome
any annotation support as well if people like it, want to volunteer
and contribute it.
I believe the article had some code that could potentially be used.
The article you pointed to is from 2004, do you know if the
approach described in this article became widely used?
Macromedia did a massive overhaul of ECMAScript and added a lot of
reflection capabilities into the language (Actionscript 3) as well as
type checking into their VM that would make this much easier. As an
aside it is interesting that Ruby proponents like untyped systems yet
ECMAScript has evolved away from that to more static type checking.
Back to whether it has become widely use, I believe Macromedia was
looking at this at some point. It took Java five versions to get
annotations so maybe SCA could convince the ECMAScript group metadata
is a good thing ;-)
Jim
Jim
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Jean-Sebastien
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]