• Post Reply Bookmark Topic Watch Topic
  • New Topic

Spring - singleton attribute not available when using namespace  RSS feed

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using the xmlns and xsi:schemaLocation attributes in my beans tag for my applicationContext.xml file instead of using the dtd for defining DOCTYPE. The problem I'm running into is I can't define the bean tags with singleton="false". I need to have a couple of the classes in the applicationContext file as singletons, but I also need to have some of them not be singletons. There just doesn't seem to be singleton attribute available when I'm using namespace instead of a DTD. Can anyone help?

Thank you in advance,
Fletcher
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try Using scope="prototype" if you do not want any object not to be singleton. It is same as singleton = "false"

If you want singleton="true", you do not need to do anything on the bean. The behavior is default.

The latest versions of Spring identify scope.

Hopefully this helps.


 
Fletcher Munson
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I just discovered that myself, but perhaps you could tell me the difference between using request and prototype?
 
ranger
Sheriff
Posts: 17314
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Fletcher Munson wrote:Thanks. I just discovered that myself, but perhaps you could tell me the difference between using request and prototype?



Request only works in the web environment, so a new object is created on each Web URL Request.

Prototype is everytime you call appContext.getObject(String name) you get a new object.

Mark
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!