• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Spring Remoting (HttpInvoker) and problem with bean creation (scope)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a service that's exposed by HttpInvoker (org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter) and a test class with some tests.
applicationContext.xml


logRequisicao-servlet.xml


applicationContext-client.xml


TestClass


The problem is that my class (LoggerRequisicao) isn't thread-safe, so i can't have only one instance shared for all remote invocations. That's where my problems have started. I spent a good time looking for something about and i know i can define another scope for the bean different than singleton, which is the default. I tried different ways:

1)
applicationContext.xml


logRequisicao-servlet.xml


Result: Just one instance is created. It's the same behavior when i hadn't defined the bean logRequisicaoService scope as prototype.

2)
applicationContext.xml


logRequisicao-servlet.xml

Result: One instance is created for each method call. For example:

3 or 4 instances would be created.

What i really need is that 1 instance was created by each getBean called. In the Test Class, 1 instance per test. I really researched about it and tested different ways, but i couldn't be able to make it works.

Does somebody have any idea of how to solve that problem?


Thank you veru much.
Luciano

Ps.: Sorry for the english
reply
    Bookmark Topic Watch Topic
  • New Topic