Archive

Archive for January, 2011

How to use PropertyPlaceholderConfigurer

January 14, 2011 Leave a comment

org.springframework.beans.factory.config.PropertyPlaceholderConfigurer is a  bean factory post processor. This class can be used , when you want to provide some information to bean  configuration file from external resource(property file).
For example most of the time we used to hardcode the database related information directly in the bean configuration file itself. Using PropertyPlaceholderConfigurer we can configure the connection information such a way that, we will give some place holder in the bean configuration file .  Spring container pick up the value for that place holder from an external property file. This is the same concept we use in Ant.

Bean configuration
beanConfig.xml

<bean id="dataSource" destroy-method="close">
 <property name="driverClassName"><value>${db.driverClassName}</value></property>
 <property name="url"><value>${db.url}</value></property>
 <property name="username"><value>${db.username}</value></property>
 <property name="password"><value>${db.password}</value></property>
</bean>

Property file
Oracle.properties


db.driverClassName=oracle.jdbc.driver.OracleDriver
db.url=jdbc:oracle:thin:@db-server:1521:db-schema
db.username=username
db.password=password

How to configure this property file into  BeanConfig.xml

Simply configure PropertyPlaceholderConfigurer bean like other beans

<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
 <property name="location"><value>Oracle.properties</value></property>
</bean>
<bean id="dataSource" destroy-method="close">
 <property name="driverClassName"><value>${db.driverClassName}</value></property>
 <property name="url"><value>${db.url}</value></property>
 <property name="username"><value>${db.username}</value></property>
 <property name="password"><value>${db.password}</value></property>
</bean>

Categories: Uncategorized Tags:

Life@2010

January 14, 2011 Leave a comment

This year lots of beautiful incidents happened in my personal and professional life. In Jan i have joined with Tata Consultancy Service. I got lots of new friends from my current employer  Bhavik, Pradhamesh,Shanthanu..  But carrier wise nothing big is happened , still i got a position as module lead :) .  Didn’t get any challenging technical task this year. I believe that, my current employer has  not utilized my innovative talent. But at the end of the appraisal they have given a good rating :) . TCS has rated me Top 10 Developers in 2010.  I doesn’t write more blogs this year. I will regularly update my blog this year.  Personal point of view.. i am blessed to have a such a good wife.. she has supported me and stand with me some of the critical time of my life.. Rekha i love you..

I am wishing every one a happy new year

Categories: Uncategorized
Follow

Get every new post delivered to your Inbox.