public void addProviderImports(BundleContext containerContext,
Bundle persistenceBundle,
ServiceReference providerReference) {
if (persistenceBundle.getState() == Bundle.INSTALLED && providerReference != null) {
Bundle providerBundle = providerReference.getBundle();
BundleDescription providerDescription = new BundleDescription(providerBundle.getHeaders());
if (needsProviderImports(persistenceBundle, providerDescription)) {
StringBuilder providerConstraint = new StringBuilder();
providerConstraint.append(";");
providerConstraint.append(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
providerConstraint.append("=\"").append(providerBundle.getSymbolicName()).append("\"");
providerConstraint.append(";");
providerConstraint.append(Constants.BUNDLE_VERSION_ATTRIBUTE);
String exportVersion = providerBundle.getVersion().toString();
providerConstraint.append("=\"[").append(exportVersion).append(",").append(exportVersion).append("]\"");
if (BundleHelper.isBundleExtenderSet()) {
LOG.debug("Adding DynamicImport-Package for persistence bundle {}", persistenceBundle.getSymbolicName());
StringBuilder packageList = new StringBuilder();
Iterator<ExportPackage> iterator = providerDescription.getExportPackage().iterator();
while (iterator.hasNext()) {
ExportPackage exportPackage = iterator.next();
packageList.append(exportPackage.getName()).append(providerConstraint);
if (iterator.hasNext()) {
packageList.append(",");
}
}
BundleHelper.addDynamicImportPackage(persistenceBundle.getBundleId(), packageList.toString());
} else {
LOG.debug("Generating JPA fragment for persistence bundle {}", persistenceBundle.getSymbolicName());
FragmentBuilder builder = new FragmentBuilder(persistenceBundle, ".jpa.fragment", "JPA Fragment");
for (ExportPackage exportPackage : providerDescription.getExportPackage()) {
builder.addImports(exportPackage.getName() + providerConstraint);
}
Bundle fragment;
try {