All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.aesteve.vertx.nubes.reflections.SocketFactory Maven / Gradle / Ivy

The newest version!
package com.github.aesteve.vertx.nubes.reflections;

import com.github.aesteve.vertx.nubes.Config;
import com.github.aesteve.vertx.nubes.annotations.sockjs.SockJS;
import com.github.aesteve.vertx.nubes.reflections.visitors.SockJSVisitor;
import io.vertx.ext.web.Router;
import org.reflections.Reflections;

import java.util.Set;

public class SocketFactory implements HandlerFactory {

  private final Router router;
  private final Config config;

  public SocketFactory(Router router, Config config) {
    this.router = router;
    this.config = config;
  }

  @Override
  public void createHandlers() {
    config.forEachControllerPackage(controllerPackage -> {
      Reflections reflections = new Reflections(controllerPackage);
      Set> controllers = reflections.getTypesAnnotatedWith(SockJS.class);
      controllers.forEach(this::createSocketHandlers);
    });
  }

  private  void createSocketHandlers(Class controller) {
    SockJSVisitor visitor = new SockJSVisitor<>(controller, config, router);
    visitor.visit();
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy