Comments (13)
Mmh, that's an interesting idea.
Do you think that it should be possible to append injection point configs during runtime or would it suffice to switch out the entire XML config table?
The latter would be trivial to implement, the former at least a little bit of work. Not really much, though.
from swiftsuspenders.
Swapping out the whole XML config table seems less useful - one would have to know the entire config in order to modify/append points.
from swiftsuspenders.
My thinking is that this would be a v2 type feature - possibly replacing the current XML config scheme.
from swiftsuspenders.
Right, so appending configs it is.
I don't think it'd be wise to enable removal of individual configs, though. Doing so would make working with XML configs a lot more flexible and thus unpredictable than doing the same with metadata.
from swiftsuspenders.
Indeed!
from swiftsuspenders.
I agree: Makes sense to break compatibility with the current XML config stuff for this.
I also don't think that v2 should necessarily be too far off: I'd really like to clean up the API a bit.
That opens up a bag of worms regarding Robotlegs and DI container pluggability, though. Will bring that up on the mailing list soonish.
from swiftsuspenders.
Haxe-compiled classes don't support metadata annotations, so XML configuration can come in useful for that. Unfortunately, using XML configuration prevents regular metadata from being used either, so actually a coded solution may be better (and stronger too with better reflection checking at runtime unlike writing a XML file and losing the possibility of running with both methods.)
from swiftsuspenders.
Thanks for bringing that up - it's something I investigated myself some time ago.
From the following commit it looks like Nicholas is working on adding metadata support to Haxe, though: http://code.google.com/p/haxe/source/detail?r=3191
It's certainly on the list of planned features: http://haxe.org/com/features
Nevertheless, I agree that making XML and metadata based configuration play nice with each other is desirable. I will make sure to keep that in mind when designing the new configuration API.
from swiftsuspenders.
So, this is what I was trying to say at T{H}:
There are two sides to the coin:
- A. Responding to a request for a type (+key)
- B. Building the list of injection points (needs a better name) for a given type so that it can be constructed/resolved
A. map(Type).toProvider()
This explains what to do when queried for a type+name.
B. [Inject], [PostConstruct]
These declare injection points. But they do so internally and require reflection. It would be good if we could configure the points for a given class manually and externally. For example:
injector.configure(Class)
.addInjectionPoint('fieldName').usingProvider(type, name=null);
injector.configure(Class)
.addInjectionPoint('url').usingValue('http://api.myapp.com');
injector.configure(Class)
.addConstructorArgument().useProviderFor(type, name=null);
injector.configure(Class)
.mapPostConstructPoint('methodName').toProviderFor(type, name=null);
Obviously, it needs a better fluent interface than I've supplied.
from swiftsuspenders.
Thanks for getting back to this. I've been meaning to add an API along those lines, but didn't yet get around to it.
Maybe a DSL with nested instances works better here, though:
injector.configure(Class)
.add(new FieldInjectionPoint('fieldName', type, name=null).optional())
The reason being that the various injection points require somewhat different configuration options.
But yeah: Finding a good DSL for this isn't easy. But then, it never is.
from swiftsuspenders.
Yeh, that's much nicer :)
from swiftsuspenders.
Cool. I'll add something along those lines before the final release and run it by you.
from swiftsuspenders.
I don't see a 'watch' for issues so I'll just +1 here so I get notifications. I'd like to see this for Boiler.
from swiftsuspenders.
Related Issues (20)
- Named injections, map.toValue(null), satisfies() and getInstance() HOT 6
- Metadata.xml HOT 5
- loggable warning HOT 4
- Reflector HOT 1
- Support destruction of instances and teardown of entire containers HOT 21
- Building the SWC HOT 7
- ApplicationDomain::getDefinition Explodes Fantastically HOT 1
- Teardown nulls the _mappings dict
- DescribeTypeReflector VerifyError: Error #1068: String and * cannot be reconciled. HOT 3
- Asymmetry between satisfies & satisfiesDirectly HOT 2
- More specific InjectorError sub types HOT 4
- Null values passed to Injected constructor with multiple name-quailified injections HOT 13
- Can't build with Maven HOT 3
- Versioning HOT 6
- Feature Request -- "Mapping"-specific injections
- InstantiateUnmapped Performance HOT 2
- Injector still needs an interface ... HOT 6
- docs HOT 1
- Updated build script to preserve code comments in SWC HOT 2
- No issue , is suggest HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftsuspenders.