axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Glen Daniels" <gdani...@allaire.com>
Subject Proxy pattern
Date Fri, 16 Feb 2001 14:19:20 GMT
Jacek asked me to post my thoughts on this, so here we go.

If you have a SupplierHandler, which does this:

public class SupplierHandler implements Handler {
    Supplier _supplier;
    ...
    public void init() { _supplier.getHandler().init(); }
    public void invoke(MesssageContext msgContext) {
        _supplier.getHandler().invoke(msgContext);
    }
    ...
}

You end up calling potentially different Handler objects on the init() call
and the invoke() call in the case that the Supplier happens to be, say, a
Factory.  If you try to solve the problem thusly:

    Handler _myHandler = null;
    ...
    public void init() {
        if (_myHandler == null)
            _myHandler = _supplier.getHandler();
        _myHandler.init();
    }
    ...etc...

You now have the SupplierHandler in the registry tied to a single Handler
instance, which isn't what you want either (since now you lose the
creational dynamics the Supplier gives you once you call it the first time).

The pattern is still a good one, I think, for some uses - for instance, when
building an instance of a Chain in the registry, you might use
SupplierHandlers to get the right creational patterns for the component
parts inside the Chain.  I just don't think it can be used to replace the
idea of a registry full of Suppliers.

--Glen



Mime
View raw message