endpointDescription);
}
private BundleContext getProxyServiceFactoryContext(
EndpointDescription endpointDescription) throws Exception {
Activator a = Activator.getDefault();
if (a == null)
throw new NullPointerException(
"ECF RemoteServiceAdmin Activator cannot be null."); //$NON-NLS-1$
if (a.isOldEquinox()) {
// In this case, we get the Bundle that exposes the first service
// interface class
BundleContext rsaContext = Activator.getContext();
if (rsaContext == null)
throw new NullPointerException(
"RSA BundleContext cannot be null"); //$NON-NLS-1$
List<String> interfaces = endpointDescription.getInterfaces();
Collection<Class> serviceInterfaceClasses = loadServiceInterfacesViaBundle(
rsaContext.getBundle(),
interfaces.toArray(new String[interfaces.size()]));
if (serviceInterfaceClasses.size() == 0)
throw new NullPointerException(
"No interface classes loadable for endpointDescription=" //$NON-NLS-1$
+ endpointDescription);
// Get the bundle responsible for the first service interface class
Class serviceInterfaceClass = serviceInterfaceClasses.iterator()
.next();
Bundle bundle = FrameworkUtil.getBundle(serviceInterfaceClass);
if (bundle == null)
throw new BundleException("Bundle for service interface class=" //$NON-NLS-1$
+ serviceInterfaceClass.getName() + " cannot be found"); //$NON-NLS-1$
int bundleState = bundle.getState();
BundleContext bundleContext = bundle.getBundleContext();
if (bundleContext == null)
throw new BundleException("Bundle=" + bundle.getSymbolicName() //$NON-NLS-1$
+ " in wrong state (" + bundleState //$NON-NLS-1$
+ ") for using BundleContext proxy service factory"); //$NON-NLS-1$
return bundleContext;
}
return a.getProxyServiceFactoryBundleContext();
}