com.j_spaces.core.client
Class EntryInfo

java.lang.Object
  extended by com.j_spaces.core.client.EntryInfo

public final class EntryInfo
extends Object

This Object contains entry information like its UID and Version ID. You can use this class to assign entry UID when created and read entry using its ID. GigaSpaces will update this object when reading and updating the entry. See below example:


 import net.jini.core.lease.Lease;
 import net.jini.space.JavaSpace;
 import com.j_spaces.core.IJSpace;
 import com.j_spaces.core.LeaseProxy;
 import com.j_spaces.core.client.EntryInfo;
 import com.j_spaces.core.client.SpaceFinder;
 import com.j_spaces.core.client.ClientUIDHandler ;

 public class MyEntry
                extends com.j_spaces.core.client.MetaDataEntry
 {
        public String myData;

        public MyEntry()
  {
        }

        public MyEntry(String data)
  {
                this.myData = data;
        }

        public String toString()
        {
   return myData;
  }

        public static void main(String[] args)
  {
                try
      {
                        IJSpace space = (IJSpace) SpaceFinder.find(args[0]);
                        space.clean();
                        //              Setting Entry UID
                        MyEntry myentry = new MyEntry("Data");

                        // ClientUIDHandler allows you to generate Valid UID Entry
                        // you must make sure you provide unique name!
                        String uid1 = ClientUIDHandler.createUIDFromName("MyEntryUID" ,MyEntry.class.getName() );

                        EntryInfo ei1 = new EntryInfo(uid1 , 0);
                        myentry.__setEntryInfo(ei1);
                        //               Write entry to space
                        Lease l = space.write(myentry, null, Lease.FOREVER);
                        LeaseProxy lp =(LeaseProxy)l;
                        System.out.println("Wrote Object with UID:" + lp.getUID());

                        //              Reading Entry using its UID
                        MyEntry template = new MyEntry();

                        String uid2 =  ClientUIDHandler.createUIDFromName("MyEntryUID" ,MyEntry.class.getName() );
                        EntryInfo ei2 = new EntryInfo(uid2 , 0);
                        template.__setEntryInfo(ei2);
                        MyEntry m = (MyEntry) space.read(template, null, JavaSpace.NO_WAIT);
                        System.out.println("Read Object with UID:" + m.__getEntryInfo().m_UID + " Data:" + m.myData);
                } catch (Exception e)
       {
                        e.printStackTrace();
                 }
        }
 }

 

For more detailed information about MetaDataEntry class usage see: Optimistic locking actions

See Also:
ClientUIDHandler, MetaDataEntry

Field Summary
 long m_TimeToLive
          output-only, time (in milliseconds) left for this entry to live (correct for the time the operation- read,take under xtn, update, ... was performed)
 String m_UID
          Unique ID of the entry.
 int m_VersionID
          Version ID, initially each entry is written with versionID of 1 and it is incremented in each update.
 
Constructor Summary
EntryInfo(String UID, int versionID)
          Constructor.
EntryInfo(String UID, int versionID, long timeToLive)
          Constructor - for internal use only.
 
Method Summary
 String toString()
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_UID

public String m_UID
Unique ID of the entry.


m_VersionID

public int m_VersionID
Version ID, initially each entry is written with versionID of 1 and it is incremented in each update. VesrionID is used in optimistic locking.


m_TimeToLive

public long m_TimeToLive
output-only, time (in milliseconds) left for this entry to live (correct for the time the operation- read,take under xtn, update, ... was performed)

Constructor Detail

EntryInfo

public EntryInfo(String UID,
                 int versionID)
Constructor.

Parameters:
UID - unique ID of the entry
versionID - entry version (used in optimistic locking)

EntryInfo

public EntryInfo(String UID,
                 int versionID,
                 long timeToLive)
Constructor - for internal use only.

Parameters:
UID - entry unique ID of the entry
versionID - entry version (used in optimistic locking)
timeToLive - time for this entry to live
Method Detail

toString

public String toString()

Overrides:
toString in class Object