webservice - Web server administration

Download Report

Transcript webservice - Web server administration

Web Service
Comp6231
© Qingzhe Huang
What is the fundamental
difference between web service
and CORBA
If we don’t care about the theoretical aspect
like RPC mechanism, implementation detail
of across platform etc. the biggest difference
at server side is “single instance” vs.
“multiple instance”.
What is it?
The web service generates a new servlet for
each incoming request and in CORBA since
we inherit from “UnicastRemoteObject” we
have only one server instance. And this
makes a big difference in synchronization
issues.
What becomes invalid in web
service?
First the in-memory customer list must be
static. Otherwise every servlet will be
accessing its own customer list.
Second, you must be careful in constructor
because it will be executed again and again.
For example, you may need a static flag to
make sure your initialization procedure is
executed only once.
What becomes invalid in web
service? Continued.
For those who has make synchronized at
level of “server implementation class”, this
would not work since servlet or
“implementation class instance will be
multiple. And the “synchronized” only work
for same instance.
What becomes invalid in web
service? Continued.
However, for those who implemented his
synchronized at level of “customer” or
“Account” level, he doesn’t have to modify
his code because in java every object you
retrieve from customer list is the same object
reference. So, the multiple access of same
object or customer or Account will still be
“synchronized”.
What if you implement your
synchronization by using
“Semaphore”?
It depends. If you use semaphore at level of
“implementation class”, then you have to
make your Semaphore static so that different
instance of “implementation class” is sharing
the semaphore.
If you use semaphore at level of customer,
then you don’t have to make any change.
How about OpenAccount?
As I have explained in my blog, it is possible
that two OpenAccount threads may generate
same new Account number if your “Random”
is not declared as static. And the disaster is
one customer may lose his balance.
So, either synchronize “OpenAccount” with
customer Account checking or use a static
Random. (Still I am not sure about this
choice.)
How to configure Tomcat?
My only experience is to follow the batch file
“setclasspath.bat” to see what environment
variable it may require.