-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EntityManagerFactory(s) created by the persistence layer have be closed #183
Comments
The idea is to introduce a new abstract class in the framework called KapuaApplication.
The class has to be implemented by a custom Kapua application. It also have to be instantiated at the top level of the containing application. The containing application can be a JavaSE application or, for example, a servlet container. The protocol or a Java SE application should be the following:
the protocol for a servlet container could be the following:
Start() and stop() methods will trigger events that can be listened by resource managers.
will be substituted by the following
|
+1 |
I will try to describe my understanding with an example of usage with Liquibase. You correct me if I am wrong. Questions:
Those are just my considerations. Otherwise I agree with this principle, as we discussed it on mondays meeting. |
1 - Not necessarily. You can also use the schema management apis. For example in a test class:
or you could use the Lifecycle listener approach. To make it easier, maybe the KapuaApplication class could expose a register method:
2 - The order of execution will be determined by the registration sequence even though other approaches can be considered. |
The issue affects some classes, like for example some singletons, that have an application scope and hold resources that have to be released before closing the Kapua application. Currently these Kapua applications are the Console, the RESTful APIs, the Broker but the same can be applied to any micro service that assemble one or more Kapua services in JVM.
The solution should be easy for the developer to apply and should reduce the need to inherit from base classes in order to keep the classes where these resources are managed as simple as possible. In the same time the code dedicated to the startup/shutdown management should be kept simple and compact without requiring a priori knowledge on the implementation of the single Kapua services.
The text was updated successfully, but these errors were encountered: