You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Minto van der sluis <mi...@xup.nl> on 2012/08/31 13:39:46 UTC

isis.properties outside WebApp war file


Sorry for 'flooding' the list but I just noticed I was subscribed to the
dev mailing list and my messages to the users mailing list were blocked.
So resending them after subscribing to the correct mailing list.


Hi folks,

In my application I configured the sql objectstore in the
isis.properties file. Also the database connection information is inside
the isis.properties file (isis.persistor.sql.jdbc.* entries).

As a result of this the database connection info ends up being inside my
WAR file. This prevents me from deploying the same WAR file in the
various DTAP (Development, Test, Acceptance, Production) environment.

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?

Regards,

Minto


Re: isis.properties outside WebApp war file

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
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

Re: isis.properties outside WebApp war file

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
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