On 2010-12-09 20.39, Niclas Hedhman wrote:
Not totally sure. So, for the 'simple' case I need additional Qi4j interfaces.

Example is better...

public interface LogService{} is a OSGi service.

To use that I expected that a simple;

@Service
private LogService logger;

would be enough for the client code, with a

module.importServices( LogService.class )
     .importedBy( OSGiServiceImporter.class)
     .setMetaInfo( bundleContext );

in the assembly.

With what I suggested this would be:
// This is for a specific service you want to import from OSGi
module.importServices( LogService.class )
     .importedBy( ServiceInstanceImporter.class)
     .setMetaInfo( "osgi" );

// This is for the general importer, declared only once
module.addServices(OSGiImporterService.class).setMetaInfo(bundleContext).identifiedBy("osgi");

When the ServiceInstanceImporter is told to import LogService it will lookup a service implementing ServiceImporter with the given id ("osgi" in this case), and ask it to do the actual importing. The OSGiImporterService (which implements ServiceImporter) will do the work, and save the instance in an internal collection so that it can be unimported on passivate() of the OSGiImporterService.

So the ServiceInstanceImporter is generic for all cases where you want a service to handle the importing (we can put this in SPI with the other generic importers), and the OSGiImporterService is generic for all cases where you want to import services from OSGi. Once that is written it's only a matter of assembly to add more services from OSGi.

Clearer?

/Rickard

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to