H2 or Derby persistence #706

CLOSED learning portal
Submitted 5 months ago

Hi, I have been using your tutorial on and off for about a year now and my requirements have advanced enough to need a DB for persistence.

I followed the tutorial by Simon Scholz EclipseLink-and-Hibernate-JPA-OSGi and have successfully implemented it into my e4 application with one exception. Unfortunately, I cannot figure out how to inject the IEventBroker into the EclipseLink service. I do not get any compile errors. But it is always null when the code is executed.

Anyway, it seems to me like low hanging fruit for you gurus to add this feature to your training and fix the DI issue along the way I seem to be having.

Thank you for offering such a great e4 learning platform!

Regards,

Kurt

Comments

  5 months ago

Hi,

The EclipseLink service is an OSGi hence @Inject does not work here. One alternative would be to use a ContextFunction as described in https://learn.vogella.com/exercises/rich-client-platform/using-context-functions-ACy8M. Alternative you could use the OSGi @Reference to access the MApplication which is also published as OSGi service and use the get method to access the event service via the context. Third alternative would be to to get the OSGI IEventAdmin injected via OSGI @Reference and use this one but that one is a little bit more tricky to use.

I hope this helps.

Best regards, Lars

  5 months ago

Copied from Email:

Hi Lars and thank you very much for the quick response.

The Eclipse Rich Client Training shows the following in the following section; 135.5. Notifications from the TaskService

@Component public class TransientTaskServiceImpl implements TaskService {

@Inject
private IEventBroker broker;

Is this not correct?

  5 months ago

Please see https://learn.vogella.com/exercises/rich-client-platform/using-context-functions-ACy8M#tutorial_contextfunction2 for using context functions. As said earlier OSGI does not support @Inject.

Please login to write a comment.