On 01.10.2010, at 17:03, Bengt Rodehav wrote: > OK - obviously @ServiceController is what I need...
As said by Richard, The @ServiceController impacts the service lifecycle The @Controller impacts the instance lifecycle. The @Controller is generally used to detect wrong configuration or really bad state where the instance decide to become invalid. The @ServiceController is not tied to the instance lifecycle, which means that despite the instance is valid, the service can be unpublished using the @ServiceController. When you restart your instance, be sure that the filed is really re-assigned to false. To be sure, make your instance immediate and set the field in the constructor. Regards, Clement > > /Bengt > > 2010/10/1 Richard S. Hall <[email protected]> > >> On 10/1/10 10:41, Bengt Rodehav wrote: >> >>> OK - thanks, >>> >>> BTW, what then is @Controller used for? >>> >> >> It is for disabling the component itself and is generally more to signal >> error conditions from which the component cannot recover, such as faulty or >> missing configuration. On the other hand, @ServiceController allows you to >> control when your services are provided. >> >> -> richard >> >> >> /Bengt >>> >>> 2010/10/1 Karl Pauls<[email protected]> >>> >>> iirc, you want the @ServiceController and not the @Controller and >>>> again iirc, you need to update to ipojo 1.6.x for that one. >>>> >>>> regards, >>>> >>>> Karl >>>> >>>> On Fri, Oct 1, 2010 at 4:06 PM, Bengt Rodehav<[email protected]> wrote: >>>> >>>>> I'm using iPOJO 1.4.0. My installed iPOJO related artifacts (in Karaf >>>>> >>>> 1.6.0) >>>> >>>>> are: >>>>> >>>>> org.apache.felix.ipojo-1.4.0.jar >>>>> >>>>> org.apache.felix.ipojo.handler.extender-1.4.0.jar >>>>> >>>>> org.apache.felix.ipojo.online.manipulator-1.4.2.jar >>>>> >>>>> org.apache.felix.ipojo.webconsole-1.4.0.jar >>>>> >>>>> >>>>> I also use >>>>> >>>>> org.apache.felix.fileinstall-3.0.2.jar >>>>> >>>>> >>>>> ... and a whole lot of other bundles. >>>>> >>>>> I publish services using factories. An example of a configuration file >>>>> >>>> for >>>> >>>>> my factories is: >>>>> >>>>> connect.enabled=true >>>>> >>>>> connect.name=Sample file transfer from file to file >>>>> >>>>> >>>>> The "connect.enabled" property is bound to the field in my service class >>>>> that is a "controller": >>>>> >>>>> @Controller >>>>> >>>>> @Property(name = "connect.enabled", mandatory = false, value = "true") >>>>> >>>>> private boolean mValid; >>>>> >>>>> >>>>> The intention is that I can then disable my service by setting this >>>>> configuration property to false. However, I've encounted a problem >>>>> >>>> regarding >>>> >>>>> this. While the service is active, I set "connect.enabled" to false. >>>>> File >>>>> install picks up the changes and the service is de-registered - works >>>>> perfectly. But if I now shutdown Karaf and restart it again, the service >>>>> >>>> is >>>> >>>>> started (registered) despite the fact that "connect.disabled" is still >>>>> false. Is this a bug in iPOJO or have I misunderstood something? >>>>> >>>>> When googling about this problem I noticed that there is also an >>>>> >>>> annotation >>>> >>>>> called @ServiceController. What is the difference between @Controller >>>>> and >>>>> @ServiceController? >>>>> >>>>> I tried to switch to @ServiceController instead but get the following >>>>> >>>> error: >>>> >>>>> 2010-10-01 15:48:03,341 | ERROR | guration Updater | configadmin >>>>> >>>>>> | ? ? | >>>>>> [org.apache.felix.ipojo.Factory, >>>>>> >>>>> org.osgi.service.cm.ManagedServiceFactory, >>>> >>>>> id=174, bundle=84]: Updating configuration property >>>>>> >>>>>> {service.pid=connect.skandia.filetransfer.269d25ad-c4d6-4277-9d78-6d4b15acb795, >>>> >>>>> fromuri=file:data/connect/test/sample/file2file, >>>>>> touris=file:data/connect/test/sample/file2file/test-out, >>>>>> service.factorypid=connect.skandia.filetransfer, >>>>>> >>>>>> felix.fileinstall.filename=connect.skandia.filetransfer-sample-file2file.cfg, >>>> >>>>> connect.enabled=true, instance.name >>>>>> >>>>> =connect.skandia.filetransfer.269d25ad-c4d6-4277-9d78-6d4b15acb795, >>>> >>>>> connect.name=Sample file transfer from file to file} caused a problem: >>>>>> Missing handlers : org.apache.felix.ipojo.annotations:servicecontroller >>>>>> >>>>> org.osgi.service.cm.ConfigurationException: >>>>> >>>> >>>> {service.pid=connect.skandia.filetransfer.269d25ad-c4d6-4277-9d78-6d4b15acb795, >>>> >>>>> fromuri=file:data/connect/test/sample/file2file, >>>>>> touris=file:data/connect/test/sample/file2file/test-out, >>>>>> service.factorypid=connect.skandia.filetransfer, >>>>>> >>>>>> felix.fileinstall.filename=connect.skandia.filetransfer-sample-file2file.cfg, >>>> >>>>> connect.enabled=true, instance.name >>>>>> >>>>> =connect.skandia.filetransfer.269d25ad-c4d6-4277-9d78-6d4b15acb795, >>>> >>>>> connect.name=Sample file transfer from file to file} : Missing handlers >>>>>> >>>>> : >>>> >>>>> org.apache.felix.ipojo.annotations:servicecontroller >>>>>> >>>>> at >>>>> >>>> >>>> org.apache.felix.ipojo.IPojoFactory.updated(IPojoFactory.java:609)[38:org.apache.felix.ipojo:1.4.0] >>>> >>>>> at >>>>> >>>> >>>> org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceFactoryUpdate.run(ConfigurationManager.java:1279)[6:org.apache.felix.configadmin:1.2.4] >>>> >>>>> at >>>>> >>>> >>>> org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:88)[6:org.apache.felix.configadmin:1.2.4] >>>> >>>>> >>>>> I'm not sure in which jar the >>>>> " org.apache.felix.ipojo.annotations:servicecontroller" resides. I tried >>>>> >>>> to >>>> >>>>> deploy "org.apache.felix.ipojo.handler.whiteboard-1.4.0.jar" but it >>>>> >>>> didn't >>>> >>>>> seem to help. >>>>> >>>>> Can anyone help me sort this out? >>>>> >>>>> /Bengt >>>>> >>>>> >>>> >>>> -- >>>> Karl Pauls >>>> [email protected] >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [email protected] >>>> For additional commands, e-mail: [email protected] >>>> >>>> >>>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

