On 31 August 2012 12:39, Minto van der sluis <mi...@xup.nl> wrote:

>
> How can I extract the database connection info from the isis.properties
> inside the WAR to something that is outside the WAR file. For instance
> like a configuration directory.
>
> I looked in the documentation and the source code but could not find a
> clear answer. Overriding the IsisWebAppBootstrapper with my own is my
> last option. However my guts are telling me that ISIS somewhere already
> has support for this. I just can't figure out how.
>
> Can anyone help me out here? Or do I really have to override the
> IsisWebAppBootstrapper?
>
>
Hmm, the nice thing about open source is that you can bend it to your own
requirements.  So, no, I don't think you are any missing anything, and yes,
it's a good enhancement.

I recommend that you raise a ticket and - if you like - attach a patch with
your preferred solution.

Looking at the code myself, I see:


public class IsisWebAppBootstrapper implements ServletContextListener {
   ...
    public void contextInitialized(final ServletContextEvent
servletContextEvent) {
        try {
            final ServletContext servletContext =
servletContextEvent.getServletContext();

            final String webappDir = servletContext.getRealPath("/");
            final String webInfDir = servletContext.getRealPath("/WEB-INF");
            loggingConfigurer.configureLogging(webInfDir, new String[0]);

            // will load either from WEB-INF or from the classpath.
            final IsisConfigurationBuilder isisConfigurationBuilder =
              new IsisConfigurationBuilderResourceStreams(
                  new ResourceStreamSourceForWebInf(servletContext),
ResourceStreamSourceContextLoaderClassPath.create());
            ...
    }
}

Actually, with the current impl, it would seem that you could just build a
JAR with your resources and add it to the classpath.  But I don't think
that's quite what you want.

So, I reckon instead that you want a way to provide another
ResourceStreamSource, probably
org.apache.isis.core.commons.resource.ResourceStreamSourceFileSystem.  The
location of the directory to load could be read from context-params.

Something like

    final String configDir =
servletContextEvent.getServletContext().getInitParam("config-dir");
    final ResourceStreamSource extraRss
= ResourceStreamSourceFileSystem.create(configDir);

and then use in the constructor of IsisConfigurationBuilderResourceStreams,


HTH

Dan

Reply via email to