|
From: Dmitriy K. <dko...@ru...> - 2004-04-29 17:50:24
|
Alex, to answer your first question - the "magic" behind PropertyConfigurer's Resource property conversion from String is done by org.springframework.core.io.ResourceEditor Regards, Dmitriy. Alexi Polenur wrote: > Hi all, > > In Petclinic I see following in applicationContext.xml > > <bean id="propertyConfigurer" > class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> > > <property > name="location"><value>/WEB-INF/jdbc.properties</value></property> > </bean> > > The location property in PropertyPlaceholderConfigurer is of type > Resource. The question is, how does Spring "knows" to take > /WEB-INF/jdbc.properties string and construct an instance wich > implements a Resource interface. How does it knows what implementation > of this interface to use? > > The second part of my question is a "real question". What I would like > to do is to have PropertyConfigurer to setup different property set > based on context (system property). > > The reason I need it is for moving code from one environment to another. > For example when I move my app. from development to production my DB is > changing so I would like my PropertyConfigurer to read different > property file based on some system property which identifies environment. > > The way I am trying to do it is by creating a special subclass of a > Resource which uses a ResourceBundle instead of single property file. > Each locale in ResourceBundle represents an environment (dev, test, > prod). My context now looks like that: > > <bean id="resourceA" class="myresources.ContextualResource"> > </bean> > <bean id="propertyConfigurer" > class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> > > <property name="locations"> > <list> > <ref local="resourceA"/> > </list> > </property> > </bean> > > Does it sound like a resonable approach? Has somebody done it before ? > Is it better way of doing this ? > > Thanks, Alexi > > > ------------------------------------------------------- > This SF.Net email is sponsored by: Oracle 10g > Get certified on the hottest thing ever to hit the market... Oracle 10g. > Take an Oracle 10g class now, and we'll give you the exam FREE. > http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer |