On Thu, Dec 9, 2010 at 6:29 PM, Rickard Öberg <[email protected]> wrote:
> Here's what the assembly looks like, so you can get a feel for how things
> relate:
> module.addServices( DataSourceService.class ).identifiedBy( "datasource"
> ).visibleIn( Visibility.application );
> module.importServices( DataSource.class ).
> importedBy( ServiceInstanceImporter.class ).
> setMetaInfo( "datasource" ).
> identifiedBy( "streamflowds" ).visibleIn( Visibility.application );
> --
> The ServiceInstanceImporter is completely generic, so I could add that to to
> the org.qi4j.spi.service.importer package. It does a lookup of a service
> that implements "ServiceImporter" and which has "datasource" as service-id,
> which I then set as id for the real service. DataSourceService implements
> ServiceImporter and Activatable.
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.
What you are now suggesting is that ServiceInstanceImporter is looking
for ServiceImporter (where? it has access to ModuleSPI at this
stage?), which would be an extends LogService and a Mixin that knows
how to interact with the OSGiServiceImporter;
@Mixins( OSGiServiceImportMixin.class )
interface ImportedLogService
extends LogService, Activatable, ServiceImporter, ServiceComposite
{}
and then in the assembly I would end up with something like;
module
.addServices( ImportedLogService.class )
.setMetaInfo( bundleContext )
.identifiedBy( "logService" );
module.importServices( LogService.class ).
importedBy( ServiceInstanceImporter.class ).
setMetaInfo( "logService" ).
identifiedBy( "??What is this for??" );
But then, I am starting to wonder why would I need the ServiceImporter
at all? If a new interface is needed, with mixins, then I can just
create a Generic Mixin that delegates every method to the imported
service. I selected to not choose that path to keep it simple (well,
also that some services are not expressed as interfaces, but that I
could probably be without) for the poor developer.
Is my understanding right here?
Cheers
--
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java
I live here; http://tinyurl.com/3xugrbk
I work here; http://tinyurl.com/24svnvk
I relax here; http://tinyurl.com/2cgsug
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev