I have a class JAXBReader
which hold unmarshalled xml file using the jaxb generated classes. I have used the singleton design so that I need not unmarshall the file again and again. The object of this class (precisely the unmarshalled xml) is needed only to initialize an enum having eight constants. The constructor of enum constants use the singleton object to get their required part of the xml.
After the enum is initialized, I don't need the objetc of JAXBReader
in my system. How can I achieve this?
I read here that I can call a setter to assign null to the static singelton instance but I don't want to do it externally. I want that, the instance is assigned null automatically after the enum is initialized.
I am using Java 1.7