RE: 1st DNA container ever, need metadata contracts

"Peter@Stock" <peter-4lf8KW9E9MLMqX/[email protected]> Sun, 4 Apr 2004 11:12:20 +1000
Newsgroups gmane.comp.java.jcontainer.interest
Message-ID <[email protected]>
> after sourceforge anoncvs updates, the code that makes it 
> work will be at

Kool - will look when it is up.

> What is not stated on the website is anything along the lines of
> 
>    "Containers must verify the dna contract using metaclass, 
> and not run
>     components that do not provide verifiable resource 
> utilization data,
>     nor should the container attempt to run components for 
> which not all
>     resources are available."
> 
> What's your thoughts on that? Is this a requirement for calling a 
> container "dna compliant"?

The website really doesn't describe any of the equirements for a DNA
compatible container. It focuses on the demands of the component. Maybe we
should describe some of the containers responsibilities for DNA components.

> What's up with metaclass? Where does it live currently, where is it 
> moving, is there a final release? Which release should be 
> used with dna-1.0?

MetaClass will be migrated to a new top-level codehaus project and then
released out of beta real soon now. We are just waiting on the other Peter
to setup the infrastrucutre on Codehaus - hint hint ;) 

IIRC dna-1.0 did not use MetaClass at all - subsequent rcs have used
MetaClass in various guises and the latest release *should* use the latest
release of metaclass.

> public class DnaUtil
> {
>    /* ... */
> 
>    // TODO: should this be in dna-tools?
>    public static void verifyDnaContract( Class type )
>      throws InvalidTypeException
>    {
>      final ComponentVerifier verifier = new ComponentVerifier();
>      final VerifyIssue[] issues = verifier.verifyType( type );
>      if( issues.length > 0 )
>      {
>          throw new InvalidTypeException( issues );
>            // TODO: exception does not exist yet...

I would log all the messages first and then throw an exception after that.
This is why the ComponentVerifier returns an array of issues rather than
throwing an exception itself.

>      }
>    }
> 
>    public static void verifySatisfiableDnaContract( Class type,
>      ResourceLocator availableResources )
>    {
>      verifyDnaContract( type );
> 
>      // TODO: what goes here?

You need to assert that the container can provide all resources that the
component has declared it needs. .This means all resources defined as
dependency, configuration data (that matches schema if appropriate) and
logger(s). The container must also ensure that the component will not be
provided with resources if it has not declared the need for resource. The
coontainer must also ensure that any resources are "resolved" prior to the
component using them (ie services have been initialized before being passed
to component or JIT prior to first call).

> what do you think should be on the TODO lines? Should a utility class 
> like this (all dna-compatible containers would need stuff like this) 
> live in dna?

I can't think of a good way to implement any generic utility at this stage.
I have thought about writing a "generic" pico-like container (or even using
pico)  but that's not something that has been tackled yet.

Cheers,

Peter Donald

*-----------------------------------------------------*
* "Faced with the choice between changing one's mind, *
* and proving that there is no need to do so - almost *
* everyone gets busy on the proof."                   *
*              - John Kenneth Galbraith               *
*-----------------------------------------------------*