Skip to content

Provide runtime hints for Spring Boot 3 native applications #2483

Open
@Artur-

Description

@Artur-

Spring Boot 3 native applications require compile time definitions of which reflection data needs to be available at runtime. Atmosphere could provide this info for its own classes by adding a RuntimeHintsRegistrar.

An example registrar I have tested basic functionality with looks like this (certainly incomplete):

public class AtmosphereHintsRegistrar implements RuntimeHintsRegistrar {

    @Override
    public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
        ReflectionHints ref = hints.reflection();
        try {
            for (Class<?> c : getAtmosphereClasses()) {
                ref.registerType(c, MemberCategory.values());
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }

    private Collection<? extends Class<?>> getAtmosphereClasses() {
        Set<Class<?>> classes = new HashSet<>();
        classes.add(DefaultAtmosphereResourceFactory.class);
        classes.add(SimpleHttpProtocol.class);

        classes.addAll(AtmosphereFramework.DEFAULT_ATMOSPHERE_INTERCEPTORS);
        classes.add(AtmosphereResourceLifecycleInterceptor.class);
        classes.add(TrackMessageSizeInterceptor.class);
        classes.add(SuspendTrackerInterceptor.class);
        classes.add(DefaultBroadcasterFactory.class);
        classes.add(SimpleBroadcaster.class);
        classes.add(DefaultBroadcaster.class);
        classes.add(UUIDBroadcasterCache.class);
        classes.add(VoidAnnotationProcessor.class);
        classes.add(DefaultAtmosphereResourceSessionFactory.class);
        classes.add(JSR356AsyncSupport.class);
        classes.add(DefaultMetaBroadcaster.class);

        return classes;
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions