Win a copy of Spark in Action this week in the Open Source Projects forum!

stewchicken

Greenhorn
+ Follow
since May 31, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by stewchicken

below way could solve the problem

BindingProvider provider = (BindingProvider) port;
// You can set the address per request here
provider.getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
soapAddressURL);

6 years ago

Originally posted by Lisa Foster:
//contains locked records
private Vector r_lock = new Vector(); //Global declaration
public void lock(int record) throws IOException {
synchronized(r_lock)
{
while(r_lock.contains(new Integer(record)))
{
try
{
wait();
}
catch(InterruptedException e)
{
throw new IOException("lock failed");
}
}
r_lock.add(new Integer(record));
}

}
/**
* Unlock the requested record. Ignored if the caller does not have
* a current lock on the requested record.The record that was locked
* is removed from the Vector r_lock and all threads are notifyed.
*/
public void unlock(int record) {
synchronized(r_lock)
{
if(r_lock.contains(new Integer(record)))
{
r_lock.remove(new Integer(record));
}
r_lock.notifyAll();
}
}
Now My question is how to lock the whole database if -1??? and then how to unlock it
Thanks Lisa


i think should
use r_lock.wait()
and r_lock.notifyAll()
cos r_lock was synchorinized but not this.
on server side. by RMI i create and bind only one remoteDataFactoryimpl.it has a method eg create()--which will create Data object for every client which could
get that remoteDataFactoryImpl object by naming lookup.
so relation between client ,remoteDataFactoryImpl and Data object are multi --one--multi,
so we could allow multi client concurrently access database but only allow one client modify record.
but instruction(page 6/10) also requires that if lock method was called with -1,then entire database should be locked..i am confused on this. how to implement on this?
every client has their own Data object now. how to lock enire database for all clients?
belowing is my sample code of lock and unlcok. except lock(-1) funcation ..
static Vector recordContainer =new Vector();
public void lock(int recordnumber){
sychronized(recordContainer){
try{
if(recordContainer.contain(recordnumber))
recordContainer.wait();
else
recordContainer.add(recordnumber);
}catch(Exception e){}
}
}
public void unlock(int recordnumber){
sychronized(recordContainer){
recordContainer.remove(recordnumber);
try{
recordContainer.notifyAll();
}catch(Exception e){}
}
}
public sychronized modify(int recordnumber,DataInfo newData){
lock(recordnumber);
/*
here doing modifying record
*/
unlock(recordnumber);
}
thanks for your attention

Dear all,
1)
Did you put "add" and "delete" at your interface?
According to instruction , i only implement
search and bookflight two functions, but it said
Data client need implements all public method
in Data class.
GUI realize it's funcation through Data client,
so do you think i need put "add" and "delete"
2) instruction said "To connect with your server,
your should create a client program. This implementation
should include a class that implements the same public methods as suncertify.db.Data class,"
according to this.should i implements Data class
's modify, close, getRecord(),getRecordcount..all
public methods?
but i didnot see any sense of it
.
thanks for your attention
please give me some hints
regards