Search in sources :

Example 6 with ApplicationMetadata

use of org.apache.aries.application.ApplicationMetadata in project aries by apache.

the class DeploymentManifestManagerImpl method generateDeploymentManifest.

/**
   * Perform provisioning to work out the 'freeze dried list' of the eba
   * @param app - Aries application
   * @param ResolveConstraint - resolver constraint for limiting the resolving results
   * @return manifest the generated deployment manifest
   * @throws ResolverException
   */
@Override
public Manifest generateDeploymentManifest(AriesApplication app, ResolveConstraint... constraints) throws ResolverException {
    _logger.debug(LOG_ENTRY, "generateDeploymentManifest", new Object[] { app, constraints });
    ApplicationMetadata appMetadata = app.getApplicationMetadata();
    Collection<ModelledResource> byValueBundles = null;
    try {
        // find out blueprint information
        byValueBundles = getByValueBundles(app);
    // find out by value bundles and then by reference bundles
    } catch (Exception e) {
        throw new ResolverException(e);
    }
    Collection<Content> bundlesToResolve = new ArrayList<Content>();
    bundlesToResolve.addAll(appMetadata.getApplicationContents());
    bundlesToResolve.addAll(app.getApplicationMetadata().getUseBundles());
    //If we pass in provision bundles (e.g. import deployment manifest sanity check), we add them into our bundlesToResolve set.
    // This is because we want to make sure all bundles we passed into resolver the same as what we are going to get from resolver. 
    List<Content> restrictedReqs = new ArrayList<Content>();
    for (ResolveConstraint constraint : constraints) {
        Content content = ContentFactory.parseContent(constraint.getBundleName(), constraint.getVersionRange().toString());
        restrictedReqs.add(content);
    }
    DeployedBundles deployedBundles = generateDeployedBundles(appMetadata, byValueBundles, restrictedReqs);
    Manifest man = generateDeploymentManifest(appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(), deployedBundles);
    _logger.debug(LOG_EXIT, "generateDeploymentManifest", new Object[] { man });
    return man;
}
Also used : ApplicationMetadata(org.apache.aries.application.ApplicationMetadata) ResolverException(org.apache.aries.application.management.ResolverException) ResolveConstraint(org.apache.aries.application.management.ResolveConstraint) Content(org.apache.aries.application.Content) ArrayList(java.util.ArrayList) DeployedBundles(org.apache.aries.application.modelling.DeployedBundles) Manifest(java.util.jar.Manifest) ResolverException(org.apache.aries.application.management.ResolverException) IOException(java.io.IOException) InvalidAttributeException(org.apache.aries.application.InvalidAttributeException) ServiceUnavailableException(org.osgi.service.blueprint.container.ServiceUnavailableException) ModellerException(org.apache.aries.application.modelling.ModellerException) ModelledResource(org.apache.aries.application.modelling.ModelledResource)

Example 7 with ApplicationMetadata

use of org.apache.aries.application.ApplicationMetadata in project aries by apache.

the class ManifestProcessorTest method testManifestMetadataWithMultiLineEntries.

/**
   * Check metadata can be extracted from a manifest that uses multiple lines
   * for a single manifest attribute.
   */
@Test
public void testManifestMetadataWithMultiLineEntries() throws Exception {
    ApplicationMetadataFactoryImpl manager = new ApplicationMetadataFactoryImpl();
    InputStream in = getClass().getClassLoader().getResourceAsStream("META-INF/APPLICATION2.MF");
    ApplicationMetadata am = manager.parseApplicationMetadata(in);
    assertNotNull(am);
    assertEquals(am.getApplicationName(), appName);
    //"com.travel.reservation.web;version=\"[1.1.0,1.2.0)\",com.travel.reservation.business",
    List<Content> contents = am.getApplicationContents();
    for (Content content : contents) {
        if ("com.travel.reservation.web".equals(content.getContentName())) {
            VersionRange vr = content.getVersion();
            assertEquals(vr.getMinimumVersion(), new Version("1.1.0"));
            assertEquals(vr.getMaximumVersion(), new Version("1.2.0"));
        } else if ("com.travel.reservation.business".equals(content.getContentName())) {
            VersionRange vr = content.getVersion();
            assertEquals(new Version(0, 0, 0), vr.getMinimumVersion());
        } else
            fail("Unexepcted content name " + content.getContentName());
    }
}
Also used : ApplicationMetadata(org.apache.aries.application.ApplicationMetadata) Version(org.osgi.framework.Version) InputStream(java.io.InputStream) Content(org.apache.aries.application.Content) VersionRange(org.apache.aries.util.VersionRange) ApplicationMetadataFactoryImpl(org.apache.aries.application.impl.ApplicationMetadataFactoryImpl) Test(org.junit.Test)

