Skip to content

Commit

Permalink
Watch service files for hot-reload of Integrators and ServiceContribu…
Browse files Browse the repository at this point in the history
…tors
  • Loading branch information
gastaldi committed Feb 15, 2020
1 parent 6d1eb22 commit 6261ea2
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public final class HibernateOrmProcessor {
private static final DotName PERSISTENCE_UNIT = DotName.createSimple(PersistenceUnit.class.getName());
private static final DotName PRODUCES = DotName.createSimple(Produces.class.getName());

private static final String INTEGRATOR_SERVICE_FILE = "META-INF/services/org.hibernate.integrator.spi.Integrator";
private static final String SERVICE_CONTRIBUTOR_SERVICE_FILE = "META-INF/services/org.hibernate.service.spi.ServiceContributor";

/**
* Hibernate ORM configuration
*/
Expand All @@ -125,6 +128,9 @@ public SystemPropertyBuildItem enforceDisableRuntimeEnhancer() {
List<HotDeploymentWatchedFileBuildItem> hotDeploymentWatchedFiles(LaunchModeBuildItem launchMode) {
List<HotDeploymentWatchedFileBuildItem> watchedFiles = new ArrayList<>();
watchedFiles.add(new HotDeploymentWatchedFileBuildItem("META-INF/persistence.xml"));
watchedFiles.add(new HotDeploymentWatchedFileBuildItem(INTEGRATOR_SERVICE_FILE));
watchedFiles.add(new HotDeploymentWatchedFileBuildItem(SERVICE_CONTRIBUTOR_SERVICE_FILE));

getSqlLoadScript(launchMode.getLaunchMode()).ifPresent(script -> {
watchedFiles.add(new HotDeploymentWatchedFileBuildItem(script));
});
Expand Down Expand Up @@ -225,14 +231,13 @@ public void build(RecorderContext recorderContext, HibernateOrmRecorder recorder
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
// inspect service files for additional integrators
Collection<Class<? extends Integrator>> integratorClasses = new LinkedHashSet<>();
for (String integratorClassName : ServiceUtil.classNamesNamedIn(classLoader,
"META-INF/services/org.hibernate.integrator.spi.Integrator")) {
for (String integratorClassName : ServiceUtil.classNamesNamedIn(classLoader, INTEGRATOR_SERVICE_FILE)) {
integratorClasses.add((Class<? extends Integrator>) recorderContext.classProxy(integratorClassName));
}
// inspect service files for service contributors
Collection<Class<? extends ServiceContributor>> serviceContributorClasses = new LinkedHashSet<>();
for (String serviceContributorClassName : ServiceUtil.classNamesNamedIn(classLoader,
"META-INF/services/org.hibernate.service.spi.ServiceContributor")) {
SERVICE_CONTRIBUTOR_SERVICE_FILE)) {
serviceContributorClasses
.add((Class<? extends ServiceContributor>) recorderContext.classProxy(serviceContributorClassName));
}
Expand Down

0 comments on commit 6261ea2

Please sign in to comment.