Package org.apache.felix.bundlerepository

Examples of org.apache.felix.bundlerepository.RepositoryAdmin


        Object svcObj = getRepositoryAdmin();
        if (svcObj == null)
        {
            return;
        }
        RepositoryAdmin ra = (RepositoryAdmin) svcObj;

        Resolver resolver = ra.resolver();
        for (int argIdx = 0; (args != null) && (argIdx < args.length); argIdx++)
        {
            // Find the target's bundle resource.
            String targetName = args[argIdx];
            String targetVersion = null;
View Full Code Here


        Object svcObj = getRepositoryAdmin();
        if (svcObj == null)
        {
            return;
        }
        RepositoryAdmin ra = (RepositoryAdmin) svcObj;

        for (int argIdx = 0; argIdx < args.length; argIdx++)
        {
            // Find the target's bundle resource.
            String targetName = args[argIdx];
View Full Code Here

        Object svcObj = getRepositoryAdmin();
        if (svcObj == null)
        {
            return;
        }
        RepositoryAdmin ra = (RepositoryAdmin) svcObj;

        for (int argIdx = 0; argIdx < args.length; argIdx++)
        {
            // Find the target's bundle resource.
            String targetName = args[argIdx];
View Full Code Here

    public void refresh() throws Exception {
        generateRepository();

        ServiceReference ref = bundleContext.getServiceReference(RepositoryAdmin.class.getName());
        RepositoryAdmin repositoryAdmin = (RepositoryAdmin) bundleContext.getService(ref);
        try {
            repositoryAdmin.removeRepository(obrFile.toURI().toURL().toExternalForm());
            repositoryAdmin.addRepository(obrFile.toURI().toURL());
        } finally {
            bundleContext.ungetService(ref);
        }
    }
View Full Code Here

        return "mvn:" + artifact.getGroupId() + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + ("jar".equals(artifact.getType())"": "/" + artifact.getType());
    }

    private void registerRepositories() throws Exception {
        ServiceReference ref = bundleContext.getServiceReference(RepositoryAdmin.class.getName());
        RepositoryAdmin repositoryAdmin = (RepositoryAdmin) bundleContext.getService(ref);
        try {
            repositoryAdmin.addRepository(obrFile.toURI().toURL());
            for (URL repository : repositories) {
                repositoryAdmin.addRepository(repository);
            }
        } finally {
            bundleContext.ungetService(ref);
        }
    }
View Full Code Here

        }
    }

    private void unregisterRepositories() throws Exception {
        ServiceReference ref = bundleContext.getServiceReference(RepositoryAdmin.class.getName());
        RepositoryAdmin repositoryAdmin = (RepositoryAdmin) bundleContext.getService(ref);
        try {
            repositoryAdmin.removeRepository(obrFile.toURI().toURL().toExternalForm());
            for (URL repository : repositories) {
                repositoryAdmin.removeRepository(repository.toExternalForm());
            }
        } finally {
            bundleContext.ungetService(ref);
        }
    }
