Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Spring - singleton attribute not available when using namespace

 
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
Posts: 17344
11
Mac IntelliJ IDE 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
 
We don't have time for this. We've gotta save the moon! Or check this out:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!