• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling Helper class static methods from Struts action class.

 
Ranch Hand
Posts: 37
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Iam calling a Helper class with all static methods from struts action class. My question is, if multiple requests are coming to action , the static methods in Helper holds other request's data.so is it correct to using static methods across multiple requests.
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramu,

You can use static methods when you want to use it as utility method.

In short, Don't assign/change value of any static class variables to make it thread safe.

Your static methods would be safe.
--Niraj
 
Ramu Valivarthi
Ranch Hand
Posts: 37
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Niraj Thanks for prompt response,

In my case the data will get changed for each request ,the flow is something like Action <--> Helper (static) <--> ServiceImpl <--> MilldeTier (Jboss EJB)<--> DAO
I just wanted to know , whether static methods will cause any issue ?
 
Niiraj Patel
Ranch Hand
Posts: 47
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
howdly ramu,
please have a look at this thread ..
http://stackoverflow.com/questions/5173399/are-non-synchronised-static-methods-thread-safe-if-they-dont-modify-static-class

Thanks,
niraj
 
Ramu Valivarthi
Ranch Hand
Posts: 37
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Niraj
Its cleared..Iam safe now as my static methods are thread safe.



Ramu V.
reply
    Bookmark Topic Watch Topic
  • New Topic