Skip to content

Commit c801bb3

Browse files
committed
router: deprecated mvc(Class, *) router
- Fix #3658 [minor] Default route suffix doesn't match reflection-based MVC fix #3657
1 parent 4523077 commit c801bb3

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

jooby/src/main/java/io/jooby/Jooby.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,17 +541,20 @@ public Jooby mvc(@NonNull MvcExtension router) {
541541
}
542542

543543
@NonNull @Override
544+
@Deprecated(since = "3.8.0", forRemoval = true)
544545
public Jooby mvc(@NonNull Object router) {
545546
Provider provider = () -> router;
546547
return mvc(router.getClass(), provider);
547548
}
548549

549550
@NonNull @Override
551+
@Deprecated(since = "3.8.0", forRemoval = true)
550552
public Jooby mvc(@NonNull Class router) {
551553
return mvc(router, () -> require(router));
552554
}
553555

554556
@NonNull @Override
557+
@Deprecated(since = "3.8.0", forRemoval = true)
555558
public <T> Jooby mvc(@NonNull Class<T> router, @NonNull Provider<T> provider) {
556559
try {
557560
MvcFactory module = loadModule(router);
@@ -563,6 +566,7 @@ public <T> Jooby mvc(@NonNull Class<T> router, @NonNull Provider<T> provider) {
563566
}
564567
}
565568

569+
@Deprecated(since = "3.8.0", forRemoval = true)
566570
private <T> MvcFactory<T> loadModule(Class<T> router) {
567571
try {
568572
ServiceLoader<MvcFactory> modules = ServiceLoader.load(MvcFactory.class);
@@ -571,10 +575,10 @@ private <T> MvcFactory<T> loadModule(Class<T> router) {
571575
.findFirst()
572576
.orElseGet(
573577
() ->
574-
/** Make happy IDE incremental build: */
578+
/* Make happy IDE incremental build: */
575579
mvcReflectionFallback(router, getClassLoader()));
576580
} catch (ServiceConfigurationError notfound) {
577-
/** Make happy IDE incremental build: */
581+
/* Make happy IDE incremental build: */
578582
return mvcReflectionFallback(router, getClassLoader());
579583
}
580584
}
@@ -1508,7 +1512,10 @@ private void joobyRunHook(ClassLoader loader, Server server) {
15081512
*/
15091513
private MvcFactory mvcReflectionFallback(Class source, ClassLoader classLoader) {
15101514
try {
1511-
String moduleName = source.getName() + "$Module";
1515+
var moduleName =
1516+
System.getProperty("jooby.routerPrefix", "")
1517+
+ source.getName()
1518+
+ System.getProperty("jooby.routerSuffix", "_");
15121519
Class<?> moduleType = classLoader.loadClass(moduleName);
15131520
Constructor<?> constructor = moduleType.getDeclaredConstructor();
15141521
getLog().debug("Loading mvc using reflection: " + source);

jooby/src/main/java/io/jooby/MvcFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*
1313
* @since 2.1.0
1414
*/
15+
@Deprecated(since = "3.8.0", forRemoval = true)
1516
public interface MvcFactory<T> {
1617
/**
1718
* Check if the factory applies for the given MVC route.

0 commit comments

Comments
 (0)