Search in sources :

Example 1 with ImportedBundleImpl

use of org.apache.aries.application.modelling.impl.ImportedBundleImpl in project aries by apache.

the class DeployedBundlesTest method getSimpleDeployedBundles.

private DeployedBundles getSimpleDeployedBundles(ternary a, ternary b, ternary c) throws InvalidAttributeException {
    Collection<ImportedBundle> content = new ArrayList<ImportedBundle>();
    Collection<ImportedBundle> uses = new ArrayList<ImportedBundle>();
    if (a == ternary.CONTENT)
        content.add(new ImportedBundleImpl("bundle.a", "1.0.0"));
    else if (a == ternary.USES)
        uses.add(new ImportedBundleImpl("bundle.a", "1.0.0"));
    if (b == ternary.CONTENT)
        content.add(new ImportedBundleImpl("bundle.b", "1.0.0"));
    else if (b == ternary.USES)
        uses.add(new ImportedBundleImpl("bundle.b", "1.0.0"));
    if (c == ternary.CONTENT)
        content.add(new ImportedBundleImpl("bundle.c", "1.0.0"));
    else if (c == ternary.USES)
        uses.add(new ImportedBundleImpl("bundle.c", "1.0.0"));
    // In a unit test we could go straight to the static method; choosing not to in this case. 
    return new ModellingHelperImpl().createDeployedBundles("test", content, uses, null);
}
Also used : ImportedBundleImpl(org.apache.aries.application.modelling.impl.ImportedBundleImpl) ArrayList(java.util.ArrayList) ImportedBundle(org.apache.aries.application.modelling.ImportedBundle) ModellingHelperImpl(org.apache.aries.application.modelling.utils.impl.ModellingHelperImpl)

Example 2 with ImportedBundleImpl

use of org.apache.aries.application.modelling.impl.ImportedBundleImpl in project aries by apache.

the class DeployedBundlesTest method validDeployedBundles.

private DeployedBundles validDeployedBundles() throws Exception {
    Collection<ImportedBundle> content = new ArrayList<ImportedBundle>();
    Collection<ImportedBundle> uses = new ArrayList<ImportedBundle>();
    content.add(new ImportedBundleImpl("bundle.a", "1.0.0"));
    content.add(new ImportedBundleImpl("bundle.b", "1.0.0"));
    uses.add(new ImportedBundleImpl("bundle.c", "1.0.0"));
    uses.add(new ImportedBundleImpl("bundle.d", "1.0.0"));
    return new ModellingHelperImpl().createDeployedBundles("test", content, uses, null);
}
Also used : ImportedBundleImpl(org.apache.aries.application.modelling.impl.ImportedBundleImpl) ArrayList(java.util.ArrayList) ImportedBundle(org.apache.aries.application.modelling.ImportedBundle) ModellingHelperImpl(org.apache.aries.application.modelling.utils.impl.ModellingHelperImpl)

Example 3 with ImportedBundleImpl

use of org.apache.aries.application.modelling.impl.ImportedBundleImpl in project aries by apache.

the class ModellingHelperImpl method buildFragmentHost_.

public static ImportedBundle buildFragmentHost_(String fragmentHostHeader) throws InvalidAttributeException {
    logger.debug(LOG_ENTRY, "buildFragmentHost_", new Object[] { fragmentHostHeader });
    if (fragmentHostHeader == null) {
        return null;
    }
    Map<String, Map<String, String>> parsedFragHost = ManifestHeaderProcessor.parseImportString(fragmentHostHeader);
    if (parsedFragHost.size() != 1)
        throw new InvalidAttributeException(MessageUtil.getMessage("MORE_THAN_ONE_FRAG_HOST", new Object[] { fragmentHostHeader }, "An internal error occurred. A bundle fragment manifest must define exactly one Fragment-Host entry. The following entry was found" + fragmentHostHeader + "."));
    String hostName = parsedFragHost.keySet().iterator().next();
    Map<String, String> attribs = parsedFragHost.get(hostName);
    String bundleVersion = attribs.remove(BUNDLE_VERSION_ATTRIBUTE);
    if (bundleVersion != null && attribs.get(VERSION_ATTRIBUTE) == null) {
        attribs.put(VERSION_ATTRIBUTE, bundleVersion);
    }
    attribs.put(ModellingConstants.OBR_SYMBOLIC_NAME, hostName);
    String filter = ManifestHeaderProcessor.generateFilter(attribs);
    ImportedBundle result = new ImportedBundleImpl(filter, attribs);
    logger.debug(LOG_EXIT, "buildFragmentHost_", result);
    return result;
}
Also used : InvalidAttributeException(org.apache.aries.application.InvalidAttributeException) ImportedBundleImpl(org.apache.aries.application.modelling.impl.ImportedBundleImpl) ImportedBundle(org.apache.aries.application.modelling.ImportedBundle) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ImportedBundle (org.apache.aries.application.modelling.ImportedBundle)3 ImportedBundleImpl (org.apache.aries.application.modelling.impl.ImportedBundleImpl)3 ArrayList (java.util.ArrayList)2 ModellingHelperImpl (org.apache.aries.application.modelling.utils.impl.ModellingHelperImpl)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 InvalidAttributeException (org.apache.aries.application.InvalidAttributeException)1