Skip to content
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

feat: improved endpoint detection #3255

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/
package com.vaadin.hilla.internal;

import com.vaadin.hilla.engine.EngineConfiguration;
import java.lang.annotation.Annotation;
import java.util.HashSet;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -26,8 +29,13 @@
import com.vaadin.flow.server.frontend.Options;
import com.vaadin.flow.server.frontend.TaskGenerateEndpoint;
import com.vaadin.flow.server.frontend.TaskGenerateOpenAPI;

import com.vaadin.flow.server.frontend.scanner.ClassFinder;
import com.vaadin.hilla.BrowserCallable;
import com.vaadin.hilla.Endpoint;
import com.vaadin.hilla.EndpointExposed;
import com.vaadin.hilla.engine.EngineConfiguration;
import com.vaadin.hilla.engine.ParserProcessor;
import com.vaadin.hilla.signals.handler.SignalsHandler;

/**
* An implementation of the EndpointGeneratorTaskFactory, which creates endpoint
Expand Down Expand Up @@ -75,6 +83,26 @@ public TaskGenerateOpenAPI createTaskGenerateOpenAPI(Options options) {
return new TaskGenerateOpenAPIImpl(engineConfiguration);
}

@Override
public Set<Class<? extends Annotation>> getBrowserCallableAnnotations() {
Set<Class<? extends Annotation>> classes = new HashSet<>();
classes.add(BrowserCallable.class);
classes.add(Endpoint.class);
classes.add(EndpointExposed.class);
return classes;
}

@Override
public boolean hasBrowserCallables(Options options) {
Set<Class<?>> foundClasses = new HashSet<>();
ClassFinder classFinder = options.getClassFinder();
getBrowserCallableAnnotations().forEach(annotation -> {
foundClasses.addAll(classFinder.getAnnotatedClasses(annotation));
});
foundClasses.remove(SignalsHandler.class);
return !foundClasses.isEmpty();
}

private static class SkipTaskGenerateEndpoint
implements TaskGenerateEndpoint {
@Override
Expand Down
Loading