|
|
|
|
|
|
|
|
|
|
Re: Setup to include for @ContextValue annotation [message #1506324 is a reply to message #1506274] |
Wed, 10 December 2014 19:27 |
Andrea Richiardi Messages: 64 Registered: August 2012 |
Member |
|
|
Yes, I removed every type annotation and used org.eclipse.jdt.annotation;bundle-version="[1.1.0,2.0.0) for classical return types and method parameters.
It builds with Maven without issues, I just need to verify that retrolamba generates Java 7 bytecode for the two, three lamdas I have seen.
EDIT: still some work to do the tests all fail with:
org.eclipse.e4.core.di.InjectionException: Unable to process "EventBroker.logger": no actual value was found for the argument "Logger".
at org.eclipse.e4.core.internal.di.InjectorImpl.reportUnresolvedArgument(InjectorImpl.java:412)
at org.eclipse.e4.core.internal.di.InjectorImpl.resolveRequestorArgs(InjectorImpl.java:403)
at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:108)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:333)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:254)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
at org.eclipse.e4.ui.services.events.EventBrokerFactory.compute(EventBrokerFactory.java:29)
[Updated on: Wed, 10 December 2014 19:52] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Re: Setup to include for @ContextValue annotation [message #1513390 is a reply to message #1512633] |
Tue, 16 December 2014 13:41 |
Andrea Richiardi Messages: 64 Registered: August 2012 |
Member |
|
|
Thanks for answering Tom, I now have your tests with ContextValue working!
As you suggested in another Eclipse's forum thread, I also had to set a Logger in the context or the IEventBroker was not getting its dependencies filled.
I have another problem on the othe test case, the one with @Adapt. It throws:
testAdapt(com.andrearichiardi.eclipse.addons.di.context.AdaptSupplierTestCase) Time elapsed: 0.078 sec <<< ERROR!
org.eclipse.e4.core.di.InjectionException: Unable to process "Bean.integerValue": no actual value was found for the argument "Integer[@com.andrearichiardi.eclipse.addons.adapter.Adapt(),@javax.inject.Named(value=test)]".
I checked that both Providers and di.context.internal.AdaptValueSupplier are present but still it fails in
private Object[] InjectorImpl.resolveArgs(...) {
...
// 6) post process
for (int i = 0; i < descriptors.length; i++) {
// check that values are of a correct type
...
if (!descriptorsClass.isAssignableFrom(actualArgs[i].getClass()))
it gets here --> actualArgs[i] = IInjector.NOT_A_VALUE;
}
}
Basically it finds the value "test" but never converts it to the desired type, so for instance here descriptorsClass is Integer but actualArgs[i].getClass() returns a String and of course the check fails. I think both tests can be fixed in e(fx)clipse as well, that is why I am trying to make them work.
Here is what services are running:
Components in bundle com.andrearichiardi.eclipse.addons:
ID State Component Name Located in bundle
1 Registered com.andrearichiardi.eclipse.addons.jlogger com.andrearichiardi.eclipse.addons(bid=8)
2 Registered com.andrearichiardi.eclipse.addons.adapter.adapterservice com.andrearichiardi.eclipse.addons(bid=8)
3 Registered com.andrearichiardi.eclipse.addons.di.context.loggersupplier com.andrearichiardi.eclipse.addons(bid=8)
4 Registered com.andrearichiardi.eclipse.addons.di.context.observableadapter com.andrearichiardi.eclipse.addons(bid=8)
5 Active com.andrearichiardi.eclipse.addons.di.context.dateformatter com.andrearichiardi.eclipse.addons(bid=8)
6 Registered com.andrearichiardi.eclipse.addons.di.context.valuesupplier com.andrearichiardi.eclipse.addons(bid=8)
7 Active com.andrearichiardi.eclipse.addons.di.context.localeprovider com.andrearichiardi.eclipse.addons(bid=8)
8 Active com.andrearichiardi.eclipse.addons.di.context.numberformatter com.andrearichiardi.eclipse.addons(bid=8)
9 Registered com.andrearichiardi.eclipse.addons.di.context.adaptsupplier com.andrearichiardi.eclipse.addons(bid=8)
10 Active com.andrearichiardi.eclipse.addons.di.context.temporalaccessformatter com.andrearichiardi.eclipse.addons(bid=8)
11 Active com.andrearichiardi.eclipse.addons.di.context.scopedobjectfactoryfunction com.andrearichiardi.eclipse.addons(bid=8)
12 Active com.andrearichiardi.eclipse.addons.tests.stringDoubleProvider com.andrearichiardi.eclipse.addons.tests(bid=9)
13 Active com.andrearichiardi.eclipse.addons.tests.stringIntegerProvider com.andrearichiardi.eclipse.addons.tests(bid=9)
[Updated on: Tue, 16 December 2014 17:30] Report message to a moderator
|
|
|
Re: Setup to include for @ContextValue annotation [message #1513628 is a reply to message #1513390] |
Tue, 16 December 2014 17:57 |
Andrea Richiardi Messages: 64 Registered: August 2012 |
Member |
|
|
It looks like the primary supplier used for the object is org.eclipse.e4.core.internal.contexts.ContextObjectSupplier, shouldn't it be AdaptValueSupplier ? I cannot understand why it gets the other one...
EDIT:
I found it.. somehow the Named annotation takes precedence over Adapt.
It is evident when putting a breakpoint in AdaptValueSupplier, removing the Named annotation.
static class Bean {
@Inject
@Adapt
Integer integerValue;
As you can see, now the code enters in the AdaptValueSupplier.get.
You can also see this in InjectorImpl.resolveArgs where the step 3) use the primary supplier will fill up the dependency, leaving no space to other suppliers.
[Updated on: Tue, 16 December 2014 18:26] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.28344 seconds