View Full Code Here

        final String requirement = "bundle:(&(symbolicname=org.apache.camel.camel-blueprint)(version>=2.4.0)(version<2.4.1))";

        final org.apache.karaf.features.internal.model.Feature f = new org.apache.karaf.features.internal.model.Feature("f1", "1.0");
        f.setResolver("obr");
        f.getBundle().add(new Bundle(requirement));
        final RepositoryAdmin admin = createMock(RepositoryAdmin.class);
        final Resolver resolver = createMock(Resolver.class);
        final Resource resource = createMock(Resource.class);
        final ObrResolver obrResolver = new ObrResolver();
        obrResolver.setRepositoryAdmin(admin);

        final Capture<Requirement> captureReq = new Capture<Requirement>();

        expect(admin.getHelper()).andReturn(new DataModelHelperImpl()).anyTimes();
        expect(admin.getSystemRepository()).andReturn(createMock(org.apache.felix.bundlerepository.Repository.class));
        expect(admin.getLocalRepository()).andReturn(createMock(org.apache.felix.bundlerepository.Repository.class));
        expect(admin.listRepositories()).andReturn(new org.apache.felix.bundlerepository.Repository[0]);
        expect(admin.resolver(EasyMock.<org.apache.felix.bundlerepository.Repository[]>anyObject())).andReturn(resolver);
        resolver.add(EasyMock.capture(captureReq));
        expect(resolver.resolve(Resolver.NO_OPTIONAL_RESOURCES)).andReturn(true);
        expect(resolver.getAddedResources()).andReturn(new Resource[] { });
        expect(resolver.getRequiredResources()).andReturn(new Resource[] { resource });
        expect(resolver.getReason(resource)).andAnswer(new IAnswer<Reason[]>() {
View Full Code Here

        final String requirement = "bundle:(&(symbolicname=org.apache.camel.camel-blueprint)(version>=2.4.0)(version<2.4.1))";

        final org.apache.karaf.features.internal.model.Feature f = new org.apache.karaf.features.internal.model.Feature("f1", "1.0");
        f.setResolver("obr");
        f.getBundle().add(new Bundle(requirement));
        final RepositoryAdmin admin = createMock(RepositoryAdmin.class);
        final Resolver resolver = createMock(Resolver.class);
        final Resource resource = createMock(Resource.class);
        final Resource optionalResource = createMock(Resource.class);
        final ObrResolver obrResolver = new ObrResolver();
        obrResolver.setRepositoryAdmin(admin);
        obrResolver.setResolveOptionalImports(true);

        final Capture<Requirement> captureReq = new Capture<Requirement>();

        expect(admin.getHelper()).andReturn(new DataModelHelperImpl()).anyTimes();
        expect(admin.getSystemRepository()).andReturn(createMock(org.apache.felix.bundlerepository.Repository.class));
        expect(admin.getLocalRepository()).andReturn(createMock(org.apache.felix.bundlerepository.Repository.class));
        expect(admin.listRepositories()).andReturn(new org.apache.felix.bundlerepository.Repository[0]);
        expect(admin.resolver(EasyMock.<org.apache.felix.bundlerepository.Repository[]>anyObject())).andReturn(resolver);
        resolver.add(EasyMock.capture(captureReq));
        expect(resolver.resolve()).andReturn(true);
        expect(resolver.getAddedResources()).andReturn(new Resource[] { });
        expect(resolver.getRequiredResources()).andReturn(new Resource[] { resource });
        expect(resolver.getOptionalResources()).andReturn(new Resource[] { optionalResource});
View Full Code Here

      final org.apache.karaf.features.internal.model.Feature f = new org.apache.karaf.features.internal.model.Feature("f1", "1.0");
        f.setResolver("obr");
        // Using file instead of mvn: as we do not want to mess with URL handlers
        f.getBundle().add(new Bundle("file:org.foo/foo/1.0"));

        final RepositoryAdmin admin = createMock(RepositoryAdmin.class);
        final Resolver resolver = createMock(Resolver.class);
        final Resource resource = createMock(Resource.class);
        final ObrResolver obrResolver = new ObrResolver();
        obrResolver.setRepositoryAdmin(admin);

        expect(admin.getHelper()).andReturn(new DummyDataModelHelper()).anyTimes();
        replay(admin, resolver, resource);

         obrResolver.resolve(f);
    }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testList() throws Exception {
    IMocksControl control = EasyMock.createControl();
    RepositoryAdmin repoAdmin = control.createMock(RepositoryAdmin.class);
    ListCommand command = new ListCommand();
    command.setRepoAdmin(repoAdmin);
   
    Resource[] resources = new Resource[] {
      createResource("My bundle", "my.bundle", "1.0.0"),
      createResource("My other Bundle", "org.apache.mybundle", "2.0.1")
    };
    EasyMock.expect(repoAdmin.discoverResources("(|(presentationname=*)(symbolicname=*))")).
      andReturn(resources);
   
    control.replay();
    command.execute(null);
    control.verify();
 
View Full Code Here

TOP

Related Classes of org.apache.felix.bundlerepository.RepositoryAdmin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.