Hi,

2008/12/15 Todor Boev <[email protected]>

> Hello,
> I am trying to add a new flavor of service dependency to iPojo. It's
> purpose in life is to provide the dynamic-proxy approach to service
> tracking. I.e. it will make iPojo a bit like Spring Dynamic Modules - but
> without the tons of XML and with a nicer architecture ;P
>
> I need this because:
> 1) I want to propagate the service dependencies from components into
> collaborator objects.

Interesting :-)


>
> 2) I don't want to create anonymous proxies manually and have iPojo
> instrument them. Too verbose.
> 3) I want to use collections for the aggregate services rather than arrays.


iPOJO manages this (list, collection,vector and set). Just you need to
specify the service interface in the metadata (or in the annotation):

*    <requires field="m_hellos" interface="o.a.f.i.Hello"/>*



>
> 4) I will not be using this in an embedded device so the performance
> overhead of proxies is not that much of an issue (the proxies I have here
> make the coast of a method call equal to about 1.5 the coast of a normal
> Java synchronized method call).
>
> At the same time I still want to retain all the the other goodies iPojo
> adds to the normal service dependencies. After looking for a while at the
> DependencyHandler, Dependency, DependencyCallback classes I came to the
> conclusion that I need to code my dependency stuff directly from
> PrimitiveHandler :(
> If you have an idea what can I extend to reuse most of that code - please
> tell me.


So, why not extending DependencyModel (org.apache.felix.ipojo.util). This
class contains the most part of the iPOJO dependency management (dynamism
...). You just have to implement some abstract methods to be notified when a
service provider arrives or disappears, or when the dependency is
reconfigured. Then, just implement your injection as you want
(FieldInterceptor interface) and manage the validity of the dependency...


>
> Fortunately with the exception of compositions I seem to have everything
> else implemented already. From the DependencyHandler code it seems the
> composition support is relatively easy to add. The last bit that worries me
> is this:
>
> ProvidedServiceHandler refers to the DependencyHandler. It seems it needs
> to check if all incoming dependencies are valid before it can register a
> component as a service. So it seems I will have to code both the service
> registration and the service consumption. Or is there a way I can code just
> the service consumption and still get the registration check out my
> dependencies for validity?


So, the ProvidedServiceHandler interacts with the DependencyHandler to
manage service-level dependencies (an advanced iPOJO composition feature).
This interaction does not manage the instance validation/invalidation. This
is managed by the iPOJO container itself. Handlers impacting on the instance
state calls the setValidity method. So, you don't have to modify the
provided service handler.

You can look at the temporal dependency handler (
http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java?view=log)
that implement a 'flavor' of service dependency.


Regards,

Clement


>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to