}
}
if (m!=null) {
String importedBundles = m.getMainAttributes().getValue(ManifestConstants.BUNDLE_IMPORT_NAME);
if (importedBundles!=null) {
for( String token : new Tokenizer(importedBundles,",")) {
Collection<Module> modules = modulesRegistry.getModules(token);
if (modules.size() ==1) {
defs.add(modules.iterator().next().getModuleDefinition());
} else {
throw new ResolveError("Not able to locate a unique module by name " + token);
}
}
}
// Applications can add an additional osgi repos...
String additionalRepo = m.getMainAttributes().getValue(org.glassfish.api.ManifestConstants.GLASSFISH_REQUIRE_REPOSITORY);
if (additionalRepo != null) {
for (String token : new Tokenizer(additionalRepo, ",")) {
// Each entry should be name=path
int equals = token.indexOf('=');
if (equals == -1) {
// Missing '='...
throw new IllegalArgumentException("\""
+ org.glassfish.api.ManifestConstants.GLASSFISH_REQUIRE_REPOSITORY
+ ": " + additionalRepo + "\" is missing an '='. "
+ "It must be in the format: name=path[,name=path]...");
}
String name = token.substring(0, equals);
String path = token.substring(++equals);
addRepository(name, resolver.translate(path));
}
}
// Applications can also request to be wired to implementors of certain services.
// That means that any module implementing the requested service will be accessible
// by the parent class loader of the application.
String requestedWiring = m.getMainAttributes().getValue(org.glassfish.api.ManifestConstants.GLASSFISH_REQUIRE_SERVICES);
if (requestedWiring!=null) {
for (String token : new Tokenizer(requestedWiring, ",")) {
for (Object impl : habitat.getAllServices(BuilderHelper.createContractFilter(token))) {
Module wiredBundle = modulesRegistry.find(impl.getClass());
if (wiredBundle!=null) {
defs.add(wiredBundle.getModuleDefinition());
}