org.coffeecrew.mobile.oop.impl
Class BulkObjectPusher
java.lang.Object
org.coffeecrew.mobile.oop.util.Observable
org.coffeecrew.mobile.oop.impl.BulkObjectPusher
- All Implemented Interfaces:
- java.lang.Runnable, Observer
public class BulkObjectPusher
- extends Observable
- implements Observer, java.lang.Runnable
This class implements a mechanism to send multiple objects
that are stored in a java.util.Vector
to safely
transfer them to a remote device. All the threading issues are
covert within this class. You can also use ObjectPusher
to transfer
multiple objects to a remote device but then you have to synchronize the threads
on your own.
BulkObjectPusher
usage is like follows:
// create your objects
Person p = new Person();
p.setName("Schneider");
p.setVorname("Rosemarie");
p.setAge(37);
Person hans = new Person();
hans.setName("Peter");
hans.setVorname("Hans");
hans.setAge(37);
//staff them into a vector
Vector transferringObjects = new Vector();
transferringObjects.addElement(p);
transferringObjects.addElement(hans);
//happy pushing
new BulkObjectPusher(transferringObjects).addObserver(this);
- Since:
- 0.1
- See Also:
ObjectPusher
,
ObjectReceiver
Constructor Summary |
BulkObjectPusher(java.util.Vector objectsToTransfer)
Creates a new instance of BulkObjectPusher which then sends the given
java.util.Vector of objects to the remote device where an
instance of ObjectReceiver is running. |
Method Summary |
void |
run()
The actual working method |
void |
update(Observable observable,
java.lang.Object arg)
This method causes this thread to send the next object by notifying
the run method that the object in transfer has been sent. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BulkObjectPusher
public BulkObjectPusher(java.util.Vector objectsToTransfer)
- Creates a new instance of BulkObjectPusher which then sends the given
java.util.Vector
of objects to the remote device where an
instance of ObjectReceiver
is running.
- Parameters:
objectsToTransfer
- The objects encapsulated in a java.util.Vector
that should be
transferred to the remote device.
run
public void run()
- The actual working method
- Specified by:
run
in interface java.lang.Runnable
update
public void update(Observable observable,
java.lang.Object arg)
- This method causes this thread to send the next object by notifying
the run method that the object in transfer has been sent.
- Specified by:
update
in interface Observer
- Parameters:
observable
- The observable which notified the changearg
- Argument to transfer additional information from the observable to the
Observer