Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

using JAXB how to bind the static fields or property.

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so, basically I have a xml which I want to umarshall using JAXB.
If I dont include the static fields or property I am able to set . I went through documentation where it was stated that static fields or static property cannot be binded using JAXB.

The reason Im focused on static is that I would be setting those data at runtime and will use across the application.(serve all the clients)

XML :





JAVA:





Please let me know your thoughts on how to set the static Map

Its works fine without static..
 
Marshal
Posts: 27211
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, so you need to save and restore static members of a class. It still doesn't make sense to do that by serializing an object of that class, which is what JAXB does.

However all serialization tools are designed to serialize objects, so you will find that none of them will handle static members. You're going to have to look elsewhere.

Or perhaps you could review your design. Why do you need static data? And why do you need to marshal and unmarshal it?
 
dileep keely
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got your point
I want to load all the xml data and its attributes at runtime and be utilized across the application..so thats the reason for static.... I will use SAX parser and and populate those objects into a static map thats the way I would think of..
 
Paul Clapham
Marshal
Posts: 27211
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But that isn't a reason for using static variables. Create a class whose attributes (not static) are the things you want to share across the application. Then when the application starts, create an instance of that class from your XML and store that instance in application scope. You aren't forced to use static variables to do that.
 
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic