use of io.quarkus.runtime.ShutdownContext in project quarkus-github-app by quarkiverse.
the class GitHubAppRecorder method replayUiHandler.
public Handler<RoutingContext> replayUiHandler(String replayUiFinalDestination, String replayUiPath, List<FileSystemStaticHandler.StaticWebRootConfiguration> webRootConfigurations, ShutdownContext shutdownContext) {
WebJarStaticHandler handler = new WebJarStaticHandler(replayUiFinalDestination, replayUiPath, webRootConfigurations);
shutdownContext.addShutdownTask(new ShutdownContext.CloseRunnable(handler));
return handler;
}
use of io.quarkus.runtime.ShutdownContext in project quarkus by quarkusio.
the class SmallRyeHealthRecorder method uiHandler.
public Handler<RoutingContext> uiHandler(String healthUiFinalDestination, String healthUiPath, List<FileSystemStaticHandler.StaticWebRootConfiguration> webRootConfigurations, SmallRyeHealthRuntimeConfig runtimeConfig, ShutdownContext shutdownContext) {
if (runtimeConfig.enable) {
WebJarStaticHandler handler = new WebJarStaticHandler(healthUiFinalDestination, healthUiPath, webRootConfigurations);
shutdownContext.addShutdownTask(new ShutdownContext.CloseRunnable(handler));
return handler;
} else {
return new WebJarNotFoundHandler();
}
}
use of io.quarkus.runtime.ShutdownContext in project quarkus by quarkusio.
the class SwaggerUiRecorder method handler.
public Handler<RoutingContext> handler(String swaggerUiFinalDestination, String swaggerUiPath, List<FileSystemStaticHandler.StaticWebRootConfiguration> webRootConfigurations, SwaggerUiRuntimeConfig runtimeConfig, ShutdownContext shutdownContext) {
if (runtimeConfig.enable) {
WebJarStaticHandler handler = new WebJarStaticHandler(swaggerUiFinalDestination, swaggerUiPath, webRootConfigurations);
shutdownContext.addShutdownTask(new ShutdownContext.CloseRunnable(handler));
return handler;
} else {
return new WebJarNotFoundHandler();
}
}
use of io.quarkus.runtime.ShutdownContext in project quarkus by quarkusio.
the class ResteasyReactiveRecorder method createDeployment.
public RuntimeValue<Deployment> createDeployment(DeploymentInfo info, BeanContainer beanContainer, ShutdownContext shutdownContext, HttpBuildTimeConfig vertxConfig, RequestContextFactory contextFactory, BeanFactory<ResteasyReactiveInitialiser> initClassFactory, LaunchMode launchMode, boolean resumeOn404) {
if (resumeOn404) {
info.setResumeOn404(true);
}
CurrentRequestManager.setCurrentRequestInstance(new QuarkusCurrentRequest(beanContainer.instance(CurrentVertxRequest.class)));
BlockingOperationSupport.setIoThreadDetector(new BlockingOperationSupport.IOThreadDetector() {
@Override
public boolean isBlockingAllowed() {
return BlockingOperationControl.isBlockingAllowed();
}
});
Consumer<Closeable> closeTaskHandler = new Consumer<Closeable>() {
@Override
public void accept(Closeable closeable) {
shutdownContext.addShutdownTask(new ShutdownContext.CloseRunnable(closeable));
}
};
CurrentIdentityAssociation currentIdentityAssociation = Arc.container().instance(CurrentIdentityAssociation.class).get();
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
if (contextFactory == null) {
contextFactory = new RequestContextFactory() {
@Override
public ResteasyReactiveRequestContext createContext(Deployment deployment, ProvidersImpl providers, Object context, ThreadSetupAction requestContext, ServerRestHandler[] handlerChain, ServerRestHandler[] abortHandlerChain) {
return new QuarkusResteasyReactiveRequestContext(deployment, providers, (RoutingContext) context, requestContext, handlerChain, abortHandlerChain, launchMode == LaunchMode.DEVELOPMENT ? tccl : null, currentIdentityAssociation);
}
};
}
RuntimeDeploymentManager runtimeDeploymentManager = new RuntimeDeploymentManager(info, EXECUTOR_SUPPLIER, closeTaskHandler, contextFactory, new ArcThreadSetupAction(beanContainer.requestContext()), vertxConfig.rootPath);
Deployment deployment = runtimeDeploymentManager.deploy();
initClassFactory.createInstance().getInstance().init(deployment);
currentDeployment = deployment;
if (LaunchMode.current() == LaunchMode.DEVELOPMENT) {
classMappers = deployment.getClassMappers();
RuntimeResourceVisitor.visitRuntimeResources(classMappers, ScoreSystem.ScoreVisitor);
}
return new RuntimeValue<>(deployment);
}
use of io.quarkus.runtime.ShutdownContext in project quarkus by quarkusio.
the class UndertowDeploymentRecorder method createDeployment.
public RuntimeValue<DeploymentInfo> createDeployment(String name, Set<String> knownFile, Set<String> knownDirectories, LaunchMode launchMode, ShutdownContext context, String mountPoint, String defaultCharset, String requestCharacterEncoding, String responseCharacterEncoding, boolean proactiveAuth, List<String> welcomeFiles) {
DeploymentInfo d = new DeploymentInfo();
d.setDefaultRequestEncoding(requestCharacterEncoding);
d.setDefaultResponseEncoding(responseCharacterEncoding);
d.setDefaultEncoding(defaultCharset);
d.setSessionIdGenerator(new QuarkusSessionIdGenerator());
d.setClassLoader(getClass().getClassLoader());
d.setDeploymentName(name);
d.setContextPath(mountPoint);
d.setEagerFilterInit(true);
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null) {
cl = new ClassLoader() {
};
}
d.setClassLoader(cl);
// TODO: we need better handling of static resources
ResourceManager resourceManager;
if (hotDeploymentResourcePaths == null) {
resourceManager = new KnownPathResourceManager(knownFile, knownDirectories, new ClassPathResourceManager(d.getClassLoader(), "META-INF/resources"));
} else {
List<ResourceManager> managers = new ArrayList<>();
for (Path i : hotDeploymentResourcePaths) {
managers.add(new PathResourceManager(i));
}
managers.add(new ClassPathResourceManager(d.getClassLoader(), "META-INF/resources"));
resourceManager = new DelegatingResourceManager(managers.toArray(new ResourceManager[0]));
}
if (launchMode == LaunchMode.NORMAL) {
// todo: cache configuration
resourceManager = new CachingResourceManager(1000, 0, null, resourceManager, 2000);
}
d.setResourceManager(resourceManager);
if (welcomeFiles != null) {
// if available, use welcome-files from web.xml
d.addWelcomePages(welcomeFiles);
} else {
d.addWelcomePages("index.html", "index.htm");
}
d.addServlet(new ServletInfo(ServletPathMatches.DEFAULT_SERVLET_NAME, DefaultServlet.class).setAsyncSupported(true));
for (HandlerWrapper i : hotDeploymentWrappers) {
d.addOuterHandlerChainWrapper(i);
}
d.addAuthenticationMechanism("QUARKUS", new ImmediateAuthenticationMechanismFactory(QuarkusAuthMechanism.INSTANCE));
d.setLoginConfig(new LoginConfig("QUARKUS", "QUARKUS"));
context.addShutdownTask(new ShutdownContext.CloseRunnable(d.getResourceManager()));
d.addNotificationReceiver(new NotificationReceiver() {
@Override
public void handleNotification(SecurityNotification notification) {
if (notification.getEventType() == SecurityNotification.EventType.AUTHENTICATED) {
QuarkusUndertowAccount account = (QuarkusUndertowAccount) notification.getAccount();
Instance<CurrentIdentityAssociation> instance = CDI.current().select(CurrentIdentityAssociation.class);
if (instance.isResolvable())
instance.get().setIdentity(account.getSecurityIdentity());
}
}
});
if (proactiveAuth) {
d.setAuthenticationMode(AuthenticationMode.PRO_ACTIVE);
} else {
d.setAuthenticationMode(AuthenticationMode.CONSTRAINT_DRIVEN);
}
return new RuntimeValue<>(d);
}
Aggregations