views:

29

answers:

1

Currently all web apps are deployed using seperate config files:

<!-- <import bean.... production/> -->
<import bean... development/>

This has disadvantages, even if you only need to swap out one config file, that I'm sure everyone is familiar with (wondering what just deployed without searching through XML is one of them)

I want to add Logging to my application that basically says 'RUNNING IN PRODUCTION MODE', with a description of the services deployed and what mode they are working in.

RUNNING IN PRODUCTION MODE 
Client Service - Production
Messaging Service - Local

and so on...

Is this possible in Spring using a conventional deployment (putting a war on a server)? What other things do people do to manage deployments and software configurations?

If not, what other ways could you achieve something similar?

+2  A: 

Yes it is. You use a PropertyPlaceholderConfigurer to dynamically add properties and have a different properties file in each environment. For example:

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="location" value="classpath:environment.properties"/>
</bean>

This one is loaded from the classpath, which might work for you or might not depending on how you start your application. So you can properties in it like:

environment.message=DEVELOPMENT ENVIRONMENT

You then have a few options on how to get this to a Web page. Probably the simplest is to use an interceptor to add a request attribute and inject the value of $(environment.message} from Spring config.

Anyway, hope that points you in the right direction.

cletus