Skip to content

Commit 87ec2da

Browse files
committed
Revert "feat: improved endpoint detection (#21009)"
This reverts commit 530e757.
1 parent 933bc92 commit 87ec2da

File tree

17 files changed

+32
-214
lines changed

17 files changed

+32
-214
lines changed

flow-plugins/flow-maven-plugin/src/test/java/com/vaadin/flow/plugin/maven/TestEndpointGeneratorTaskFactory.java

-12
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
import java.io.File;
1919
import java.io.IOException;
20-
import java.lang.annotation.Annotation;
2120
import java.nio.charset.StandardCharsets;
2221
import java.nio.file.Files;
2322
import java.nio.file.StandardOpenOption;
24-
import java.util.Set;
2523

2624
import org.slf4j.Logger;
2725
import org.slf4j.LoggerFactory;
@@ -49,16 +47,6 @@ public TaskGenerateOpenAPI createTaskGenerateOpenAPI(Options options) {
4947
return new TestTaskGenerateOpenAPI(options);
5048
}
5149

52-
@Override
53-
public Set<Class<? extends Annotation>> getBrowserCallableAnnotations() {
54-
return Set.of();
55-
}
56-
57-
@Override
58-
public boolean hasBrowserCallables(Options options) {
59-
return true;
60-
}
61-
6250
/**
6351
* An abstract parent for the test endpoints generator tasks.
6452
*/

flow-plugins/flow-plugin-base/src/test/java/com/vaadin/flow/plugin/base/BuildFrontendUtilTest.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ public void should_useHillaEngine_withNodeUpdater()
156156
EndpointRequestUtil.class, Mockito.CALLS_REAL_METHODS)) {
157157
util.when(() -> EndpointRequestUtil.isHillaAvailable(Mockito.any()))
158158
.thenReturn(true);
159-
util.when(() -> EndpointRequestUtil
160-
.areHillaEndpointsUsed(Mockito.any())).thenReturn(true);
161159
BuildFrontendUtil.runNodeUpdater(adapter);
162160
}
163161

@@ -170,10 +168,10 @@ public void should_useHillaEngine_withNodeUpdater()
170168
// Hilla Engine requires npm install, the order of execution is critical
171169
final TaskRunNpmInstall taskRunNpmInstall = construction.constructed()
172170
.get(0);
173-
InOrder inOrder = Mockito.inOrder(taskGenerateOpenAPI,
174-
taskRunNpmInstall, taskGenerateEndpoint);
175-
inOrder.verify(taskGenerateOpenAPI).execute();
171+
InOrder inOrder = Mockito.inOrder(taskRunNpmInstall,
172+
taskGenerateOpenAPI, taskGenerateEndpoint);
176173
inOrder.verify(taskRunNpmInstall).execute();
174+
inOrder.verify(taskGenerateOpenAPI).execute();
177175
inOrder.verify(taskGenerateEndpoint).execute();
178176
}
179177

flow-server/src/main/java/com/vaadin/flow/internal/hilla/EndpointRequestUtil.java

-20
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
import jakarta.servlet.http.HttpServletRequest;
2020
import java.io.Serializable;
2121

22-
import com.vaadin.flow.server.frontend.EndpointGeneratorTaskFactory;
23-
import com.vaadin.flow.server.frontend.Options;
2422
import com.vaadin.flow.server.frontend.scanner.ClassFinder;
2523

2624
/**
@@ -88,22 +86,4 @@ static boolean isHillaAvailable(ClassFinder classFinder) {
8886
return false;
8987
}
9088
}
91-
92-
/**
93-
* Checks if Hilla is available and Hilla endpoints are used in the project.
94-
*
95-
* @return {@code true} if Hilla is available and Hilla endpoints are used,
96-
* {@code false} otherwise
97-
*/
98-
static boolean areHillaEndpointsUsed(Options options) {
99-
if (!EndpointRequestUtil.isHillaAvailable()) {
100-
return false;
101-
}
102-
EndpointGeneratorTaskFactory endpointGeneratorTaskFactory = options
103-
.getLookup().lookup(EndpointGeneratorTaskFactory.class);
104-
if (endpointGeneratorTaskFactory != null) {
105-
return endpointGeneratorTaskFactory.hasBrowserCallables(options);
106-
}
107-
return false;
108-
}
10989
}

