Setup to include for @ContextValue annotation [message #1504958] |
Tue, 09 December 2014 18:17  |
Eclipse User |
|
|
|
Hello guys,
following this very good blog post link I am thinking to include the e(fx)clipse Dependency Injection features in my project.
I tried to look here, but I could not find the info I wanted. What steps do I need to take in order to include it in my .product/pom.xml ? Maybe I have not looked hard enough, but I could not find a way. Basically I would like to use the @ContextValue annotation in my product (which now supports back to Kepler).
Thanks!
|
|
|
|
|
|
Re: Setup to include for @ContextValue annotation [message #1505932 is a reply to message #1505900] |
Wed, 10 December 2014 12:29   |
Eclipse User |
|
|
|
Hello Tom thank you first of all and yes, feature and SWT based.
What I meant is that I added <feature id="org.eclipse.fx.runtime.feature"/> and now Maven downloads all the dependencies, but in my MANIFEST I have big red crosses in the Require-Bundle section.
But as I said, maybe I am doing something wrong and still investigating, probably a runtime dependency is different from what I think it is and I need to put it somwhere else.
For instance now I add the following to the .product and trying:
<plugins>
<plugin id="org.eclipse.fx.core" autoStart="true" startLevel="3" />
<plugin id="org.eclipse.fx.core.di" autoStart="true" startLevel="3" />
<plugin id="org.eclipse.fx.core.di.context" autoStart="true" startLevel="3" />
</plugins>
|
|
|
|
Re: Setup to include for @ContextValue annotation [message #1506023 is a reply to message #1506008] |
Wed, 10 December 2014 14:09   |
Eclipse User |
|
|
|
Yes, you are right, but this does not explain the failure with mvn, now I am trying to specify version 1.1.0 in my .product.
And something is moving, I now have (I am still using kepler):
Cannot complete the install because of a conflicting dependency.
Software being installed: e(fx)clipse core Feature 1.1.0.201411050703 (org.eclipse.fx.core.feature.feature.group 1.1.0.201411050703)
Software currently installed: Equinox Target Components 3.9.0.v20140221-1852 (org.eclipse.equinox.sdk.feature.group 3.9.0.v20140221-1852)
Only one of the following can be installed at once:
OSGi System Bundle 3.10.100.v20141020-1414 (org.eclipse.osgi 3.10.100.v20141020-1414)
OSGi System Bundle 3.9.0.v20130529-1710 (org.eclipse.osgi 3.9.0.v20130529-1710)
OSGi System Bundle 3.9.1.v20130814-1242 (org.eclipse.osgi 3.9.1.v20130814-1242)
OSGi System Bundle 3.10.1.v20140909-1633 (org.eclipse.osgi 3.10.1.v20140909-1633)
OSGi System Bundle 3.8.2.v20130124-134944 (org.eclipse.osgi 3.8.2.v20130124-134944)
OSGi System Bundle 3.9.1.v20140110-1610 (org.eclipse.osgi 3.9.1.v20140110-1610)
Cannot satisfy dependency:
From: Equinox Core SDK 3.8.0.v20140114-1344 (org.eclipse.equinox.core.sdk.feature.group 3.8.0.v20140114-1344)
To: org.eclipse.osgi [3.9.1.v20140110-1610]
Cannot satisfy dependency:
From: Equinox Target Components 3.9.0.v20140221-1852 (org.eclipse.equinox.sdk.feature.group 3.9.0.v20140221-1852)
To: org.eclipse.equinox.core.sdk.feature.group [3.8.0.v20140114-1344]
Cannot satisfy dependency:
From: e(fx)clipse core Feature 1.1.0.201411050703 (org.eclipse.fx.core.feature.feature.group 1.1.0.201411050703)
To: org.eclipse.fx.osgi [1.1.0.201411050602]
Cannot satisfy dependency:
From: OSGi integration for JavaFX 1.1.0.201411050602 (org.eclipse.fx.osgi 1.1.0.201411050602)
To: bundle org.eclipse.osgi 3.10.0
|
|
|
|
|
|
Re: Setup to include for @ContextValue annotation [message #1506324 is a reply to message #1506274] |
Wed, 10 December 2014 19:27   |
Eclipse User |
|
|
|
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] by Moderator Report message to a moderator
|
|
|
|
|
Re: Setup to include for @ContextValue annotation [message #1507320 is a reply to message #1507161] |
Thu, 11 December 2014 14:18   |
Eclipse User |
|
|
|
I understand it is not your use case at all, nonetheless I would not feel very comfortable in putting my name on some Maven artifact as it was not at all my merit 
You are not even interested in putting these modified packages under a *.j7 package on eclipse.org/github and delegating the maintenance to me?
|
|
|
|
|
|
|
Re: Setup to include for @ContextValue annotation [message #1513390 is a reply to message #1512633] |
Tue, 16 December 2014 13:41   |
Eclipse User |
|
|
|
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] by Moderator 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   |
Eclipse User |
|
|
|
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] by Moderator Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05535 seconds