On 2010-02-02 22.46, Niclas Hedhman wrote:
On Tue, Feb 2, 2010 at 2:28 PM, Rickard Öberg<[email protected]>  wrote:

In general, sounds really good...

Here's my assembly code:
module.addServices( DataSourceService.class ).identifiedBy( "datasource"
).visibleIn( Visibility.application );
module.importServices( DataSource.class ).
      importedBy( ServiceInstanceImporter.class ).
      setMetaInfo( "datasource" ).
      identifiedBy( "streamflow" ).visibleIn( Visibility.application );

Couple of questions;
1. I'm interested to see the pattern between the DSS and DS...

Here's the entire code so far:
public class ServiceInstanceImporter
   implements ServiceImporter
{
   @Structure
   ServiceFinder finder;

   String serviceId;

public Object importService( ImportedServiceDescriptor importedServiceDescriptor ) throws ServiceImporterException
   {
      serviceId = importedServiceDescriptor.metaInfo( String.class );

for (ServiceReference<ServiceImporter> reference : finder.<ServiceImporter>findServices( ServiceImporter.class ))
      {
         if (reference.identity().equals( serviceId ))
return reference.get().importService( importedServiceDescriptor );
      }

throw new ServiceImporterException("No service importer with id '"+ serviceId +"' was found");
   }

   public boolean isActive( Object o )
   {
for (ServiceReference<ServiceImporter> reference : finder.<ServiceImporter>findServices( ServiceImporter.class ))
      {
         if (reference.identity().equals(serviceId))
            return reference.get().isActive( o );
      }

      return false;
   }
}



2. What does the "datasource" metainfo give you?

There can be many ServiceImporter services registered. I need to know which one to pick.

3. How does Configuration kick in for the DataSource and
DataSourceService respectively?

Good question. I'm guessing the DataSourceService would have to use UnitOfWork explicitly to load an entity with the id given by the ImportedServiceDescriptor, instead of the @This Configuration<> injection.

4. Are you also pushing across a lib for the actual case here, i.e.
DataSources, or only asking about the ServiceInstanceImporter itself?

Might as well put in the DataSource code, since it would be generally useful.

/Rickard

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

Reply via email to