|
|
|
|
Re: Translation Service [message #1806869 is a reply to message #1806129] |
Thu, 16 May 2019 17:50   |
Kürşat Özer Messages: 5 Registered: March 2019 |
Junior Member |
|
|
Thanks for the replies, I got it working with something like this:
in service :
@Component(immediate = true)
public class MainApplicationService implements IMainApplicationService {
private MainStage mainStage;
@Activate
void activate() {
BundleContext bundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
IEclipseContext osgiContext = EclipseContextFactory.getServiceContext(bundleContext);
ContextInjectionFactory.setDefault(osgiContext);
this.mainStage = ContextInjectionFactory.make(MainStage.class, osgiContext);
this.mainStage.initComponents();
}
}
MainStage.java:
@Creatable
public class MainStage {
@Inject
private NamedMessageRegistry registry;
private void initComponents() {
Label label1 = new Label();
Label label2 = new Label();
Label label3 = new Label();
this.registry.register(label1::setText, m -> m.first_label_message);
this.registry.register(label2::setText, m -> m.second_label_message);
this.registry.register(label3::setText, m -> m.third_label_message);
}
}
However I cant inject ILocalChanceService in MainStage.java
I get InjectionException which says
no actual value was found for the argument "ILocaleChangeService".
How can I triger locale change ?
EDIT: After some searching, the code above creates bundle specific context which does not have Locale data.
Is there an application context or top level context in a osgi environment? How can I get it or is it the right way?
[Updated on: Fri, 17 May 2019 13:54] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01762 seconds