Search in sources :

Example 1 with ModelledResourceManager

use of org.apache.aries.application.modelling.ModelledResourceManager in project aries by apache.

the class OBRResolverTest method generateOBRRepoXML.

private void generateOBRRepoXML(String... bundleFiles) throws Exception {
    Set<ModelledResource> mrs = new HashSet<ModelledResource>();
    FileOutputStream fout = new FileOutputStream("repository.xml");
    RepositoryGenerator repositoryGenerator = context().getService(RepositoryGenerator.class);
    ModelledResourceManager modelledResourceManager = context().getService(ModelledResourceManager.class);
    for (String fileName : bundleFiles) {
        File bundleFile = new File(fileName);
        IDirectory jarDir = FileSystem.getFSRoot(bundleFile);
        mrs.add(modelledResourceManager.getModelledResource(bundleFile.toURI().toString(), jarDir));
    }
    repositoryGenerator.generateRepository("Test repo description", mrs, fout);
    fout.close();
}
Also used : RepositoryGenerator(org.apache.aries.application.management.spi.repository.RepositoryGenerator) FileOutputStream(java.io.FileOutputStream) IDirectory(org.apache.aries.util.filesystem.IDirectory) ModelledResourceManager(org.apache.aries.application.modelling.ModelledResourceManager) File(java.io.File) HashSet(java.util.HashSet) ModelledResource(org.apache.aries.application.modelling.ModelledResource)

Example 2 with ModelledResourceManager

use of org.apache.aries.application.modelling.ModelledResourceManager in project aries by apache.

the class OBRResolverAdvancedTest method generateOBRRepoXML.

private void generateOBRRepoXML(boolean nullURI, String... bundleFiles) throws Exception {
    Set<ModelledResource> mrs = new HashSet<ModelledResource>();
    FileOutputStream fout = new FileOutputStream("repository.xml");
    RepositoryGenerator repositoryGenerator = context().getService(RepositoryGenerator.class);
    ModelledResourceManager modelledResourceManager = context().getService(ModelledResourceManager.class);
    for (String fileName : bundleFiles) {
        File bundleFile = new File(fileName);
        IDirectory jarDir = FileSystem.getFSRoot(bundleFile);
        String uri = "";
        if (!!!nullURI) {
            uri = bundleFile.toURI().toString();
        }
        if ("delete.jar".equals(fileName)) {
            jarDir = null;
        }
        mrs.add(modelledResourceManager.getModelledResource(uri, jarDir));
    }
    repositoryGenerator.generateRepository("Test repo description", mrs, fout);
    fout.close();
}
Also used : RepositoryGenerator(org.apache.aries.application.management.spi.repository.RepositoryGenerator) FileOutputStream(java.io.FileOutputStream) IDirectory(org.apache.aries.util.filesystem.IDirectory) ModelledResourceManager(org.apache.aries.application.modelling.ModelledResourceManager) File(java.io.File) HashSet(java.util.HashSet) ModelledResource(org.apache.aries.application.modelling.ModelledResource)

Example 3 with ModelledResourceManager

use of org.apache.aries.application.modelling.ModelledResourceManager in project aries by apache.

the class OBRResolverTest method createAndResolveSelfContainedApp.

private Collection<ModelledResource> createAndResolveSelfContainedApp(String extraImport) throws Exception {
    FileOutputStream fout = new FileOutputStream(new File("a.bundle.jar"));
    ArchiveFixture.newJar().manifest().attribute(BUNDLE_SYMBOLICNAME, "a.bundle").attribute(BUNDLE_VERSION, "1.0.0").attribute(BUNDLE_MANIFESTVERSION, "2").attribute(IMPORT_PACKAGE, "a.pack.age").end().writeOut(fout);
    fout.close();
    fout = new FileOutputStream(new File("b.bundle.jar"));
    ArchiveFixture.newJar().manifest().attribute(BUNDLE_SYMBOLICNAME, "b.bundle").attribute(BUNDLE_VERSION, "1.0.0").attribute(BUNDLE_MANIFESTVERSION, "2").attribute(IMPORT_PACKAGE, extraImport).attribute(EXPORT_PACKAGE, "a.pack.age").end().writeOut(fout);
    fout.close();
    ModelledResourceManager mrm = context().getService(ModelledResourceManager.class);
    ModelledResource aBundle = mrm.getModelledResource(FileSystem.getFSRoot(new File("a.bundle.jar")));
    ModelledResource bBundle = mrm.getModelledResource(FileSystem.getFSRoot(new File("b.bundle.jar")));
    AriesApplicationResolver resolver = context().getService(AriesApplicationResolver.class);
    return resolver.resolveInIsolation("test.app", "1.0.0", Arrays.asList(aBundle, bBundle), Arrays.<Content>asList(ContentFactory.parseContent("a.bundle", "1.0.0"), ContentFactory.parseContent("b.bundle", "1.0.0")));
}
Also used : FileOutputStream(java.io.FileOutputStream) AriesApplicationResolver(org.apache.aries.application.management.spi.resolve.AriesApplicationResolver) File(java.io.File) ModelledResourceManager(org.apache.aries.application.modelling.ModelledResourceManager) ModelledResource(org.apache.aries.application.modelling.ModelledResource)

Aggregations

File (java.io.File)3 FileOutputStream (java.io.FileOutputStream)3 ModelledResource (org.apache.aries.application.modelling.ModelledResource)3 ModelledResourceManager (org.apache.aries.application.modelling.ModelledResourceManager)3 HashSet (java.util.HashSet)2 RepositoryGenerator (org.apache.aries.application.management.spi.repository.RepositoryGenerator)2 IDirectory (org.apache.aries.util.filesystem.IDirectory)2 AriesApplicationResolver (org.apache.aries.application.management.spi.resolve.AriesApplicationResolver)1