use of com.vaadin.flow.server.VaadinServletContext in project flow by vaadin.
the class DevModeBrowserLauncher method isProductionMode.
private static boolean isProductionMode(GenericWebApplicationContext app) {
ServletContext servletContext = app.getServletContext();
VaadinContext context = new VaadinServletContext(servletContext);
ApplicationConfiguration applicationConfiguration = ApplicationConfiguration.get(context);
return applicationConfiguration.isProductionMode();
}
use of com.vaadin.flow.server.VaadinServletContext in project flow by vaadin.
the class SpringLookupInitializer method initialize.
@Override
public void initialize(VaadinContext context, Map<Class<?>, Collection<Class<?>>> services, VaadinApplicationInitializationBootstrap bootstrap) throws ServletException {
VaadinServletContext servletContext = (VaadinServletContext) context;
boolean isContextAvailable = false;
synchronized (LOCK) {
ApplicationContext appContext = getApplicationContext(context);
isContextAvailable = appContext != null;
if (!isContextAvailable) {
context.setAttribute(BootstrapCallable.class, () -> doInitialize(servletContext, services, bootstrap));
}
}
if (isContextAvailable) {
doInitialize(servletContext, services, bootstrap);
}
}
use of com.vaadin.flow.server.VaadinServletContext in project flow by vaadin.
the class VaadinServletContextInitializer method onStartup.
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
// Verify servlet version also for SpringBoot.
ServletVerifier.verifyServletVersion();
VaadinServletContext vaadinContext = new VaadinServletContext(servletContext);
servletContext.addListener(createCompositeListener(vaadinContext));
}
use of com.vaadin.flow.server.VaadinServletContext in project flow by vaadin.
the class LookupServletContainerInitializer method process.
@Override
public void process(Set<Class<?>> classSet, ServletContext servletContext) throws ServletException {
if (classSet == null) {
throw new ServletException(ServletContainerInitializer.class.getSimpleName() + " is called but the " + "provided set of classes is 'null'. " + LookupInitializer.class + " always presents " + "and has to be passed to the 'onStartup' method as an argument " + "in the set of classes if the servlet container supports Servlet 3.0 specification. " + "The propject configuration is broken somehow or you are using Servlet 3.0 incompatible container.");
}
if (!classSet.contains(LookupInitializer.class)) {
// executed at all.
return;
}
VaadinServletContext vaadinContext = new VaadinServletContext(servletContext);
Map<Class<?>, Collection<Class<?>>> services = new HashMap<>();
collectSubclasses(AbstractLookupInitializer.class, classSet, services);
AbstractLookupInitializer initializer = getLookupInitializer(services);
services.remove(AbstractLookupInitializer.class);
collectServiceImplementations(classSet, services);
initializer.initialize(vaadinContext, services, lookup -> {
vaadinContext.setAttribute(Lookup.class, lookup);
DeferredServletContextInitializers deferredInitializers;
synchronized (servletContext) {
deferredInitializers = vaadinContext.getAttribute(DeferredServletContextInitializers.class);
vaadinContext.removeAttribute(DeferredServletContextInitializers.class);
}
if (deferredInitializers != null) {
deferredInitializers.runInitializers(servletContext);
}
});
}
use of com.vaadin.flow.server.VaadinServletContext in project flow by vaadin.
the class ServletDeployer method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext context = sce.getServletContext();
Collection<DeploymentConfiguration> servletConfigurations = getServletConfigurations(context);
VaadinServletContext vaadinContext = new VaadinServletContext(context);
ApplicationConfiguration config = ApplicationConfiguration.get(vaadinContext);
boolean enableServlets = !config.disableAutomaticServletRegistration();
boolean productionMode = false;
for (DeploymentConfiguration configuration : servletConfigurations) {
productionMode = productionMode || configuration.isProductionMode();
}
VaadinServletCreation servletCreation = enableServlets ? createAppServlet(context) : null;
logServletCreation(servletCreation, context, productionMode);
}
Aggregations