Example 8 with ApplicationMetadata

use of org.apache.aries.application.ApplicationMetadata in project aries by apache.

the class ManifestProcessorTest method testManifestMetadata.

/**
   * Check metadata can be extracted from a simple manifest.
   */
@Test
public void testManifestMetadata() throws Exception {
    ApplicationMetadataFactoryImpl manager = new ApplicationMetadataFactoryImpl();
    InputStream in = getClass().getClassLoader().getResourceAsStream("META-INF/APPLICATION.MF");
    ApplicationMetadata am = manager.parseApplicationMetadata(in);
    assertNotNull(am);
    assertEquals(am.getApplicationName(), appName);
    //"com.travel.reservation.web;version=\"[1.1.0,1.2.0)\",com.travel.reservation.business",
    List<Content> contents = am.getApplicationContents();
    for (Content content : contents) {
        if ("com.travel.reservation.web".equals(content.getContentName())) {
            VersionRange vr = content.getVersion();
            assertEquals(vr.getMinimumVersion(), new Version("1.1.0"));
            assertEquals(vr.getMaximumVersion(), new Version("1.2.0"));
        } else if ("com.travel.reservation.business".equals(content.getContentName())) {
            VersionRange vr = content.getVersion();
            assertEquals(new Version(0, 0, 0), vr.getMinimumVersion());
        } else
            fail("Unexepcted content name " + content.getContentName());
    }
}
Also used : ApplicationMetadata(org.apache.aries.application.ApplicationMetadata) Version(org.osgi.framework.Version) InputStream(java.io.InputStream) Content(org.apache.aries.application.Content) VersionRange(org.apache.aries.util.VersionRange) ApplicationMetadataFactoryImpl(org.apache.aries.application.impl.ApplicationMetadataFactoryImpl) Test(org.junit.Test)

Example 9 with ApplicationMetadata

use of org.apache.aries.application.ApplicationMetadata in project aries by apache.

the class ApplicationMetadataFactoryImpl method parseApplicationMetadata.

public ApplicationMetadata parseApplicationMetadata(InputStream in) throws IOException {
    Manifest man = ManifestProcessor.parseManifest(in);
    ApplicationMetadata metadata = new ApplicationMetadataImpl(man);
    return metadata;
}
Also used : ApplicationMetadata(org.apache.aries.application.ApplicationMetadata) Manifest(java.util.jar.Manifest)

Example 10 with ApplicationMetadata

use of org.apache.aries.application.ApplicationMetadata in project aries by apache.

the class ApplicationMetadataImplTest method testBasicMetadataCreation.

@Test
public void testBasicMetadataCreation() throws IOException {
    ApplicationMetadataFactory manager = new ApplicationMetadataFactoryImpl();
    ApplicationMetadata app = manager.parseApplicationMetadata(getClass().getResourceAsStream("/META-INF/APPLICATION.MF"));
    Assert.assertEquals("Travel Reservation", app.getApplicationName());
}
Also used : ApplicationMetadata(org.apache.aries.application.ApplicationMetadata) ApplicationMetadataFactory(org.apache.aries.application.ApplicationMetadataFactory) ApplicationMetadataFactoryImpl(org.apache.aries.application.impl.ApplicationMetadataFactoryImpl) Test(org.junit.Test)

Aggregations

ApplicationMetadata (org.apache.aries.application.ApplicationMetadata)12 Test (org.junit.Test)8 Content (org.apache.aries.application.Content)7 ApplicationMetadataFactoryImpl (org.apache.aries.application.impl.ApplicationMetadataFactoryImpl)5 Version (org.osgi.framework.Version)5 InputStream (java.io.InputStream)3 Manifest (java.util.jar.Manifest)3 DeploymentMetadata (org.apache.aries.application.DeploymentMetadata)3 BundleInfo (org.apache.aries.application.management.BundleInfo)3 ResolveConstraint (org.apache.aries.application.management.ResolveConstraint)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 ApplicationMetadataFactory (org.apache.aries.application.ApplicationMetadataFactory)2 DeploymentContent (org.apache.aries.application.DeploymentContent)2 ContentImpl (org.apache.aries.application.impl.ContentImpl)2 DeploymentContentImpl (org.apache.aries.application.impl.DeploymentContentImpl)2 AriesApplication (org.apache.aries.application.management.AriesApplication)2 ResolverException (org.apache.aries.application.management.ResolverException)2