avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter M. Goldstein" <peter_m_goldst...@yahoo.com>
Subject RE: reduction ad unum
Date Sat, 23 Nov 2002 21:05:46 GMT

Noel,

> Please take a closer look at this, because I really think that it
> addressed
> each of your points, including the ability to handle both deprecation
and
> delegation.  From Stephen's reply, and yours, perhaps I didn't explain
my
> approach in sufficient context.  My approach would support both
individual
> operations:
> 
>    ShutdownRequestingContext src =
>     (ShutdownRequestingContext)
> context.get(ShutdownRequestingContext.class);
> 
>    DirectoryContext dc =
>      (DirectoryContext) context.get(DirectoryContext.class);
> 
>    MailForwardingContext mfc =
>      (MailForwardingContext) context.get(MailForwardingContext.class);
> 
> if all you know about are the "atomic" interfaces, as well as support:
> 
>    JAMESComponentContext jcc =
>      (JAMESComponentContext) context.get(JAMESComponentContext.class);
> 
> if you know about the "molecular" interface.  Note that client code is
> completely isolated from whether the relationship between the context
> implementation and the interface implementation is IS-A or HAS-A.

Ah, missed that.  The goal of this is to hide whether it's an IS-A or a
HAS-A.  That's why the get is being used rather than a simple cast.  So
to rephrase my last email, this would look like

public void contextualize(Context context) throws ContextException {
    
    AContract aContract =
(AContract)context.getInterface(AContract.class);
    // Do AContract stuff

    BContract bContract =
(BContract)context.getInterface(BContract.class);
    // Do BContract stuff
}

I've renamed the get call to getInterface because I would want it to be
distinguished from the current get method which just returns attributes.
IMO, the getInterface argument list should be narrow (i.e.
getInterface(Class clazz)) and if the requisite interface is not found
it should throw an exception with a meaningful message (i.e. "container
doesn't support this context contract - contract name"). 
 
Is this what you mean Noel?

--Peter



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


Mime
View raw message