aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Bosschaert (JIRA)" <>
Subject [jira] [Commented] (ARIES-1746) SPIFly support for InitialContextFactory
Date Fri, 13 Oct 2017 13:39:00 GMT


David Bosschaert commented on ARIES-1746:

That change is very specific to the javax.naming.spi.InitialContextFactory and does not belong
in SPI-Fly IMHO.

A more generic way to do this would be to get your own bundle to do this. Basically you have
a service tracker or something like this listen for the service that is registered by SPI-Fly.
The you can register the same service object in your own code under the {{javax.naming.spi.InitialContextFactory}}

Something like this:

    List<ServiceReference<InitialContextFactory>> handled = new CopyOnWriteArrayList<>();

    public void start() {
        BundleContext context = null;
        ServiceTracker<InitialContextFactory, InitialContextFactory> tracker = new ServiceTracker<InitialContextFactory,
InitialContextFactory>(context, InitialContextFactory.class, null) {
            public InitialContextFactory addingService(ServiceReference<InitialContextFactory>
reference) {
                InitialContextFactory svc = super.addingService(reference);
                if (!handled.contains(reference)) { // only process services once

                    String implClass = svc.getClass().getName();
                    String[] objClass = (String[]) reference.getProperty("objectClass");
                    List<String> newObjClasses = Arrays.asList(objClass);

                    context.registerService(newObjClasses.toArray(new String [] {}), svc,
                return svc;

Hope this works for you?

> SPIFly support for InitialContextFactory
> ----------------------------------------
>                 Key: ARIES-1746
>                 URL:
>             Project: Aries
>          Issue Type: Improvement
>          Components: SPI Fly
>            Reporter: Thusitha Thilina Dayaratne
> I'm trying to use Aries SPYFly with one of our projects. According to the OSGi spec when
we register an InitialContextFactory, we need to register that for both implementation and
InitialContextFactory classes.
> IMHO it would be great if we can support that with SPY-Fly

This message was sent by Atlassian JIRA

View raw message