ResolverImport newImport = new ResolverImport(rb, state.getFactory().createImportPackageSpecification(requestedPackage, null, null, null, ImportPackageSpecification.RESOLUTION_DYNAMIC, null, importingBundle));
Map directives = new HashMap(1); directives.put (Constants.RESOLUTION_DIRECTIVE, ImportPackageSpecification.RESOLUTION_DYNAMIC); ImportPackageSpecification packageSpec = state.getFactory().createImportPackageSpecification(requestedPackage, null, null, null, directives, null, importingBundle); ResolverImport newImport = new ResolverImport(rb, packageSpec);
	public synchronized ExportPackageDescription resolveDynamicImport(BundleDescription importingBundle, String requestedPackage) {		if (state == null)			throw new IllegalStateException("RESOLVER_NO_STATE"); //$NON-NLS-1$		// Make sure the resolver is initialized		if (!initialized)			initialize();		ResolverBundle rb = (ResolverBundle) bundleMapping.get(importingBundle);		ResolverImport[] resolverImports = rb.getImportPackages();		// Check through the ResolverImports of this bundle.		// If there is a matching one then pass it into resolveImport()		boolean found = false;		for (int j = 0; j < resolverImports.length; j++) {			// Make sure it is a dynamic import			if ((resolverImports[j].getImportPackageSpecification().getResolution() & ImportPackageSpecification.RESOLUTION_DYNAMIC) == 0) {				continue;			}			String importName = resolverImports[j].getName();			// If the import uses a wildcard, then temporarily replace this with the requested package			if (importName.equals("*") || //$NON-NLS-1$					(importName.endsWith(".*") && requestedPackage.startsWith(importName.substring(0, importName.length() - 2)))) { //$NON-NLS-1$				resolverImports[j].setName(requestedPackage);				found = true;			}			// Resolve the import			if (requestedPackage.equals(resolverImports[j].getName())) {				boolean resolved = resolveImport(resolverImports[j], true);				while (resolved && !checkDynamicGrouping(resolverImports[j])) {					resolved = resolveImport(resolverImports[j], true);				}				if (resolved) {					// If the import resolved then return it's matching export					resolverImports[j].setName(null);					if (DEBUG_IMPORTS)						ResolverImpl.log("Resolved dynamic import: " + rb + ":" + resolverImports[j].getName() + " -> " + resolverImports[j].getMatchingExport().getExporter() + ":" + requestedPackage); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$					ExportPackageDescription matchingExport = resolverImports[j].getMatchingExport().getExportPackageDescription();					// If it is a wildcard import then clear the wire, so other					// exported packages can be found for it					if (importName.endsWith("*")) { //$NON-NLS-1$						resolverImports[j].setMatchingExport(null);					}					return matchingExport;				}			}			// Reset the import package name			resolverImports[j].setName(null);		}		if (!found) {			ResolverImport newImport = new ResolverImport(rb, state.getFactory().createImportPackageSpecification(requestedPackage, null, null, null, ImportPackageSpecification.RESOLUTION_DYNAMIC, null, importingBundle));			boolean resolved = resolveImport(newImport, true);			while (resolved && !checkDynamicGrouping(newImport))				resolved = resolveImport(newImport, true);			if (resolved)				return newImport.getMatchingExport().getExportPackageDescription();		}		if (DEBUG || DEBUG_IMPORTS)			ResolverImpl.log("Failed to resolve dynamic import: " + requestedPackage); //$NON-NLS-1$		return null; // Couldn't resolve the import, so return null	}