> From: Alex Karasulu [mailto:[EMAIL PROTECTED] 
>
> >     myContainer.addAspect(new DependencyValidation());
> 
> Now this is very interesting.  You're suggesting that 
> dependency checks are a feature of the container?  I think I 
> like this.  It's a most excellent way to take an intertwined 
> aspect of a container and separate it.

This is how it would be done:

You have two things: ComponentHandlers and Aspects. Component
handlers manage components, and Aspects are system-level plugins
that have access to all componenthandlers in the system.

Define a package org.apache.avalon.meta.dependency:

    public interface DependencyProvider {
        ServiceDefinition[] provides ();
        ServiceDefinition[] requires ();
    }

    public class ServiceDefinition { ... }

    public interface DependencyValidation {
        public static final int VALID = 0;
        public static final int INVALID = 1;
        public static final int INDETERMINATE = 2;
        public int validate ();
    }

    public class DependencyValidationImpl implements
DependencyValidation {
        /* default impl */ 
    }

OK, now, any ComponentHandler that wishes to be part of the
dependency validation must implement DependencyProvider. If you
don't implement it, fine - you're not part of the validation.

The DependencyValidationImpl listens to events in the container - 
when is a component handler added, when is one removed? It checks
when a handler has been added and updates the state - is it valid,
invalid, or indeterminate due to component handlers that don't
participate?

Then add one method to the container:

    Object Container.getAspect (Class aspectClass);

So you add the aspect, add a lot of component handlers, and
then you get the aspect from the container, and call its validate()
method.

If you don't care for validation, then just don't add the aspect.

If you're a ComponentHandler author, you can choose to participate
in validation or not by implementing/not implementing DependecyProvider.

In fact, you don't have to care about the
org.apache.avalon.meta.dependency
package at all.

What do you think? (Not the implementation, but the concept.)

/LS


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to