Good points that you make!!

I think that basically the Domain initialization was quickly written near
the beginning of the project, and since it more or less works well, as not
been treated since. At some point someone added the EmbeddedDomain class,
whose purpose I must admit completely escapes me. 'Remy Maucherat' is the
original author of both classes, but I have not heard from him on this list
in a while.

The Domain concept is really a bit incomplete, and has some major bugs...
Luckily, a normal installation of slide never triggers them.

Domain problems:

Initialization: 
* The way the domain is initialized and most of the methods in it are
written, it is quite possible for some code to call methods on the domain
before it is initialized, and receive incorrect results.
* Synchronization, as you point out, is a problem. A domain could
conceivably be initialized twice.
* The EmbeddedDomain is confusing, and unneccessary if you ask me. What is
it for? I never received an answer to this question.

Static Nature:
* Having the Domain class be static is a simple solution to the 'service
location' problem. However, I think making the entire functionality of the
domain static was a mistake, and leads to problems. A mechanism like that of
java.lang.Runtime (java.lang.Runtime.getRuntime() is a static method that
returns the instantiated Runtime object) would have been better.
* Alternatively, one could use Factory Classes to create / retrieve the
Domain, or JNDI.
* The current solution allows only one domain. While this seems ok to me
(after all, the domain is the container for namespaces, and you can have
many namespaces), it would prevent a solution that needed multiple domains
for some reason.

To fix all this, I would propose the following:

* Drop EmbeddedDomain altogether, unless someone can finally tell me what it
is for.
* Make everything that is static in Domain non-static
* Add the following new methods to Domain:
       static Domain getDomain(SecurityToken token);                       
          // get the default domain, initialize if not found
       static Domain getDomain(SecurityToken token,String name);            
          // get the named domain, return null if not found
         static void initDomain(SecurityToken token,String name,File conf); 
          // initialize a new domain using the given name, from the given
conf.
The new model would keep a static Hashtable of domains in the Domain class,
normally only the default domain, which is sensibly associated with the name
'default'. Accessing the default domain initializes it from the default
configuration file path, if it is not already initialized. Accessing other
domains is only possible if they have been explicitly initialized.
Synchronization for all this would be easy to add.

Changes would be local to domain, and the few classes that used it directly
(SlideServerListener, WebdavServlet).

There is also the DomainAccessToken and the accessDomain() method, which are
not really used at the moment, but had the same purpose, I think, as what I
propose.

Richie







> -----Urspr�ngliche Nachricht-----
> Von: Martin Holz [mailto:holz@;fiz-chemie.de]
> Gesendet: Mittwoch, 13. November 2002 15:10
> An: 'Slide Developers Mailing List'
> Betreff: EmbeddedDomain initialization
> 
> 
> Hi,
> 
> why does Domain.setDomain not check, if the Domain is already 
> initialized?
> And why are the Domain initialization methods not synchronized? 
> 
> Regards
>       Martn
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:slide-dev-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:slide-dev-help@;jakarta.apache.org>
> 

--
To unsubscribe, e-mail:   <mailto:slide-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:slide-dev-help@;jakarta.apache.org>

Reply via email to