This week's book giveaway is in the Agile/Processes forum.
We're giving away four copies of Building Green Software: A Sustainable Approach to Software Development and Operations and have Anne Currie, Sarah Hsu , Sara Bergman on-line!
See this thread for details.

shashidhar kumar

Greenhorn
+ Follow
since Jan 09, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by shashidhar kumar


Here is one more update.

The bean in xml was not given "scope" explicitly, i.e., it is like this:
<bean id="simpleAction" class="com.sapient.SimpleAction"/>

In java class, annotation was given scope explicitly.
i.e.
@Component
@Scope("prototype")

But finally, the scope of the bean is singleton from its behaviour.
That might mean, when bean is defined in the xml file, it overwrites all the properties specified elsewhere that are applicable for the bean.

Thanks,
Shashidhar.
12 years ago

Thanks Kathleen, It very much helped in my understanding.

I am trying to implement it with a sample code and will tell the execution behaviour.
12 years ago
Thanks Kathleen, Could you please explain, how bean gets 'prototype' scope ? If you have reference which I can take look into, please provide it.

When does duplicate setting in XML overwrite the setting in annotation ?

Further, the following two lines are placed at top of applicationContext.xml file, before bean definitions (the file contains bean definitions, used by ApplicationContext to create itself).

<context:annotation-config />
<context:component-scan base-package="com.project.struts" />

Do the position of these two lines matter ?
12 years ago
Hi,

This is the definition in xml file, spring reads through ApplicationContext.
<bean id="simpleAction" class="com.sapient.SimpleAction"/>
Here, since scope is not defined, it's scope will be singleton.

In SimpleAction java class, using annotations, it is defined here as well:
@Component
@Scope("prototype")

Do the SimpleAction bean get prototype scope, mentioned in java file ?

Thanks,
Shashi
12 years ago