Search in sources :

Example 1 with BundleCapability

use of org.apache.ivy.osgi.core.BundleCapability in project ant-ivy by apache.

the class OBRXMLWriter method saxBundleInfo.

private static void saxBundleInfo(BundleInfo bundleInfo, ContentHandler handler) throws SAXException {
    AttributesImpl atts = new AttributesImpl();
    addAttr(atts, ResourceHandler.SYMBOLIC_NAME, bundleInfo.getSymbolicName());
    addAttr(atts, ResourceHandler.VERSION, bundleInfo.getRawVersion());
    for (BundleArtifact artifact : bundleInfo.getArtifacts()) {
        if (!artifact.isSource()) {
            addAttr(atts, ResourceHandler.URI, bundleInfo.getArtifacts().get(0).getUri().toString());
            break;
        }
    }
    handler.startElement("", ResourceHandler.RESOURCE, ResourceHandler.RESOURCE, atts);
    for (BundleArtifact artifact : bundleInfo.getArtifacts()) {
        if (artifact.isSource()) {
            startElement(handler, ResourceSourceHandler.SOURCE);
            characters(handler, artifact.getUri().toString());
            endElement(handler, ResourceSourceHandler.SOURCE);
            break;
        }
    }
    for (BundleCapability capability : bundleInfo.getCapabilities()) {
        saxCapability(capability, handler);
    }
    for (BundleRequirement requirement : bundleInfo.getRequirements()) {
        saxRequirement(requirement, handler);
    }
    handler.endElement("", ResourceHandler.RESOURCE, ResourceHandler.RESOURCE);
    handler.characters("\n".toCharArray(), 0, 1);
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) BundleArtifact(org.apache.ivy.osgi.core.BundleArtifact) BundleCapability(org.apache.ivy.osgi.core.BundleCapability) BundleRequirement(org.apache.ivy.osgi.core.BundleRequirement)

Example 2 with BundleCapability

use of org.apache.ivy.osgi.core.BundleCapability in project ant-ivy by apache.

the class CapabilityAdapter method getOSGiService.

private static BundleCapability getOSGiService(BundleInfo bundleInfo, Capability capability) throws ParseException {
    String name = null;
    Version version = null;
    for (CapabilityProperty property : capability.getProperties()) {
        String propName = property.getName();
        switch(propName) {
            case "service":
                name = property.getValue();
                break;
            case "version":
                version = new Version(property.getValue());
                break;
            default:
                Message.warn("Unsupported property '" + propName + "' on the 'package' capability of the bundle '" + bundleInfo.getSymbolicName() + "'");
                break;
        }
    }
    if (name == null) {
        throw new ParseException("No service name for the capability", 0);
    }
    return new BundleCapability(BundleInfo.SERVICE_TYPE, name, version);
}
Also used : Version(org.apache.ivy.osgi.util.Version) ParseException(java.text.ParseException) BundleCapability(org.apache.ivy.osgi.core.BundleCapability)

Example 3 with BundleCapability

use of org.apache.ivy.osgi.core.BundleCapability in project ant-ivy by apache.

the class EditableRepoDescriptor method addBundle.

public void addBundle(BundleInfo bundleInfo) {
    ModuleDescriptorWrapper module = findModule(bundleInfo.getSymbolicName(), bundleInfo.getVersion());
    if (module != null) {
        Message.debug("Duplicate module " + bundleInfo.getSymbolicName() + "@" + bundleInfo.getVersion());
        return;
    }
    ModuleDescriptorWrapper md = new ModuleDescriptorWrapper(bundleInfo, baseUri, profileProvider);
    add(BundleInfo.BUNDLE_TYPE, bundleInfo.getSymbolicName(), md);
    for (BundleCapability capability : bundleInfo.getCapabilities()) {
        add(capability.getType(), capability.getName(), md);
    }
}
Also used : BundleCapability(org.apache.ivy.osgi.core.BundleCapability)

Aggregations

BundleCapability (org.apache.ivy.osgi.core.BundleCapability)3 ParseException (java.text.ParseException)1 BundleArtifact (org.apache.ivy.osgi.core.BundleArtifact)1 BundleRequirement (org.apache.ivy.osgi.core.BundleRequirement)1 Version (org.apache.ivy.osgi.util.Version)1 AttributesImpl (org.xml.sax.helpers.AttributesImpl)1