|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Serializing Components
I am giving a presentation on components tonight and I have a quickDan Vega 11/13/08 09:38 A I am giving a presentation on components tonight and I have a quick question. I understand that the following code will serialize / deserialize my component. Takes it and wraps up into a nice binary format (very compact) and then at a later time I can unpack it. My question is outside of moving info across clusters can anyone give me an example of where you would actually use this? I have never had the need to use it so I would love to hear from those who have! Thanks... <cfset person = CreateObject("component", "Person")> <cfset person.setFirstName("Dan")> <cfset person.setLastName("Vega")> <cfset fileOut = CreateObject("Java", "java.io.FileOutputStream")> <cfset fileOut.init(ExpandPath("serialized_cfc.txt"))> <cfset objOut = CreateObject("Java", "java.io.ObjectOutputStream")> <cfset objOut.init(fileOut)> <cfset objOut.writeObject(person)> <cfset objOut.close()> <!--- <cfset fileIn = CreateObject("java", "java.io.FileInputStream")> <cfset fileIn.init(ExpandPath("serialized_cfc.txt"))> <cfset objIn = CreateObject("java", "java.io.ObjectInputStream")> <cfset objIn.init(fileIn)> <cfset newCFCInstance = objIn.readObject()> <cfset objIn.close()> <cfoutput>#newCFCInstance.getFullName()#</cfoutput> ---> Thank You Dan Vega danvega@gmail.com http://www.danvega.org I guess maybe if you had an application where you wanted to actually cache objects in Client scope. Client scope can only take simple vars, so this would allow that ... potentially?
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||