Class ResourceBuilder
java.lang.Object
aQute.bnd.osgi.resource.ResourceBuilder
- Direct Known Subclasses:
SyntheticBuilder
The ResourceBuilder class provides a fluent API for constructing resources.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new `ResourceBuilder`.ResourceBuilder(SupportingResource parent) Constructs a new `ResourceBuilder`.ResourceBuilder(org.osgi.resource.Resource source) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.voidaddCapabilities(List<org.osgi.resource.Capability> capabilities) addCapability(CapReqBuilder builder) Adds a capability to this builder using the given `CapReqBuilder`.addCapability(org.osgi.resource.Capability capability) Adds a capability to this builder.voidaddContentCapability(URI uri, String sha256, long length, String mime) voidAdds the Execution Environment information to this Processor's capabilities list and exported packages list.voidDeprecated.voidaddExportPackage(String name, Attrs attrs) Adds a new Export-Package requirement to this Processor's requirements list, representing an exported package with the specified name and attributes, and exporting by the current bundle.voidaddExportPackage(String name, Attrs attrs, String bundle_symbolic_name, org.osgi.framework.Version bundle_version) Adds a new Export-Package requirement to this Processor's requirements list, representing an exported package with the specified name and attributes, and exporting by the specified bundle.voidaddExportPackages(Parameters exports) Adds one or more Export-Package requirements to this Processor's requirements list, using the specified Parameters object to define the exported packages and their attributes.voidaddExportPackages(Parameters exports, String bundle_symbolic_name, org.osgi.framework.Version bundle_version) Adds one or more Export-Package requirements to this Processor's requirements list, using the specified Parameters object to define the exported packages and their attributes, as well as the bundle symbolic name and version for the exporting bundle.voidaddExportServices(Parameters exportServices) Adds CapabilityBuilder objects to this Processor's capabilities list, one for each service listed in the exportServices Parameters object.booleanbooleanvoidaddFragmentHost(String bsn, Attrs attrs) Adds a new Fragment-Host requirement to this Processor's requirements list, specifying the host bundle symbolic name and any additional attributes.voidvoidorg.osgi.resource.RequirementaddImportPackage(String name, Attrs attrs) voidaddImportPackages(Parameters imports) Add imported packagesvoidaddImportServices(Parameters importServices) Adds RequirementBuilder objects to this Processor's requirements list, one for each service listed in the importServices Parameters object.booleanbooleanaddManifest(Domain manifest) Parse the manifest and turn them into requirements invalid input: '&' capabilitiesbooleanList<org.osgi.resource.Capability> addProvideCapabilities(Parameters capabilities) Adds one or more CapabilityBuilder objects to this Processor's capabilities list, using the specified Parameters object to define the provided capabilities.List<org.osgi.resource.Capability> addProvideCapabilities(String clauses) org.osgi.resource.CapabilityaddProvideCapability(String namespace, Attrs attrs) Adds a new CapabilityBuilder object to this Processor's capabilities list, representing a provided capability with the specified namespace and attributes.voidaddRequireBundle(String bsn, Attrs attrs) Adds a new Require-Bundle requirement to this Processor's requirements list, specifying the bundle symbolic name and any additional attributes.voidaddRequireBundle(String bsn, VersionRange range) Adds a new Require-Bundle requirement to this Processor's requirements list, specifying the bundle symbolic name and version range.voidaddRequireBundles(Parameters requireBundle) Add the Require-Bundle headervoidaddRequireCapabilities(Parameters required) Adds one or more Require-Capability requirements to this Processor's requirements list, using the specified Parameters object to define the required capabilities.voidaddRequireCapability(String namespace, String name, Attrs attrs) Adds a new Require-Capability requirement to this Processor's requirements list, using the specified namespace, name, and attributes.voidaddRequireCapability(String namespace, String name, String versionRange, Attrs attrs) Adds a new Require-Capability requirement to this Processor's requirements list, using the specified namespace, name, version range, and attributes.addRequirement(CapReqBuilder builder) Adds a requirement to this ResourceBuilder.voidaddRequirement(List<org.osgi.resource.Requirement> requirements) addRequirement(org.osgi.resource.Requirement requirement) Adds a requirement to this builder.voidaddRequirements(List<org.osgi.resource.Requirement> requires) addResource(SupportingResource source) Adds a composite resource to this builder.addResource(org.osgi.resource.Resource source) Adds a resource to this builder.voidaddSupportingResource(org.osgi.resource.Resource resource) Adds a supporting resource to this builder.voidaddWorkspaceNamespace(String name) A repository that implements theWorkspaceRepositoryMarkerin the resolver must add a WORKSPACE_NAMESPACE capability to make its clear the resources are from the workspace.build()Builds and returns a new SupportingResource object using the data stored in this ResourceBuilder.protected CapabilityImplbuildCapability(CapReqBuilder builder) Builds a capability using the given `CapReqBuilder`.protected RequirementImplbuildRequirement(CapReqBuilder builder) Builds a new RequirementImpl object using the provided CapReqBuilder.voidcopyCapabilities(Set<String> ignoreNamespaces, org.osgi.resource.Resource r) List<org.osgi.resource.Capability> findCapabilities(String ns, String filter) Map<org.osgi.resource.Capability, org.osgi.resource.Capability> from(org.osgi.resource.Resource bundle) List<org.osgi.resource.Capability> Returns a flattened list of all the Capability objects stored in this ResourceBuilder.getNativeCode(String header) Calculate the requirement from a native code headeraQute.service.reporter.ReporterList<org.osgi.resource.Requirement> Returns a flattened list of all the Requirement objects stored in this ResourceBuilder.static Supplier<org.osgi.resource.Resource> Create a deferred resource builder so that any expensive actions are deferred until the supplier is called to get the resource.static SupportingResourcetoString()
-
Field Details
-
SYNTHETIC
- See Also:
-
-
Constructor Details
-
ResourceBuilder
public ResourceBuilder()Constructs a new `ResourceBuilder`. -
ResourceBuilder
Constructs a new `ResourceBuilder`. -
ResourceBuilder
Deprecated.Constructs a new `ResourceBuilder` with the given source resource.- Parameters:
source- the source resource to add to this builder
-
-
Method Details
-
addResource
Adds a resource to this builder. If the resource is a `SupportingResource`, it is added as a composite resource, otherwise its capabilities and requirements are added to this builder.- Parameters:
source- the resource to add- Returns:
- this builder
-
addResource
Adds a composite resource to this builder. The capabilities, requirements, and supporting resources of the composite resource are added to this builder.- Parameters:
source- the composite resource to add- Returns:
- this builder
-
addSupportingResource
public void addSupportingResource(org.osgi.resource.Resource resource) Adds a supporting resource to this builder.- Parameters:
resource- the supporting resource to add
-
addCapability
Adds a capability to this builder.- Parameters:
capability- the capability to add- Returns:
- this builder
-
addCapability
Adds a capability to this builder using the given `CapReqBuilder`.- Parameters:
builder- the `CapReqBuilder` to use for building the capability- Returns:
- this builder
-
buildCapability
Builds a capability using the given `CapReqBuilder`.- Parameters:
builder- the `CapReqBuilder` to use for building the capability- Returns:
- the built capability
-
addRequirement
Adds a requirement to this builder.- Parameters:
requirement- the requirement to add- Returns:
- this builder
-
addRequirement
Adds a requirement to this ResourceBuilder.- Parameters:
builder- the CapReqBuilder representing the requirement to add- Returns:
- this ResourceBuilder instance
- Throws:
IllegalStateException- if the Resource has already been built
-
buildRequirement
Builds a new RequirementImpl object using the provided CapReqBuilder.- Parameters:
builder- the CapReqBuilder to use to build the RequirementImpl- Returns:
- the newly created RequirementImpl object
-
build
Builds and returns a new SupportingResource object using the data stored in this ResourceBuilder.- Returns:
- the newly created SupportingResource object
- Throws:
IllegalStateException- if the Resource has already been built
-
getCapabilities
Returns a flattened list of all the Capability objects stored in this ResourceBuilder.- Returns:
- a List of Capability objects
-
getRequirements
Returns a flattened list of all the Requirement objects stored in this ResourceBuilder.- Returns:
- a List of Requirement objects
-
addManifest
Parse the manifest and turn them into requirements invalid input: '&' capabilities- Parameters:
manifest- The manifest to parse
-
addExportServices
Adds CapabilityBuilder objects to this Processor's capabilities list, one for each service listed in the exportServices Parameters object.- Parameters:
exportServices- the Parameters object containing the service names and attributes to export
-
addImportServices
Adds RequirementBuilder objects to this Processor's requirements list, one for each service listed in the importServices Parameters object.- Parameters:
importServices- the Parameters object containing the service names and attributes to import
-
getNativeCode
Calculate the requirement from a native code header- Parameters:
header- the Bundle-NativeCode header or null- Returns:
- a Requirement Builder set to the requirements according tot he core spec
-
addRequireBundles
Add the Require-Bundle header -
addRequireBundle
Adds a new Require-Bundle requirement to this Processor's requirements list, specifying the bundle symbolic name and version range.- Parameters:
bsn- the bundle symbolic name to requirerange- the version range to require for the specified bundle
-
addRequireBundle
Adds a new Require-Bundle requirement to this Processor's requirements list, specifying the bundle symbolic name and any additional attributes.- Parameters:
bsn- the bundle symbolic name to requireattrs- the additional attributes for the requirement
-
addFragmentHost
Adds a new Fragment-Host requirement to this Processor's requirements list, specifying the host bundle symbolic name and any additional attributes.- Parameters:
bsn- the host bundle symbolic name to requireattrs- the additional attributes for the requirement
-
addRequireCapabilities
Adds one or more Require-Capability requirements to this Processor's requirements list, using the specified Parameters object to define the required capabilities.- Parameters:
required- the Parameters object containing the required capabilities and their attributes
-
addRequireCapability
Adds a new Require-Capability requirement to this Processor's requirements list, using the specified namespace, name, and attributes.- Parameters:
namespace- the namespace of the required capabilityname- the name of the required capability, or null if not applicableattrs- the additional attributes for the requirement
-
addRequireCapability
Adds a new Require-Capability requirement to this Processor's requirements list, using the specified namespace, name, version range, and attributes.- Parameters:
namespace- the namespace of the required capabilityname- the name of the required capability, or null if not applicableversionRange- the version range to require for the specified capability, or null if not applicableattrs- the additional attributes for the requirement
-
addProvideCapabilities
Adds one or more CapabilityBuilder objects to this Processor's capabilities list, using the specified Parameters object to define the provided capabilities.- Parameters:
capabilities- the Parameters object containing the provided capabilities and their attributes- Returns:
- a List of Capability objects that were added to the Processor's capabilities list
-
addProvideCapabilities
-
addProvideCapability
Adds a new CapabilityBuilder object to this Processor's capabilities list, representing a provided capability with the specified namespace and attributes.- Parameters:
namespace- the namespace of the provided capabilityattrs- the attributes for the provided capability- Returns:
- the Capability object that was added to the Processor's capabilities list
-
addExportPackages
Adds one or more Export-Package requirements to this Processor's requirements list, using the specified Parameters object to define the exported packages and their attributes.- Parameters:
exports- the Parameters object containing the exported packages and their attributes
-
addExportPackages
public void addExportPackages(Parameters exports, String bundle_symbolic_name, org.osgi.framework.Version bundle_version) Adds one or more Export-Package requirements to this Processor's requirements list, using the specified Parameters object to define the exported packages and their attributes, as well as the bundle symbolic name and version for the exporting bundle.- Parameters:
exports- the Parameters object containing the exported packages and their attributesbundle_symbolic_name- the symbolic name of the exporting bundlebundle_version- the version of the exporting bundle
-
addEE
Adds the Execution Environment information to this Processor's capabilities list and exported packages list.- Parameters:
ee- the EE object containing the Execution Environment information
-
addExportPackage
public void addExportPackage(String name, Attrs attrs, String bundle_symbolic_name, org.osgi.framework.Version bundle_version) Adds a new Export-Package requirement to this Processor's requirements list, representing an exported package with the specified name and attributes, and exporting by the specified bundle.- Parameters:
name- the name of the exported packageattrs- the attributes for the exported packagebundle_symbolic_name- the symbolic name of the exporting bundlebundle_version- the version of the exporting bundle
-
addExportPackage
Adds a new Export-Package requirement to this Processor's requirements list, representing an exported package with the specified name and attributes, and exporting by the current bundle.- Parameters:
name- the name of the exported packageattrs- the attributes for the exported package
-
addImportPackages
Add imported packages -
addImportPackage
-
addExecutionEnvironment
Deprecated. -
addAllExecutionEnvironments
Deprecated. -
copyCapabilities
-
addCapabilities
-
addRequirement
-
addRequirements
-
findCapabilities
-
from
public Map<org.osgi.resource.Capability, org.osgi.resource.Capability> from(org.osgi.resource.Resource bundle) -
getReporter
public aQute.service.reporter.Reporter getReporter() -
addContentCapability
-
addFile
-
addFile
-
parse
-
addJar
-
addManifest
-
addHashes
-
addHashes
-
safeResourceBuilder
-
addWorkspaceNamespace
A repository that implements theWorkspaceRepositoryMarkerin the resolver must add a WORKSPACE_NAMESPACE capability to make its clear the resources are from the workspace. Ideally this would not be necessary but we're having two workspace repositories. One for Bndtools where the repository is interactive, the other is for resolving in Gradle, etc.- Parameters:
name- the project name
-
toString
-
memoize
public static Supplier<org.osgi.resource.Resource> memoize(Jar jar, URI uri, String projectName) throws Exception Create a deferred resource builder so that any expensive actions are deferred until the supplier is called to get the resource.- Parameters:
jar- a Jar, preferably with checksum calculated, or nulluri- the uri to use or null (will use file uri as default)projectName- if in a workspace, the project name or otherwise null- Returns:
- a memo for creating the corresponding resource
- Throws:
Exception
-