Skip to content

Commit

Permalink
add delayTask method
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Aug 1, 2024
1 parent 8b276c1 commit d48626f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 46 deletions.
32 changes: 18 additions & 14 deletions generators/migration/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@ export default class extends BaseApplicationGenerator {
get [BaseApplicationGenerator.PREPARING]() {
return this.asPreparingTaskGroup({
async source({ application, source }) {
this.queueTask({
method: () => {
source.addAllowBlockingCallsInside = () => undefined;
source.addApplicationPropertiesContent = () => undefined;
source.addIntegrationTestAnnotation = () => undefined;
source.addTestSpringFactory = () => undefined;
this.delayTask(() => {
source.addAllowBlockingCallsInside = () => undefined;
source.addApplicationPropertiesContent = () => undefined;
source.addIntegrationTestAnnotation = () => undefined;
source.addTestSpringFactory = () => undefined;

if (application.buildToolGradle) {
// Add a noop needles for spring-gateway generator
source.addJavaDefinition = () => {};
source.addJavaDependencies = () => {};
}
},
taskName: `${this.runningState.methodName}(delayed)`,
queueName: this.runningState.queueName,
if (application.buildToolGradle) {
// Add a noop needles for spring-gateway generator
source.addJavaDefinition = () => {};
source.addJavaDependencies = () => {};
}
});
},
});
Expand Down Expand Up @@ -89,4 +85,12 @@ export default class extends BaseApplicationGenerator {
},
});
}

delayTask(method) {
this.queueTask({
method,
taskName: `${this.runningState.methodName}(delayed)`,
queueName: this.runningState.queueName,
});
}
}
68 changes: 36 additions & 32 deletions generators/spring-boot/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,38 +284,34 @@ export default class extends BaseApplicationGenerator {
});
},
addCacheNeedles({ source, application }) {
this.queueTask({
method: () => {
if (application.cacheProviderEhcache) {
const cacheConfigurationFile = `src/main/kotlin/${application.packageFolder}config/CacheConfiguration.kt`;
const needle = `${application.cacheProvider}-add-entry`;
const useJcacheConfiguration = application.cacheProviderRedis;
const addEntryToCacheCallback = entry =>
createNeedleCallback({
needle,
contentToAdd: `createCache(cm, ${entry}${useJcacheConfiguration ? ', jcacheConfiguration' : ''})`,
});

source.addEntryToCache = ({ entry }) => this.editFile(cacheConfigurationFile, addEntryToCacheCallback(entry));
source.addEntityToCache = ({ entityAbsoluteClass, relationships }) => {
const entry = `${entityAbsoluteClass}::class.java.name`;
this.editFile(
cacheConfigurationFile,
addEntryToCacheCallback(entry),
...(relationships ?? [])
.filter(rel => rel.collection)
.map(rel => addEntryToCacheCallback(`${entry} + ".${rel.propertyName}"`)),
);
};
} else {
// Add noop
source.addEntryToCache = () => {};
// Add noop
source.addEntityToCache = () => {};
}
},
taskName: `${this.runningState.methodName}(delayed)`,
queueName: this.runningState.queueName,
this.delayTask(() => {
if (application.cacheProviderEhcache) {
const cacheConfigurationFile = `src/main/kotlin/${application.packageFolder}config/CacheConfiguration.kt`;
const needle = `${application.cacheProvider}-add-entry`;
const useJcacheConfiguration = application.cacheProviderRedis;
const addEntryToCacheCallback = entry =>
createNeedleCallback({
needle,
contentToAdd: `createCache(cm, ${entry}${useJcacheConfiguration ? ', jcacheConfiguration' : ''})`,
});

source.addEntryToCache = ({ entry }) => this.editFile(cacheConfigurationFile, addEntryToCacheCallback(entry));
source.addEntityToCache = ({ entityAbsoluteClass, relationships }) => {
const entry = `${entityAbsoluteClass}::class.java.name`;
this.editFile(
cacheConfigurationFile,
addEntryToCacheCallback(entry),
...(relationships ?? [])
.filter(rel => rel.collection)
.map(rel => addEntryToCacheCallback(`${entry} + ".${rel.propertyName}"`)),
);
};
} else {
// Add noop
source.addEntryToCache = () => {};
// Add noop
source.addEntityToCache = () => {};
}
});
},
});
Expand Down Expand Up @@ -548,4 +544,12 @@ export default class extends BaseApplicationGenerator {
},
});
}

delayTask(method) {
this.queueTask({
method,
taskName: `${this.runningState.methodName}(delayed)`,
queueName: this.runningState.queueName,
});
}
}

0 comments on commit d48626f

Please sign in to comment.