You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by "mffrench@axway.com" <mf...@axway.com> on 2009/08/11 18:23:41 UTC
iPojo service + ManagedService
Hello,
I'm new to Felix + iPojo and I'm trying to build a service which will be
exposed to the configuration admin at the Felix start.
In order to achieve my aims I've this source code in my service:
@Component(name="toto", propagation=true, architecture=true,
immediate=true, managedservice="titi")
@Provides
public class TotoServiceImpl implements Runnable, TotoService {
@Property
String aproperty = null
@Validate
public void start() {
...
}
@Unvalidate
public void stop() {
...
}
@Override
public void run() {
...
}
}
I instanciate my service through my pom.xml:
<instance
component="Foo.TotoServiceImpl">
<property name="aproperty"
value="TEST"/>
</instance>
So when starting my felix I can see my service thanks arch command:
...
Instance toto-0 -> valid
...
and thanks services command:
...
Foo.TotoServiceImpl
...
But as you can see my managedservicepid is not taking into account and
when I try the command arch -instance it return me "Instance not found" ...
Did I miss something ???
Thanks for all
++
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: iPojo service + ManagedService
Posted by clement escoffier <cl...@gmail.com>.
Hi,
There is some issue in your code:
- Unvalidate does not exist it's Invalidate.
- except if it's your goal, publishing Runnable as a service is not
necessary a good idea, you can specify the set of provided services in
@Provides
The following code works:
@Component(name="toto", propagation=true, architecture=true,
immediate=true, managedservice="titi")
@Provides
public class TotoImpl implements Runnable {
@Property
String aproperty = null;
@Validate
public void start() {
System.out.println("Started...");
}
@Invalidate
public void stop() {
System.out.println("Stopped...");
}
public void run() {
// TODO Auto-generated method stub
}
}
Then, with the following instance declaration:
<instance component="org.apache.felix.ipojo.sample.Toto"/>
the managed service is correctly exposed:
{org.osgi.service.cm.ManagedService}={service.pid=titi, factory.name=toto,
instance.name=toto-0, service.id=34}
Regards,
Clement
2009/8/11 mffrench@axway.com <mf...@axway.com>
> Hello,
>
> I'm new to Felix + iPojo and I'm trying to build a service which will be
> exposed to the configuration admin at the Felix start.
> In order to achieve my aims I've this source code in my service:
>
> @Component(name="toto", propagation=true, architecture=true,
> immediate=true, managedservice="titi")
> @Provides
> public class TotoServiceImpl implements Runnable, TotoService {
>
> @Property
> String aproperty = null
>
> @Validate
> public void start() {
> ...
> }
>
> @Unvalidate
> public void stop() {
> ...
> }
>
> @Override
> public void run() {
> ...
> }
>
> }
>
> I instanciate my service through my pom.xml:
>
> <instance
> component="Foo.TotoServiceImpl">
> <property name="aproperty"
> value="TEST"/>
> </instance>
>
> So when starting my felix I can see my service thanks arch command:
>
> ...
> Instance toto-0 -> valid
> ...
>
> and thanks services command:
>
> ...
> Foo.TotoServiceImpl
> ...
>
>
> But as you can see my managedservicepid is not taking into account and
> when I try the command arch -instance it return me "Instance not found" ...
>
> Did I miss something ???
>
> Thanks for all
>
> ++
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>