flow-server/src/main/java/com/vaadin/flow/server/frontend/BundleValidationUtil.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.vaadin.flow.internal.JacksonUtils;
3131
import com.vaadin.flow.internal.StringUtil;
3232
import com.vaadin.flow.internal.UsageStatistics;
33-
import com.vaadin.flow.internal.hilla.EndpointRequestUtil;
3433
import com.vaadin.flow.server.Constants;
3534
import com.vaadin.flow.server.LoadDependenciesOnStartup;
3635
import com.vaadin.flow.server.Mode;
@@ -69,11 +68,9 @@ public static boolean needsBuild(Options options,
6968
try {
7069
boolean needsBuild;
7170
if (mode.isProduction()) {
72-
if (options.isForceProductionBuild()
73-
|| FrontendUtils.isHillaUsed(
74-
options.getFrontendDirectory(),
75-
options.getClassFinder())
76-
|| EndpointRequestUtil.areHillaEndpointsUsed(options)) {
71+
if (options.isForceProductionBuild() || FrontendUtils
72+
.isHillaUsed(options.getFrontendDirectory(),
73+
options.getClassFinder())) {
7774
if (options.isForceProductionBuild()) {
7875
UsageStatistics.markAsUsed("flow/prod-build-requested",
7976
null);

flow-server/src/main/java/com/vaadin/flow/server/frontend/EndpointGeneratorTaskFactory.java

-20
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
package com.vaadin.flow.server.frontend;
1818

19-
import java.lang.annotation.Annotation;
20-
import java.util.Set;
21-
2219
/**
2320
* A factory for creating Vaadin Endpoint generator tasks.
2421
* <p>
@@ -46,21 +43,4 @@ public interface EndpointGeneratorTaskFactory {
4643
* @return an endpoint task that generates open api json file.
4744
*/
4845
TaskGenerateOpenAPI createTaskGenerateOpenAPI(Options options);
49-
50-
/**
51-
* Fetches all endpoint-type annotations from Hilla configuration
52-
*
53-
* @return Set of endpoint-type annotations
54-
*/
55-
Set<Class<? extends Annotation>> getBrowserCallableAnnotations();
56-
57-
/**
58-
* Determines the presence of annotations (e.g. BrowserCallable or Endpoint)
59-
* which require Flow to add Hilla packages to the build.
60-
*
61-
* @param options
62-
* the task options
63-
* @return {@code true} if annotations are present, {@code false} otherwise
64-
*/
65-
boolean hasBrowserCallables(Options options);
6646
}

flow-server/src/main/java/com/vaadin/flow/server/frontend/FrontendUtils.java

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import java.util.stream.Stream;
4141

4242
import com.fasterxml.jackson.databind.JsonNode;
43+
import com.fasterxml.jackson.databind.node.ObjectNode;
4344
import jakarta.servlet.ServletContext;
4445
import org.apache.commons.io.FileUtils;
4546
import org.apache.commons.io.IOUtils;

flow-server/src/main/java/com/vaadin/flow/server/frontend/NodeTasks.java

+14-17
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public class NodeTasks implements FallibleCommand {
7373
TaskGenerateWebComponentBootstrap.class,
7474
TaskGenerateFeatureFlags.class,
7575
TaskInstallFrontendBuildPlugins.class,
76-
TaskGenerateOpenAPI.class,
7776
TaskUpdatePackages.class,
7877
TaskRunNpmInstall.class,
78+
TaskGenerateOpenAPI.class,
7979
TaskGenerateEndpoint.class,
8080
TaskCopyFrontendFiles.class,
8181
TaskCopyLocalFrontendFiles.class,
@@ -319,22 +319,19 @@ private void addEndpointServicesTasks(Options options) {
319319
if (!EndpointRequestUtil.isHillaAvailable(options.getClassFinder())) {
320320
return;
321321
}
322-
if (EndpointRequestUtil.areHillaEndpointsUsed(options)
323-
|| FrontendUtils.isHillaUsed(options.getFrontendDirectory())) {
324-
Lookup lookup = options.getLookup();
325-
EndpointGeneratorTaskFactory endpointGeneratorTaskFactory = lookup
326-
.lookup(EndpointGeneratorTaskFactory.class);
327-
328-
if (endpointGeneratorTaskFactory != null) {
329-
TaskGenerateOpenAPI taskGenerateOpenAPI = endpointGeneratorTaskFactory
330-
.createTaskGenerateOpenAPI(options);
331-
commands.add(taskGenerateOpenAPI);
332-
333-
if (options.getFrontendGeneratedFolder() != null) {
334-
TaskGenerateEndpoint taskGenerateEndpoint = endpointGeneratorTaskFactory
335-
.createTaskGenerateEndpoint(options);
336-
commands.add(taskGenerateEndpoint);
337-
}
322+
Lookup lookup = options.getLookup();
323+
EndpointGeneratorTaskFactory endpointGeneratorTaskFactory = lookup
324+
.lookup(EndpointGeneratorTaskFactory.class);
325+
326+
if (endpointGeneratorTaskFactory != null) {
327+
TaskGenerateOpenAPI taskGenerateOpenAPI = endpointGeneratorTaskFactory
328+
.createTaskGenerateOpenAPI(options);
329+
commands.add(taskGenerateOpenAPI);
330+
331+
if (options.getFrontendGeneratedFolder() != null) {
332+
TaskGenerateEndpoint taskGenerateEndpoint = endpointGeneratorTaskFactory
333+
.createTaskGenerateEndpoint(options);
334+
commands.add(taskGenerateEndpoint);
338335
}
339336
}
340337
}

flow-server/src/main/java/com/vaadin/flow/server/frontend/NodeUpdater.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import com.vaadin.experimental.FeatureFlags;
4444
import com.vaadin.flow.internal.JacksonUtils;
4545
import com.vaadin.flow.internal.JsonDecodingException;
46-
import com.vaadin.flow.internal.hilla.EndpointRequestUtil;
4746
import com.vaadin.flow.server.Constants;
4847
import com.vaadin.flow.server.frontend.scanner.ClassFinder;
4948
import com.vaadin.flow.server.frontend.scanner.FrontendDependencies;
@@ -621,8 +620,7 @@ private ObjectNode generateVersionsFromPackageJson(JsonNode packageJson) {
621620
private void putHillaComponentsDependencies(
622621
Map<String, String> dependencies, String packageJsonKey) {
623622
if (FrontendUtils.isHillaUsed(options.getFrontendDirectory(),
624-
options.getClassFinder())
625-
|| EndpointRequestUtil.areHillaEndpointsUsed(options)) {
623+
options.getClassFinder())) {
626624
if (options.isReactEnabled()) {
627625
dependencies.putAll(readDependenciesIfAvailable(
628626
"hilla/components/react", packageJsonKey));

flow-server/src/test/java/com/vaadin/flow/server/frontend/NodeTasksHillaTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ public void should_useHillaEngine_whenEnabled()
122122
EndpointRequestUtil.class, Mockito.CALLS_REAL_METHODS)) {
123123
util.when(() -> EndpointRequestUtil.isHillaAvailable(Mockito.any()))
124124
.thenReturn(true);
125-
util.when(() -> EndpointRequestUtil
126-
.areHillaEndpointsUsed(Mockito.any())).thenReturn(true);
125+
127126
new NodeTasks(options).execute();
128127
}
129128

vaadin-dev-server/src/main/java/com/vaadin/base/devserver/startup/DevModeInitializer.java

+3-20
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
import com.vaadin.flow.server.Mode;
7070
import com.vaadin.flow.server.VaadinContext;
7171
import com.vaadin.flow.server.VaadinServlet;
72-
import com.vaadin.flow.server.frontend.EndpointGeneratorTaskFactory;
7372
import com.vaadin.flow.server.frontend.FrontendUtils;
7473
import com.vaadin.flow.server.frontend.NodeTasks;
7574
import com.vaadin.flow.server.frontend.Options;
@@ -101,12 +100,9 @@ static class DevModeClassFinder extends DefaultClassFinder {
101100

102101
private static final Set<String> APPLICABLE_CLASS_NAMES = Collections
103102
.unmodifiableSet(calculateApplicableClassNames());
104-
private final Set<Class<? extends Annotation>> browserCallableAnnotations;
105103

106-
public DevModeClassFinder(Set<Class<?>> classes,
107-
Set<Class<? extends Annotation>> browserCallableAnnotations) {
104+
public DevModeClassFinder(Set<Class<?>> classes) {
108105
super(classes);
109-
this.browserCallableAnnotations = browserCallableAnnotations;
110106
}
111107

112108
@Override
@@ -123,8 +119,7 @@ public <T> Set<Class<? extends T>> getSubTypesOf(Class<T> type) {
123119
}
124120

125121
private void ensureImplementation(Class<?> clazz) {
126-
if (!APPLICABLE_CLASS_NAMES.contains(clazz.getName())
127-
&& !browserCallableAnnotations.contains(clazz)) {
122+
if (!APPLICABLE_CLASS_NAMES.contains(clazz.getName())) {
128123
throw new IllegalArgumentException("Unexpected class name "
129124
+ clazz + ". Implementation error: the class finder "
130125
+ "instance is not aware of this class. "
@@ -134,7 +129,6 @@ private void ensureImplementation(Class<?> clazz) {
134129
}
135130

136131
private static Set<String> calculateApplicableClassNames() {
137-
138132
HandlesTypes handlesTypes = DevModeStartupListener.class
139133
.getAnnotation(HandlesTypes.class);
140134
return Stream.of(handlesTypes.value()).map(Class::getName)
@@ -249,18 +243,7 @@ public static DevModeHandler initDevModeHandler(Set<Class<?>> classes,
249243
File frontendFolder = config.getFrontendFolder();
250244

251245
Lookup lookupFromContext = context.getAttribute(Lookup.class);
252-
253-
EndpointGeneratorTaskFactory endpointGeneratorTaskFactory = lookupFromContext
254-
.lookup(EndpointGeneratorTaskFactory.class);
255-
256-
Set<Class<? extends Annotation>> browserCallableAnnotations = new HashSet<>();
257-
if (endpointGeneratorTaskFactory != null) {
258-
browserCallableAnnotations.addAll(endpointGeneratorTaskFactory
259-
.getBrowserCallableAnnotations());
260-
}
261-
262-
Lookup lookupForClassFinder = Lookup.of(
263-
new DevModeClassFinder(classes, browserCallableAnnotations),
246+
Lookup lookupForClassFinder = Lookup.of(new DevModeClassFinder(classes),
264247
ClassFinder.class);
265248
Lookup lookup = Lookup.compose(lookupForClassFinder, lookupFromContext);
266249
Options options = new Options(lookup, baseDir)

vaadin-dev-server/src/test/java/com/vaadin/base/devserver/DevModeEndpointTest.java

-4
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ public void should_generateOpenApi() throws Exception {
112112
EndpointRequestUtil.class, Mockito.CALLS_REAL_METHODS)) {
113113
util.when(() -> EndpointRequestUtil.isHillaAvailable(Mockito.any()))
114114
.thenReturn(true);
115-
util.when(() -> EndpointRequestUtil
116-
.areHillaEndpointsUsed(Mockito.any())).thenReturn(true);
117115
devModeStartupListener.onStartup(classes, servletContext);
118116
handler = getDevModeHandler();
119117
waitForDevServer();
@@ -146,8 +144,6 @@ public void should_generateTs_files() throws Exception {
146144
EndpointRequestUtil.class, Mockito.CALLS_REAL_METHODS)) {
147145
util.when(() -> EndpointRequestUtil.isHillaAvailable(Mockito.any()))
148146
.thenReturn(true);
149-
util.when(() -> EndpointRequestUtil
150-
.areHillaEndpointsUsed(Mockito.any())).thenReturn(true);
151147
devModeStartupListener.onStartup(classes, servletContext);
152148
handler = getDevModeHandler();
153149
waitForDevServer();

vaadin-dev-server/src/test/java/com/vaadin/base/devserver/TestEndpointGeneratorTaskFactory.java

-12
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
import java.io.File;
1919
import java.io.IOException;
20-
import java.lang.annotation.Annotation;
2120
import java.nio.charset.StandardCharsets;
2221
import java.nio.file.Files;
2322
import java.nio.file.StandardOpenOption;
24-
import java.util.Set;
2523

2624
import org.slf4j.Logger;
2725
import org.slf4j.LoggerFactory;
@@ -49,16 +47,6 @@ public TaskGenerateOpenAPI createTaskGenerateOpenAPI(Options options) {
4947
return new TestTaskGenerateOpenAPI(options);
5048
}
5149

52-
@Override
53-
public Set<Class<? extends Annotation>> getBrowserCallableAnnotations() {
54-
return Set.of();
55-
}
56-
57-
@Override
58-
public boolean hasBrowserCallables(Options options) {
59-
return true;
60-
}
61-
6250
/**
6351
* An abstract parent for the test endpoints generator tasks.
6452
*/

vaadin-dev-server/src/test/java/com/vaadin/base/devserver/startup/DevModeClassFinderTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.Arrays;
2121
import java.util.Collection;
2222
import java.util.Collections;
23-
import java.util.HashSet;
2423
import java.util.List;
2524
import java.util.stream.Collectors;
2625
import java.util.stream.Stream;
@@ -56,7 +55,7 @@
5655
public class DevModeClassFinderTest {
5756

5857
private DevModeClassFinder classFinder = new DevModeClassFinder(
59-
Collections.emptySet(), Collections.emptySet());
58+
Collections.emptySet());
6059

6160
@Test
6261
public void applicableClasses_knownClasses() {
@@ -128,7 +127,7 @@ public void callGetgetAnnotatedClassesByName_unexpectedType_throw()
128127
@Test(expected = IllegalArgumentException.class)
129128
public void callGetSubTypesOfByClass_unexpectedType_throw() {
130129
DevModeClassFinder classFinder = new DevModeClassFinder(
131-
Collections.emptySet(), Collections.emptySet());
130+
Collections.emptySet());
132131
classFinder.getSubTypesOf(Object.class);
133132
}
134133

vaadin-dev-server/src/test/java/com/vaadin/base/devserver/startup/DevModeInitializerTest.java

-4
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,6 @@ public void should_generateOpenApi_when_EndpointPresents()
357357
EndpointRequestUtil.class, Mockito.CALLS_REAL_METHODS)) {
358358
util.when(() -> EndpointRequestUtil
359359
.isHillaAvailable(Mockito.any())).thenReturn(true);
360-
util.when(() -> EndpointRequestUtil
361-
.areHillaEndpointsUsed(Mockito.any())).thenReturn(true);
362360
devModeStartupListener.onStartup(classes, servletContext);
363361
handler = getDevModeHandler();
364362
waitForDevServer();
@@ -427,8 +425,6 @@ public void should_generateTs_files() throws Exception {
427425
EndpointRequestUtil.class, Mockito.CALLS_REAL_METHODS)) {
428426
util.when(() -> EndpointRequestUtil
429427
.isHillaAvailable(Mockito.any())).thenReturn(true);
430-
util.when(() -> EndpointRequestUtil
431-
.areHillaEndpointsUsed(Mockito.any())).thenReturn(true);
432428
devModeStartupListener.onStartup(classes, servletContext);
433429
handler = getDevModeHandler();
434430
waitForDevServer();

vaadin-spring/src/main/java/com/vaadin/flow/spring/SpringBootAutoConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* @author Vaadin Ltd
4848
*
4949
*/
50-
@Configuration(proxyBeanMethods = false)
50+
@Configuration
5151
@AutoConfigureBefore(WebMvcAutoConfiguration.class)
5252
@ConditionalOnClass(ServletContextInitializer.class)
5353
@EnableConfigurationProperties(VaadinConfigurationProperties.class)

0 commit comments

Comments
 (0)