I wasn't saying that the Registry or Module should be injected into
the user CSIs. I agree with you that it wouldn't be a good idea.  It
is currently not even possible, is it?  Implementation factories (as
e.g. BuilderFactory and your proposed service I dubbed as BeanFactory)
do at construction time have access to the invoking Module object
(provided by HiveMind) and could thus pass this as a parameter to the
ServiceInjector.  I.e.

public interface ServiceInjector
{
  public void injectServices(Object target, Module invokingModule);
}

I don't think the ServiceInjector would be useful other than to
implemenation factory services.

What I'm wondering about is if it makes sense to wrap up the
dependency injection logic inside a service (which will only be used
by implementation factories) or if that is overkill? IOW: Is there a
reason a user would like to write an implementation factory with
autowiring capabilities instead of using BuilderFactory or
BeanFactory.  IMO that would justify a ServiceInjector service.

We could of course also solve the problem by adding a configuration
point which all services would be contributed to... Not being serious
here :-)

--knut

On Wed, 27 Oct 2004 09:22:48 -0400, Howard Lewis Ship <[EMAIL PROTECTED]> wrote:
> I'm not very keen on injecting the Module instance into a CSI.  I
> consider the Module to be part of the internals of HiveMind and want
> to hide it as much as possible from end-user code.
> 
> I strongly object to injecting or otherwise exposing the Registry;
> anything you'd need from the Registry is available from the Module,
> and will do visibility checks properly from the Module.
> 
> On Wed, 27 Oct 2004 15:03:38 +0200, Knut Wannheden
> <[EMAIL PROTECTED]> wrote:
> > I haven't thought to hard about it either, but I think you're right:
> > it would need a reference to the Registry or any Module object.  Since
> > I don't think it's currently possible to inject either of these into
> > the core implementation it would have to be a method parameter.
> > Shouldn't be a problem for factory services which do have access to
> > the invoking Module object.
> >
> > Note that we already have a class named DependencyDescriptor in
> > HiveMind. And wouldn't it almost be easier for the client to perform
> > the dependency injection itself than using this 2nd method?  E.g.
> >
> > PropertyUtils.write(dependentObject, propertyName,
> > Registry.getService(dependencyId);
> >
> > instead of:
> >
> > serviceInjector.injectDependencies(registry, dependentObject, new
> > DependencyDescriptor[] { new DependencyDescriptorImpl(dependencyType,
> > propertyName, dependencyId) });
> >
> > But instead of an array of DependencyDescriptors the client could
> > maybe pass a set of objects, which the service could select from for
> > the injection.
> >
> > --knut
> >
> > On Wed, 27 Oct 2004 08:36:42 -0400, James Carman
> >
> >
> > <[EMAIL PROTECTED]> wrote:
> > > Do you think it would be overkill to also provide a method which performs
> > > specified injection?  Something like this...
> > >
> > > public void injectDependencies( Registry registry, Object dependentObject 
> > > );
> > > public void injectDependencies( Registry registry, Object dependentObject,
> > > DependencyDescriptor[] dependencies );
> > >
> > > A DependencyDescriptor would look like...
> > >
> > > public class DependencyDescriptor
> > > {
> > >   public Class getDependencyType();
> > >   public String getPropertyName();
> > >   public String getDependencyId();
> > > }
> > >
> > > Basically, this is for when you have multiple service points with the same
> > > service interface.  I added the Registry parameter because I don't know
> > > whether or not this should be a service.  Maybe it could just be a helper
> > > method somewhere (or added to Registry itself).  Wouldn't we run into a
> > > chicken and egg situation if we wanted to make this a service?  I mean, 
> > > what
> > > builds the service implementation for this service?  BuilderFactory?  But,
> > > what does BuilderFactory use to wire together the implementation object?
> > > Even if we make it a primitive service (which I don't think is built by
> > > BuilderFactory), what injects its dependencies?  I may be wrong here, as I
> > > haven't really thought through it completely (need more coffee), but
> > > something just doesn't smell right to me (maybe I need a shower too).
> > >
> > >
> > 
> > ---------------------------------------------------------------------
> 
> 
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> --
> Howard M. Lewis Ship
> Independent J2EE / Open-Source Java Consultant
> Creator, Jakarta Tapestry
> Creator, Jakarta HiveMind
> http://howardlewisship.com
>

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

Reply via email to