You must control concurrency on your own. You might use a simple
synchronized method which encapsulates all access to xml documents and
provide it with a perform object which does your processing.

private synchronized entryPoint(XMLObj o, Performer p) {
  p.execute(o);
}

Performer is a simple interface

public interface Performer {
  public void execute(XMLObj o);
}

Then you can use anonymous inner implementations of Performer in your
methods. Suppose you had a methodX in your initial design. Rename it to
doMethodX and make it private then have a new methodX like ("Outer" is
the name of the class methodX is defined in). Such a performer can be
arbitrarly complex and because it is an inner class has access to it's
outer parent.

methodX() {
  Performer p = new Performer() {
    public void execute(XMLObj o) {Outer.this.doMethodX(o);}
  };
  entryPoint(o, p);
}

This approach has the drawback that careless of the document you can
process only one at a time. So you have a situation like the "single-
thread" model off jsp: strict serialization of processing
You can have finer grained concurrency control by introducing not
synchronized methods but synchronized blocks. Create for each xml
dokument a simple lock object (simply: Object o = new Object()), store
associaton with xml dokument in synchronized map (syncmap.put
(xml.title, o)), whenever you access any of your xml use

Object o = syncmap.get(xml.title);
synchronized(o) {
   /*begin access here*/
}

For more concurrency issues look at Doug Leas website

Peter
----- Original Message -----
From: Alberto Imedio <[EMAIL PROTECTED]>
Date: Thursday, October 4, 2001 11:24 am
Subject: Re: Servlet accessing XML Document (PROBLEM WITH CONCURRENCY)

> I did not find any solution. The concurrence is not controlled :-(.
>
> TX

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to