boolean useLocation = location != null
&& !location.isEmpty()
&& !module.isStandaloneModule();
Set<String> beanArchiveJarNames = findBeansXml(bundle, packageAdmin, useLocation? location : "");
BundleAnnotationFinder bundleAnnotationFinder;
if (useLocation) {
ResourceDiscoveryFilter filter = new ResourceDiscoveryFilter() {
@Override
public boolean rangeDiscoveryRequired(DiscoveryRange discoveryRange) {
return discoveryRange == DiscoveryRange.BUNDLE_CLASSPATH || discoveryRange == DiscoveryRange.FRAGMENT_BUNDLES;
}
@Override
public boolean zipFileDiscoveryRequired(String s) {
return isWAR ? s.startsWith(location) : s.equals(location);
}
@Override
public boolean directoryDiscoveryRequired(String s) {
return isWAR ? s.startsWith(location) : s.equals(location);
}
};
bundleAnnotationFinder = new BundleAnnotationFinder(packageAdmin, bundle, filter, beanArchiveJarNames);
} else {
ResourceDiscoveryFilter filter = new ResourceDiscoveryFilter() {
@Override
public boolean rangeDiscoveryRequired(DiscoveryRange discoveryRange) {
return discoveryRange == DiscoveryRange.BUNDLE_CLASSPATH || discoveryRange == DiscoveryRange.FRAGMENT_BUNDLES;
}
@Override
public boolean zipFileDiscoveryRequired(String s) {
return true;
}
@Override
public boolean directoryDiscoveryRequired(String s) {
return true;
}
};
bundleAnnotationFinder = new BundleAnnotationFinder(packageAdmin, bundle, filter, beanArchiveJarNames);
}
bundleAnnotationFinder.link();
return bundleAnnotationFinder;
}
throw new IllegalStateException("Module classloader is not a BundleReference. Only use BundleFactoryFinder in an pure osgi environment");
}