[
https://issues.apache.org/jira/browse/ARIES-1746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16203572#comment-16203572
]
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}}
interface.
Something like this:
{code}
List<ServiceReference<InitialContextFactory>> handled = new
CopyOnWriteArrayList<>();
public void start() {
BundleContext context = null;
ServiceTracker<InitialContextFactory, InitialContextFactory> tracker =
new ServiceTracker<InitialContextFactory, InitialContextFactory>(context,
InitialContextFactory.class, null) {
@Override
public InitialContextFactory
addingService(ServiceReference<InitialContextFactory> reference) {
InitialContextFactory svc = super.addingService(reference);
if (!handled.contains(reference)) { // only process services
once
handled.add(reference);
String implClass = svc.getClass().getName();
String[] objClass = (String[])
reference.getProperty("objectClass");
List<String> newObjClasses = Arrays.asList(objClass);
newObjClasses.add(implClass);
context.registerService(newObjClasses.toArray(new String []
{}), svc, reference.getProperties());
}
return svc;
}
};
tracker.open();
}
{code}
Hope this works for you?
> SPIFly support for InitialContextFactory
> ----------------------------------------
>
> Key: ARIES-1746
> URL: https://issues.apache.org/jira/browse/ARIES-1746
> 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
(v6.4.14#64029)