Here is sample code of reading EPR from file and contructing object. The
code is from
http://viewcvs.globus.org/viewcvs.cgi/wsrf/java/core/source/src/org/globus/w
srf/client/BaseClient.java?revision=1.43&view=markup

in = new FileInputStream(line.getOptionValue("e"));
                this.endpoint =
                (EndpointReferenceType)ObjectDeserializer.deserialize(
                    new InputSource(in),
                    EndpointReferenceType.class);
 
You'll need to modify it to suit your scenario of multiple EPRs.

Rachana

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Carlos
> Sent: Monday, July 28, 2008 10:23 AM
> To: [email protected]
> Subject: [gt-user] Serialization and Deserialization
> 
> 
> Hi:
> 
> I'm developing a Grid Service in which some EPRs are Resource 
> Properties. So, I'm trying to get persistence saving them in 
> a file. Following the "Globus Toolkit 4: Programming Java 
> Service", I develop both store() and load() functions in the 
> Resource.java.
> 
> The store() is OK with the following Serialization:
> 
>                       FileOutputStream fos = null;
>                       File tmpFile = null;
>               
>                       // Statements associated with the EPR RP
>                       EndpointReferenceType[] EPRList = getEPR();
>                       String[] endpointString;
>                       String NS = 
> "http://org.merrill/namespaces/examples/Service";;
>                       QName RESOURCE_REFERENCE = new 
> QName(NS,"ResourceReference");
> 
>                         // Temporal file .temp creation
>                       tmpFile = File.createTempFile("file", 
> ".temp", getPersistenceHelper().getStorageDirectory());
>                       fos = new FileOutputStream(tmpFile);
>                       
>                       // RPs are written in the temporal file
>                       ObjectOutputStream oos = new 
> ObjectOutputStream(fos);
>                       //EPR needs to be serialized
>                       endpointString = new String[EPRList.length];
>                       for (int i = 0; i < EPRList.length; i++){
>                               endpointString[i] = 
> ObjectSerializer.toString(EPRList[i], RESOURCE_REFERENCE);    
>                       
>                       }
>                       oos.writeObject((String[]) 
> endpointString); //It is written as a String[]
>                       oos.close();
> 
> 
> 
> But I don't know how to retrieve the EPRs in the load() 
> function. I don't know how to use the ObjectSerializer or 
> ObjectDeserialize to get back the EPRs because I don't find 
> the reverse method. Can anybody help me?
> 
> thanks
> 
> Carlos
> _________________________________________________________________
> La Ășltima hora de tu ciudad en MSN Noticias
> http://noticias.es.msn.com/

Reply via email to