shashidhar kumar

Greenhorn
+ Follow
since Jan 09, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

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.
11 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.
11 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 ?
11 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
11 years ago