Hi list,

question/observation about the dependencymanager callbacks contract. I
noticed that init() was being invoked more then once over the lifespan
of my service instance because 1) I constructed it with an instance
(insted of class/factory) and 2) I was adding dependencies in init,
leading to duplicates, leading to multiple service dependecy
callbacks.

  // Eg. This will result in multiple service dependencies upon
logservice (un)availibility as we will go throught init/destroy each
cycle
  public synchronized void init() {
        ServiceDependency logServiceDependency =
m_dependencyManager.createServiceDependency();
        logServiceDependency.setService(LogService.class);
        logServiceDependency.setRequired(true);
        m_component.add(logServiceDependency);
   }

My (naive) assumption was that init() would be called once and only
once an a service instance, but as it seems init/destroy is called
each time a required service becomes (unavailable). An assumption
corroborated by the following DependecyManager ComponentImpl snippet.

        if (oldState.isBound() && newState.isWaitingForRequired()) {
            m_executor.enqueue(new Runnable() {
                public void run() {
                    unbindService(oldState);
                    deactivateService(oldState);
                }});
        }

Question is why and what is the contract? Obvisouly, the fact that
this results in different behaviour depending on how one instantiates
the Component is rather confusing :S

Regards,
Bram

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

Reply via email to