in atomos/src/main/java/org/apache/felix/atomos/impl/modules/AtomosModules.java [611:650]
private boolean calculateRequires(Map<String, String> headers, Module m,
Function<String, String> mapper)
{
// only do requires for non bundle modules
// map requires to require bundle
StringBuilder requireBundleHeader = new StringBuilder();
for (Requires requires : m.getDescriptor().requires())
{
if (requireBundleHeader.length() > 0)
{
requireBundleHeader.append(", ");
}
// before requiring based on the name make sure the required
// module has a BSN that is the same
String mapping = mapper.apply(requires.name());
requireBundleHeader.append(mapping).append("; ");
// determine the resolution value based on the STATIC modifier
String resolution = requires.modifiers().contains(
Requires.Modifier.STATIC) ? Namespace.RESOLUTION_OPTIONAL
: Namespace.RESOLUTION_MANDATORY;
requireBundleHeader.append(Constants.RESOLUTION_DIRECTIVE).append(
":=").append(resolution).append("; ");
// determine the visibility value based on the TRANSITIVE modifier
String visibility = requires.modifiers().contains(
Requires.Modifier.TRANSITIVE) ? BundleNamespace.VISIBILITY_REEXPORT
: BundleNamespace.VISIBILITY_PRIVATE;
requireBundleHeader.append(Constants.VISIBILITY_DIRECTIVE).append(
":=").append(visibility);
}
if (requireBundleHeader.length() > 0)
{
headers.put(Constants.REQUIRE_BUNDLE, requireBundleHeader.toString());
return true;
}
else
{
return false;
}
}