You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by marian grigoras <mg...@googlemail.com> on 2011/04/22 13:33:02 UTC

How to create an immediate component with DependencyManager?

Hello,

i want to use the DependencyManager to register a component which does not
offer any services for other components, but only listens to events and
displays them. With the registration code shown below, the events arrive at
the component, but the start(), stop() methods are never called.
According to the spec, the component should have immediate=true to be
activated even if not needed by someone else.
How can I achieve this using the DependencyManager?

Component component = mDependencyManager.createComponent()
            .setInterface(EventHandler.class.getName(), eventProps)
            .setImplementation(MyMonitorConsumer.class)

.add(mDependencyManager.createConfigurationDependency().setPid(pid)
        );

Thanks,
Marian

Re: How to create an immediate component with DependencyManager?

Posted by Pierre De Rop <pi...@gmail.com>.
Hello Marian;

Just to complete the response from Marcel: if an exception is raised from
your "updated" method, then config admin displays an ERROR message using the
log service
(or using stdout from the shell if no log service is available).

So, are you using log service ?

May be config admin has caught an exception when invoking your updated
method and has logged something ?
(just type "log error" under the shell in order to check eventual
configadmin error logs).

Hope this helps;
/pierre

On Fri, Apr 22, 2011 at 7:36 PM, Marcel Offermans <
marcel.offermans@luminis.nl> wrote:

> Hello Marian,
>
> On 22 Apr 2011, at 13:33 , marian grigoras wrote:
>
> > i want to use the DependencyManager to register a component which does
> not
> > offer any services for other components, but only listens to events and
> > displays them. With the registration code shown below, the events arrive
> at
> > the component, but the start(), stop() methods are never called.
>
> Could you please show me the implementation of the component so I can take
> a look at the signature of the methods you use?
>
> > According to the spec, the component should have immediate=true to be
> > activated even if not needed by someone else.
>
> That sounds like a part of the declarative services specification, not the
> dependency manager API. The dependency manager does not implement an OSGi
> specification.
>
> > How can I achieve this using the DependencyManager?
> >
> > Component component = mDependencyManager.createComponent()
> >            .setInterface(EventHandler.class.getName(), eventProps)
> >            .setImplementation(MyMonitorConsumer.class)
> >
>  .add(mDependencyManager.createConfigurationDependency().setPid(pid));
>
> This looks good, your component should be activated as soon as the required
> configuration dependency is present. In other words, it looks like you're
> using the API as intended, so I suspect there's something wrong with the
> actual callback methods.
>
> Greetings, Marcel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: How to create an immediate component with DependencyManager?

Posted by Marcel Offermans <ma...@luminis.nl>.
Hello Marian,

On 22 Apr 2011, at 13:33 , marian grigoras wrote:

> i want to use the DependencyManager to register a component which does not
> offer any services for other components, but only listens to events and
> displays them. With the registration code shown below, the events arrive at
> the component, but the start(), stop() methods are never called.

Could you please show me the implementation of the component so I can take a look at the signature of the methods you use?

> According to the spec, the component should have immediate=true to be
> activated even if not needed by someone else.

That sounds like a part of the declarative services specification, not the dependency manager API. The dependency manager does not implement an OSGi specification.

> How can I achieve this using the DependencyManager?
> 
> Component component = mDependencyManager.createComponent()
>            .setInterface(EventHandler.class.getName(), eventProps)
>            .setImplementation(MyMonitorConsumer.class)
>            .add(mDependencyManager.createConfigurationDependency().setPid(pid));

This looks good, your component should be activated as soon as the required configuration dependency is present. In other words, it looks like you're using the API as intended, so I suspect there's something wrong with the actual callback methods.

Greetings, Marcel


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org