|
GigaSpaces XAP 7.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IPojoSpace
This interface represents the application view of a GigaSpace instance. It is implemented by all the Space Proxies (Embedded, Remote, Cluster and LocalCache).
When client receives a proxy to the space from the Lookup Service (see
SpaceFinder
, this proxy implements this interface, and therefore may
be casted to this interface if specific GigaSpaces methods (such as
count(Object, Transaction)
) are required.
The POJO UID generation and usage scenarios:
Scenario A: Adding a POJO to the Space using methods: write(), writeMultiple()
Space UID for POJO can be created in three different ways:
1. The POJO object that has no key property declared.
In that case, the ExternalEntry is created with empty UID. The space gets the
ExternalEntry which was created and inserts it into the space. The space then
generates UID for that ExternalEntry instance and writes it into the space.
2. The POJO has property which declared as a key - The converter takes the
value of that property and calls the method getUID( Object name) in
ClientUIDHandler class. That method returns a UID which is generated using
the property value. The UID is set to the ExternalEntry object.
3. The POJO has property which declared as a key and marked as auto generate - The
property must be from type java.lang.String. The ExternalEntry is created
with an empty UID. The space gets the ExternalEntry which was created and
inserts it into the space. The space then generates UID for that
ExternalEntry instance and writes it into the space. The generated UID then
been set into the POJO instance using �set� property method.
Scenario B: Fetching a POJO from the space using methods read(), readMultiple(),
readIfExists(), take(), takeMultiple(), takeIfExists() etc:
1. When the POJO has no key property declared, it then will be returned without any UID. It
means that only read() and write() operations can be executed on the POJO and
NOT an update().
2. When the POJO has a key property declared, it then will
be returned with the source value of the property but without the generated
UID. The POJO can not approach the UID which was generated by the space. 3.
The POJO has a property which declared as a key and auto generate - The space
returns the POJO with the generated UID into the property.
IJSpaceContainer
,
SpaceFinder
Method Summary | |
---|---|
void |
clear(Object template,
net.jini.core.transaction.Transaction transaction)
Removes the objects that match the specified template and the specified transaction from this space. |
int |
count(Object template,
net.jini.core.transaction.Transaction transaction)
Count any matching object from the space, visible under the specified transaction. |
int |
count(Object template,
net.jini.core.transaction.Transaction transaction,
int modifiers)
Count (according to the modifiers ) any matching object
from the space, visible under the specified transaction. |
IProxyAdmin |
getProxyAdmin()
Returns a proxy admin. |
IServerAdmin |
getServerAdmin()
Return a server admin. |
Object |
read(Object template,
net.jini.core.transaction.Transaction transaction,
long timeout)
Read any matching object from the space, blocking until one exists. |
Object |
read(Object template,
net.jini.core.transaction.Transaction transaction,
long timeout,
int modifiers)
Read (according to the modifiers ) any matching object from
the space, blocking until one exists. |
Object |
readIfExists(Object template,
net.jini.core.transaction.Transaction transaction,
long timeout)
Read any matching object from the space, returning null if there currently is none. |
Object |
readIfExists(Object template,
net.jini.core.transaction.Transaction transaction,
long timeout,
int modifiers)
Read (according to the modifiers ) any matching object from
the space, returning null if there currently is none. |
Object[] |
readMultiple(Object template,
net.jini.core.transaction.Transaction transaction,
int limit)
Read any matching objects from the space. |
Object[] |
readMultiple(Object template,
net.jini.core.transaction.Transaction transaction,
int limit,
int modifiers)
Read (according to the modifiers ) any matching objects
from the space. |
Object |
snapshot(Object object)
The process of serializing an entry for transmission to a JavaSpaces service will be identical if the same entry is used twice. |
Object |
take(Object template,
net.jini.core.transaction.Transaction transaction,
long timeout)
Take any matching entry from the space, blocking until one exists. |
Object |
takeIfExists(Object template,
net.jini.core.transaction.Transaction transaction,
long timeout)
Take any matching object from the space, returning null if there currently is none. |
Object[] |
takeMultiple(Object template,
net.jini.core.transaction.Transaction transaction,
int limit)
Takes all the entries matching the specified template from this space. |
Object[] |
takeMultiple(Object template,
net.jini.core.transaction.Transaction txn,
int limit,
int modifiers)
Takes all the entries matching the specified template from this space. |
Object |
update(Object updatedEntry,
net.jini.core.transaction.Transaction transaction,
long lease,
long timeout)
Equivalent to calling update(Object, Transaction, long, long, int) with
modifiers (if any) set by IProxyAdmin.setUpdateModifiers(int) . |
Object |
update(Object updatedEntry,
net.jini.core.transaction.Transaction transaction,
long lease,
long timeout,
int updateModifiers)
An update operation against a space entity which it's UID is known, blocking if locked under another transaction. |
Object[] |
updateMultiple(Object[] entries,
net.jini.core.transaction.Transaction transaction,
long[] leases)
Equivalent to calling updateMultiple(Object[], Transaction, long[], int) with
modifiers (if any) set by IProxyAdmin.setUpdateModifiers(int) . |
Object[] |
updateMultiple(Object[] objects,
net.jini.core.transaction.Transaction transaction,
long[] leases,
int updateModifiers)
Same as a single update but for a group of entities sharing the same transaction (if any), applied with the same operation modifier (or default com.j_spaces.core.client.UpdateModifiers#NONE ). |
LeaseContext |
write(Object object,
net.jini.core.transaction.Transaction transaction,
long lease)
Equivalent to calling write(Object, Transaction, long, long, int) with the
UpdateModifiers.UPDATE_OR_WRITE . |
LeaseContext |
write(Object object,
net.jini.core.transaction.Transaction transaction,
long lease,
long timeout,
int modifiers)
Writes a new object to the space, returning its Lease . |
LeaseContext[] |
writeMultiple(Object[] objects,
net.jini.core.transaction.Transaction transaction,
long lease)
Equivalent to calling #writeMultiple(Object[], Transaction, long, int) with modifier {@link com.j_spaces.core.client.UpdateModifiers#WRITE_ONLY}. |
LeaseContext[] |
writeMultiple(Object[] objects,
net.jini.core.transaction.Transaction transaction,
long lease,
int updateModifiers)
Same as a single write but for a group of entities sharing the same transaction (if any), applied with the same specified operation modifier. |
Method Detail |
---|
int count(Object template, net.jini.core.transaction.Transaction transaction) throws net.jini.core.entry.UnusableEntryException, net.jini.core.transaction.TransactionException, RemoteException
template
- The template used for matching. Matching is done against
template
with null
fields being
wildcards ("match anything") other fields being values ("match
exactly on the serialized form").transaction
- The transaction (if any) under which to work.
net.jini.core.entry.UnusableEntryException
- if any serialized field of the object being
read cannot be deserialized for any reason
net.jini.core.transaction.TransactionException
- if a transaction error occurs
RemoteException
- if a communication error occursint count(Object template, net.jini.core.transaction.Transaction transaction, int modifiers) throws net.jini.core.entry.UnusableEntryException, net.jini.core.transaction.TransactionException, RemoteException
modifiers
) any matching object
from the space, visible under the specified transaction.
Overloads count(Object, Transaction)
by adding a
modifiers parameter. Equivalent when called with the default
modifier - ReadModifiers.REPEATABLE_READ
. Modifiers are used
to define the behavior of a read operation.
template
- The template used for matching. Matching is done against
template
with null
fields being
wildcards ("match anything") other fields being values ("match
exactly on the serialized form").transaction
- The transaction (if any) under which to work.modifiers
- one or a union of ReadModifiers
.
net.jini.core.entry.UnusableEntryException
- if any serialized field of the object being
read cannot be deserialized for any reason
net.jini.core.transaction.TransactionException
- if a transaction error occurs
RemoteException
- if a communication error occursObject read(Object template, net.jini.core.transaction.Transaction transaction, long timeout) throws net.jini.core.entry.UnusableEntryException, net.jini.core.transaction.TransactionException, InterruptedException, RemoteException
Overloads JavaSpace.read(Entry, Transaction, long)
by replacing
the Entry template with Object, to support Plain
Old Java Object templates. Equivalent when called with an Entry cast to
Object.
template
- The template used for matching. Matching is done against
template
with null
fields being
wildcards ("match anything") other fields being values ("match
exactly on the serialized form").transaction
- The transaction (if any) under which to work.timeout
- How long the client is willing to wait for a
transactionally proper matching object. A timeout of
JavaSpace.NO_WAIT
means to wait no time at all; this is
equivalent to a wait of zero.
net.jini.core.entry.UnusableEntryException
- if any serialized field of the object being
read cannot be deserialized for any reason
net.jini.core.transaction.TransactionException
- if a transaction error occurs
InterruptedException
- if the thread in which the read occurs is
interrupted
RemoteException
- if a communication error occursJavaSpace.read(Entry, Transaction, long)
Object read(Object template, net.jini.core.transaction.Transaction transaction, long timeout, int modifiers) throws net.jini.core.entry.UnusableEntryException, net.jini.core.transaction.TransactionException, InterruptedException, RemoteException
modifiers
) any matching object from
the space, blocking until one exists. Return null if the
timeout expires.
Overloads read(Object, Transaction, long)
by adding a
modifiers parameter. Equivalent when called with the default
modifier - ReadModifiers.REPEATABLE_READ
. Modifiers are used
to define the behavior of a read operation.
template
- The template used for matching. Matching is done against
template
with null
fields being
wildcards ("match anything") other fields being values ("match
exactly on the serialized form").transaction
- The transaction (if any) under which to work.timeout
- How long the client is willing to wait for a
transactionally proper matching object. A timeout of
JavaSpace.NO_WAIT
means to wait no time at all; this is
equivalent to a wait of zero.modifiers
- one or a union of ReadModifiers
.
net.jini.core.entry.UnusableEntryException
- if any serialized field of the object being
read cannot be deserialized for any reason
net.jini.core.transaction.TransactionException
- if a transaction error occurs
InterruptedException
- if the thread in which the read occurs is
interrupted
RemoteException
- if a communication error occursread(Object, Transaction, long)
Object readIfExists(Object template, net.jini.core.transaction.Transaction transaction, long timeout) throws net.jini.core.entry.UnusableEntryException, net.jini.core.transaction.TransactionException, InterruptedException, RemoteException
Overloads JavaSpace.readIfExists(Entry, Transaction, long)
by
replacing the Entry template with Object, to
support Plain Old Java Object templates. Equivalent when called with an
Entry cast to Object.
template
- The template used for matching. Matching is done against
template
with null
fields being
wildcards ("match anything") other fields being values ("match
exactly on the serialized form").transaction
- The transaction (if any) under which to work.timeout
- How long the client is willing to wait for a
transactionally proper matching object. A timeout of
JavaSpace.NO_WAIT
means to wait no time at all; this is
equivalent to a wait of zero.
net.jini.core.entry.UnusableEntryException
- if any serialized field of the object being
read cannot be deserialized for any reason
net.jini.core.transaction.TransactionException
- if a transaction error occurs
InterruptedException
- if the thread in which the read occurs is
interrupted
RemoteException
- if a communication error occursJavaSpace.readIfExists(Entry, Transaction, long)
,
IJSpace.read(Entry, Transaction, long, int)
Object readIfExists(Object template, net.jini.core.transaction.Transaction transaction, long timeout, int modifiers) throws net.jini.core.entry.UnusableEntryException, net.jini.core.transaction.TransactionException, InterruptedException, RemoteException
modifiers
) any matching object from
the space, returning null if there currently is none. Matching
and timeouts are done as in read, except that blocking in this
call is done only if necessary to wait for transactional state to settle.
Overloads readIfExists(Object, Transaction, long)
by adding a
modifiers parameter. Equivalent when called with the default
modifier - ReadModifiers.REPEATABLE_READ
. Modifiers are used
to define the behavior of a read operation.
template
- The template used for matching. Matching is done against
template
with null
fields being
wildcards ("match anything") other fields being values ("match
exactly on the serialized form").transaction
- The transaction (if any) under which to work.timeout
- How long the client is willing to wait for a
transactionally proper matching object. A timeout of
JavaSpace.NO_WAIT
means to wait no time at all; this is
equivalent to a wait of zero.modifiers
- one or a union of ReadModifiers
.
net.jini.core.entry.UnusableEntryException
- if any serialized field of the object being
read cannot be deserialized for any reason
net.jini.core.transaction.TransactionException
- if a transaction error occurs
InterruptedException
- if the thread in which the read occurs is
interrupted
RemoteException
- if a communication error occursreadIfExists(Object, Transaction, long)
,
read(Object, Transaction, long, int)
Object[] readMultiple(Object template, net.jini.core.transaction.Transaction transaction, int limit) throws net.jini.core.transaction.TransactionException, net.jini.core.entry.UnusableEntryException, RemoteException
JavaSpace.NO_WAIT
). Returns an
array with matches bound by limit. Returns an
empty array if no match was found.
Overloads #readMultiple(Entry, Transaction, int)
by replacing
the Entry template with Object, to support Plain
Old Java Object templates. Equivalent when called with an Entry[] cast to
Object[].
template
- The template used for matching. Matching is done against
template
with null
fields being
wildcards ("match anything") other fields being values ("match
exactly on the serialized form").transaction
- The transaction (if any) under which to work.limit
- a limit on the number of objects to be returned. Use
Integer.MAX_VALUE
for the uppermost limit.
net.jini.core.entry.UnusableEntryException
- if any serialized field of the object being
read cannot be deserialized for any reason
net.jini.core.transaction.TransactionException
- if a transaction error occurs
RemoteException
- if a communication error occursIJSpace.readMultiple(Entry, Transaction, int)
Object[] readMultiple(Object template, net.jini.core.transaction.Transaction transaction, int limit, int modifiers) throws net.jini.core.transaction.TransactionException, net.jini.core.entry.UnusableEntryException, RemoteException
modifiers
) any matching objects
from the space. Matching is done as in read without timeout (JavaSpace.NO_WAIT
).
Returns an array with matches bound by limit.
Returns an empty array if no match was found.
Overloads readMultiple(Object, Transaction, int)
by adding a
modifiers parameter. Equivalent when called with the default
modifier - ReadModifiers.REPEATABLE_READ
. Modifiers are used
to define the behavior of a read operation.
template
- The template used for matching. Matching is done against
template
with null
fields being
wildcards ("match anything") other fields being values ("match
exactly on the serialized form").transaction
- The transaction (if any) under which to work.limit
- a limit on the number of objects to be returned. Use
Integer.MAX_VALUE
for the uppermost limit.modifiers
- one or a union of ReadModifiers
.
net.jini.core.entry.UnusableEntryException
- if any serialized field of the object being
read cannot be deserialized for any reason
net.jini.core.transaction.TransactionException
- if a transaction error occurs
RemoteException
- if a communication error occursreadMultiple(Object, Transaction, int)
Object update(Object updatedEntry, net.jini.core.transaction.Transaction transaction, long lease, long timeout) throws net.jini.core.transaction.TransactionException, net.jini.core.entry.UnusableEntryException, RemoteException, InterruptedException
update(Object, Transaction, long, long, int)
with
modifiers (if any) set by IProxyAdmin.setUpdateModifiers(int)
.
updatedEntry
- the new value of the entry, must contain the UID.transaction
- The transaction under which to perform the operation.lease
- The lease time of the updated entry, 0 means retain the original leasetimeout
- "IfExists" timeout
update(Object, Transaction, long, long, int)
according to
the set UpdateModifier
. (see IProxyAdmin.setUpdateModifiers(int)
net.jini.core.transaction.TransactionException
- if a transaction error occurs
net.jini.core.entry.UnusableEntryException
- if any serialized field of the entry being read cannot be deserialized for any reason
RemoteException
- if a communication error occurs
InterruptedException
- if the thread in which the read occurs is interrupted
IllegalArgumentException
- if the lease time requested
is not Lease.ANY and is negativeupdate(Object, Transaction, long, long, int)
,
UpdateModifiers
,
IProxyAdmin.setUpdateModifiers(int)
Object update(Object updatedEntry, net.jini.core.transaction.Transaction transaction, long lease, long timeout, int updateModifiers) throws net.jini.core.transaction.TransactionException, net.jini.core.entry.UnusableEntryException, RemoteException, InterruptedException
IMetaDataEntry
or having one of the UID access
methods:
public void __setEntryUID(String inUid)
public String __getEntryUID()
An update can be performed, with any of the modifiers listed in
UpdateModifiers
,
UpdateModifiers.UPDATE_ONLY
- pure update operation, UpdateModifiers.UPDATE_OR_WRITE
- writes if absent or updates
existing, UpdateModifiers.PARTIAL_UPDATE
- updates only non-null fields
Transactions:
An update lock guarantees that you are the sole holder of a space entity.
An update lock blocks all other requests for a read, take or update on
this particular entity. An update will be blocked until timeout expires,
returning a null result or until the lock has been released and acquired
by this call.
Optimistic Locking:
With optimistic locking set, an update operation has a chance of
failing (throwing EntryVersionConflictException
) if it was
performed on an obsolete copy. To enable Optimistic Locking with update,
set IProxyAdmin.setOptimisticLocking(boolean)
.
Sample code:
IJSpace aSpace = (IJSpace)SpaceFinder.find("jini://lookup-host/container-name/space-name")
;
Message msg = new Message("Hello");
Lease lease = aSpace.write(msg, null, Lease.FOREVER);
LeaseProxy
lp = (LeaseProxy)lease;
String uid = lp.getUID();
Message upde = new Message("Hello World");
upde.__setEntryUID(uid);
Object result = aSpace.update(upde, null, Lease.FOREVER, 60000, com.j_spaces.core.client.UpdateModifiers.UPDATE_OR_WRITE);
updatedEntry
- The new value of the entity, where matching is done by UID.transaction
- The transaction (if any) under which to work.lease
- The requested lease time of the updated entity, in milliseconds; 0 means retain the original lease.timeout
- How long the client is willing to wait for a transactionally proper matching entity.
A timeout of NO_WAIT means to wait no time at all; this is equivalent to a wait of zero.updateModifiers
- operation modifiers, values from UpdateModifiers
null
- if timeout occurred after waiting for a transactional proper matching entry.
UpdateModifiers.UPDATE_OR_WRITE
modifier is applied,
null
- if write was successful,
EntryNotInSpaceException
- if an entry with such a UID doesn't exits in the space
OperationTimeoutException
- if timeout expires (when used with
UpdateModifiers.UPDATE_OR_WRITE
modifier)
net.jini.core.transaction.TransactionException
- if a transaction error occurs
net.jini.core.entry.UnusableEntryException
- if any serialized field of the entry being read cannot be deserialized for any reason
or EntryNotInSpaceException
is throw when the UId is not exists in the space
RemoteException
- if a communication error occurs
InterruptedException
- if the thread in which the read occurs is interrupted
IllegalArgumentException
- if the lease time requested
is not Lease.ANY and is negativeUpdateModifiers
,
IMetaDataEntry
Object[] updateMultiple(Object[] entries, net.jini.core.transaction.Transaction transaction, long[] leases) throws net.jini.core.entry.UnusableEntryException, net.jini.core.transaction.TransactionException, RemoteException
updateMultiple(Object[], Transaction, long[], int)
with
modifiers (if any) set by IProxyAdmin.setUpdateModifiers(int)
.
entries
- the array of entries containing the new values , each entry
must contain its UID.transaction
- The transaction under which to perform the operation.leases
- The lease time of the updated entries, 0 means retain the
original lease
updateMultiple(Object[], Transaction, long[], int)
according to
the set UpdateModifiers
. (see IProxyAdmin.setUpdateModifiers(int)
net.jini.core.transaction.TransactionException
- if a transaction error occurs
net.jini.core.entry.UnusableEntryException
- if any serialized field of the entry being
read cannot be deserialized for any reason
RemoteException
- if a communication error occursObject snapshot(Object object) throws RemoteException
object
- the object to take a snapshot of.
RemoteException
- - if a communication error occursObject[] takeMultiple(Object template, net.jini.core.transaction.Transaction transaction, int limit) throws net.jini.core.transaction.TransactionException, net.jini.core.entry.UnusableEntryException, RemoteException
IJSpace aSpace = (IJSpace)SpaceFinder.find("jini://lookup-host/container-name/space-name")
;
Object
multiTmpl = new Message();
Object[] results = aSpace.takeMultiple( multiTmpl, null, Integer.MAX_VALUE );
for (int i=0; i<results.length; i++)
{
System.out.println("Taken-Multiple: "+((Message)results[i]).content);
}
template
- the template to use for matching.transaction
- the transaction under which to perform the operation.limit
- a limit on the number of entries to be taken. Use
Integer.MAX_VALUE
for the maximum value.
net.jini.core.transaction.TransactionException
- if a transaction error occurs
net.jini.core.entry.UnusableEntryException
- if any serialized field of the entry being read cannot be deserialized for any reason
RemoteException
- if a communication error occursObject[] takeMultiple(Object template, net.jini.core.transaction.Transaction txn, int limit, int modifiers) throws net.jini.core.transaction.TransactionException, net.jini.core.entry.UnusableEntryException, RemoteException
IJSpace aSpace = (IJSpace)SpaceFinder.find("jini://lookup-host/container-name/space-name")
;
Object
multiTmpl = new Message();
Object[] results = aSpace.takeMultiple( multiTmpl, null, Integer.MAX_VALUE );
for (int i=0; i<results.length; i++)
{
System.out.println("Taken-Multiple: "+((Message)results[i]).content);
}
template
- the template to use for matching.txn
- the transaction under which to perform the operation.limit
- a limit on the number of entries to be taken. Use
Integer.MAX_VALUE
for the maximum value.modifiers
- one of [ReadModifiers.THROW_PARTIAL_FAILURE
, ReadModifiers.REPEATABLE_READ
]
net.jini.core.transaction.TransactionException
- if a transaction error occurs
net.jini.core.entry.UnusableEntryException
- if any serialized field of the entry being read cannot be deserialized for any reason
RemoteException
- if a communication error occursObject take(Object template, net.jini.core.transaction.Transaction transaction, long timeout) throws net.jini.core.entry.UnusableEntryException, net.jini.core.transaction.TransactionException, InterruptedException, RemoteException
template
- The template used for matching. Matching is done against
template with null fields being wildcards ("match anything") other
fields being values ("match exactly on the serialized form").transaction
- The template used for matching. Matching is done
against template with null fields being wildcards ("match
anything") other fields being values ("match exactly on the
serialized form").timeout
- How long the client is willing to wait for a
transactionally proper matching entry. A timeout of NO_WAIT
means to wait no time at all; this is equivalent to a wait of
zero.
net.jini.core.entry.UnusableEntryException
- - if any serialized field of the entry
being read cannot be deserialized for any reason
TransactionException - if a transaction error occurs
InterruptedException - if the thread in which the read occurs
is interrupted RemoteException - if a communication error
occurs IllegalArgumentException - if a negative timeout value
is used
net.jini.core.transaction.TransactionException
InterruptedException
RemoteException
Object takeIfExists(Object template, net.jini.core.transaction.Transaction transaction, long timeout) throws net.jini.core.entry.UnusableEntryException, net.jini.core.transaction.TransactionException, InterruptedException, RemoteException
Overloads JavaSpace.takeIfExists(Entry, Transaction, long)
by
replacing the Entry template with Object, to
support Plain Old Java Object templates. Equivalent when called with an
Entry cast to Object.
template
- The template used for matching. Matching is done against
template
with null
fields being
wildcards ("match anything") other fields being values ("match
exactly on the serialized form").transaction
- The transaction (if any) under which to work.timeout
- How long the client is willing to wait for a
transactionally proper matching object. A timeout of
JavaSpace.NO_WAIT
means to wait no time at all; this is
equivalent to a wait of zero.
net.jini.core.entry.UnusableEntryException
- if any serialized field of the object being
read cannot be deserialized for any reason
net.jini.core.transaction.TransactionException
- if a transaction error occurs
InterruptedException
- if the thread in which the read occurs is
interrupted
RemoteException
- if a communication error occursJavaSpace.takeIfExists(Entry, Transaction, long)
,
take(Object, Transaction, long)
void clear(Object template, net.jini.core.transaction.Transaction transaction) throws RemoteException, net.jini.core.transaction.TransactionException, net.jini.core.entry.UnusableEntryException
IJSpace aSpace = (IJSpace)
If the clear operation conducted without transaction (null as value) it will clear all entries that are not under transaction. Therefor entries under transaction would not be removed from the space. The clear operation supports inheritance, therefore template class matching objects and its sub classes matching objects are part of the candidates population that will be from the space. You can in fact clean all space objects (that are not under transaction) by calling:SpaceFinder.find("jini://lookup-host/container-name/space-name")
; Object multiTmpl = new Message(); aSpace.clear(multiTmpl, null);space.clear( null, null)
. Notice: The clear operation does not remove notify templates i.e. registration for notifications.
template
- the template to use for matching.transaction
- the transaction under which to perform the operation.
net.jini.core.transaction.TransactionException
- if a transaction error occurs
net.jini.core.entry.UnusableEntryException
- if any serialized field of the entry being read cannot be de serialized for any reason
RemoteException
- if a communication error occursIServerAdmin.clean()
LeaseContext[] writeMultiple(Object[] objects, net.jini.core.transaction.Transaction transaction, long lease, int updateModifiers) throws net.jini.core.transaction.TransactionException, RemoteException
IJSpace aSpace = (IJSpace)SpaceFinder.find("jini://lookup-host/container-name/space-name")
;
Object
[] objects = new Object[100];
for (int i=0; i<objects.length; i++)
{
objects[i] = new Message("Hello World -"+i);
}
aSpace.writeMultiple( objects, null, Lease.FOREVER, UpdateModifiers.UPDATE_OR_WRITE );
objects
- the objects to write.transaction
- the transaction object, if any, under which to perform the writelease
- the requested lease time, in millisecondsupdateModifiers
- operation modifiers, values from UpdateModifiers
Lease
on a successful write, or null
if performed with NoWriteLease attribute.
when UpdateModifiers.UPDATE_OR_WRITE
modifier is applied,
LeaseContext.getObject()
returns:
net.jini.core.transaction.TransactionException
- if a transaction error occurs
RemoteException
- is never thrown for backward only
IllegalArgumentException
- if the lease time requested
is not Lease.ANY and is negative, the entries array is empty or null.
InterruptedException
- if the thread in which the write occurs is interrupted
WriteMultiplePartialFailureException
- that point out which entries failed and what is the cause,
relevant in case of partial failure (can contains runtime and typed exceptions)LeaseContext[] writeMultiple(Object[] objects, net.jini.core.transaction.Transaction transaction, long lease) throws net.jini.core.transaction.TransactionException, RemoteException
objects
- the objects to write.transaction
- the transaction object, if any, under which to perform the writelease
- the requested lease time, in milliseconds
Lease
on a successful write, or null
if performed with NoWriteLease attribute.
net.jini.core.transaction.TransactionException
- if a transaction error occurs
RemoteException
- is never thrown for backward only
IllegalArgumentException
- if the lease time requested
is not Lease.ANY and is negative, the entries array is empty or null.
InterruptedException
- if the thread in which the write occurs is interrupted
WriteMultiplePartialFailureException
- that point out which entries failed and what is the cause,
relevant in case of partial failure (can contains runtime and typed exceptions)LeaseContext write(Object object, net.jini.core.transaction.Transaction transaction, long lease) throws net.jini.core.transaction.TransactionException, RemoteException
write(Object, Transaction, long, long, int)
with the
UpdateModifiers.UPDATE_OR_WRITE
.
object
- the object to writetransaction
- the transaction object, if any, under which to perform
the writelease
- the requested lease time, in milliseconds
Lease
on a successful write, or null
if performed with NoWriteLease attribute.
when UpdateModifiers.UPDATE_OR_WRITE
modifier is applied,
LeaseContext.getObject()
returns:
EntryAlreadyInSpaceException
- if an entry with the same UID already exists in space (Modifiers.WRITE
)
EntryNotInSpaceException
- if an entry with such a UID doesn't exits in the space (Modifiers.UPDATE
)
net.jini.core.transaction.TransactionException
- if a transaction error occurs
RemoteException
- if a communication error occursLeaseContext write(Object object, net.jini.core.transaction.Transaction transaction, long lease, long timeout, int modifiers) throws net.jini.core.transaction.TransactionException, RemoteException
Lease
.
Applying the UpdateModifiers.UPDATE_OR_WRITE
modifier, is
equivalent to calling
update(Object, Transaction, long, long, int)
, but otherwise
returning a Lease on a successful write.
If the object has a primary key,isn't auto - generated, and the modifiers value is one of
UpdateModifiers.UPDATE_OR_WRITE
,UpdateModifiers.UPDATE_ONLY
or
UpdateModifiers.PARTIAL_UPDATE
, it will call to the update method, returning a
LeaseContext holder. This lease is unknown to the granter, unless an actual 'write' was performed.
The operation can also be forced to perform write operation using the
UpdateModifiers.WRITE_ONLY
resulting in an
EntryAlreadyInSpaceException
exception if the object
already exists in the space.
transaction
- the transaction object, if any, under which to perform the writeobject
- the object to writelease
- the requested lease time, in millisecondstimeout
- modifiers
-
Lease
on a successful write, or null
if performed with NoWriteLease attribute.
when UpdateModifiers.UPDATE_OR_WRITE
modifier is applied,
LeaseContext.getObject()
returns:
EntryAlreadyInSpaceException
- if an entry with the same UID already exists in space (Modifiers.WRITE
)
EntryNotInSpaceException
- if an entry with such a UID doesn't exits in the space (Modifiers.UPDATE
)
OperationTimeoutException
- if timeout expires (when used
with UpdateModifiers.UPDATE_OR_WRITE
modifier)
net.jini.core.transaction.TransactionException
- if a transaction error occurs
RemoteException
- if a communication error occursObject[] updateMultiple(Object[] objects, net.jini.core.transaction.Transaction transaction, long[] leases, int updateModifiers) throws net.jini.core.entry.UnusableEntryException, net.jini.core.transaction.TransactionException, RemoteException
com.j_spaces.core.client.UpdateModifiers#NONE
).
The semantics of a single update and a batch update are similar - the return
value for each corresponds to it's cell in the returned array.
see 'returns'
for possible return values.
IJSpace aSpace = (IJSpace)SpaceFinder.find("jini://lookup-host/container-name/space-name")
;
Lease[] leases = ...//see writeMultiple
Object[] results = aSpace.readMultiple( multiTmpl, null, Integer.MAX_VALUE );
for (int i=0; i<results.length; i++)
{
// modify entry Object by adding an index to the content
((Message)results[i]).content += i;
}
// updates the space with the modified entries
Object[] results = aSpace.updateMultiple(results, null, leases);
objects
- the array of objects containing the new values,
each entry must contain its UID.transaction
- The transaction under which to perform the operation.leases
- The lease time of the updated objects, 0 means retain the original leaseupdateModifiers
- operation modifiers, values from UpdateModifiers
null
- if timeout occurred after waiting for a transactional proper matching entry
UpdateModifiers.UPDATE_OR_WRITE
modifier is applied,
null
- if write was successful,
net.jini.core.transaction.TransactionException
- if a transaction error occurs
net.jini.core.entry.UnusableEntryException
- if any serialized field of the entry being read cannot be deserialized for any reason
RemoteException
- if a communication error occursIProxyAdmin getProxyAdmin()
IServerAdmin getServerAdmin()
|
GigaSpaces XAP 7.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |