|
GigaSpaces XAP 7.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.j_spaces.core.client.EntryInfo
public final class EntryInfo
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
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 | |
---|---|
long |
getTimeToLive()
|
String |
getUID()
|
int |
getVersionID()
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public String m_UID
public int m_VersionID
public long m_TimeToLive
Constructor Detail |
---|
public EntryInfo(String UID, int versionID)
UID
- unique ID of the entryversionID
- entry version (used in optimistic locking)public EntryInfo(String UID, int versionID, long timeToLive)
UID
- entry unique ID of the entryversionID
- entry version (used in optimistic locking)timeToLive
- time for this entry to liveMethod Detail |
---|
public String toString()
toString
in class Object
public String getUID()
public int getVersionID()
public long getTimeToLive()
|
GigaSpaces XAP 7.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |