0
votes

I'm trying to move the following (working) code to an extension:

@WebListener
public class StartupListener implements ServletContextListener {

    @ConfigProperty(name = "javax.faces.PROJECT_STAGE")
    String projectStage;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        sce.getServletContext().setInitParameter("javax.faces.PROJECT_STAGE", projectStage);
    }

}

When I move this code to an extension runtime module the property is not resolved (it is null).

The extension source code can be found here.

1
I'll let other answer the core of the question but this property should really be read at build time. The project stage is well mapped with our notion of dev / test / prod and the notion of configuration profile. This should be read at build time and injected to the framework as part of the build time bootstrap approach instead of being a runtime property e.g. with quarkus.io/guides/extension-authors-guide#bytecode-recording - Emmanuel Bernard
Yes, agreed, it will be nice to have javax.faces.PROJECT_STAGE aligned with Quarkus stage so user doesn't even need to add an entry in application.properties (unless one wants to override the default stage behaviour) - rmpestano
You mean something like this @EmmanuelBernard? github.com/rmpestano/quarkus-myfaces/blob/… - rmpestano

1 Answers

0
votes

Managed to make it work programatically via config provider:

@Override
public void contextInitialized(ServletContextEvent sce) {
    Config config = ConfigProvider.getConfig();
    String projectStage = config.getValue("javax.faces.PROJECT_STAGE", String.class);
    sce.getServletContext().setInitParameter("javax.faces.PROJECT_STAGE", projectStage);
}