Package org.apache.felix.bundlerepository

Examples of org.apache.felix.bundlerepository.RepositoryAdmin


        if (ref == null) {
            System.out.println("RepositoryAdmin service is unavailable.");
            return null;
        }
        try {
            RepositoryAdmin admin = (RepositoryAdmin) getBundleContext().getService(ref);
            if (admin == null) {
                System.out.println("RepositoryAdmin service is unavailable.");
                return null;
            }
View Full Code Here


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

        final FeatureImpl f = new FeatureImpl("f1", "1.0");
        f.setResolver("obr");
        f.addBundle(new BundleInfoImpl(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.getRequiredResources()).andReturn(new Resource[] { resource });
        expect(resolver.getReason(resource)).andAnswer(new IAnswer() {
            public Object answer() throws Throwable {
View Full Code Here

        // lookup on the OBR RepositoryAdmin service
        ServiceReference repositoryAdminReference = bundleContext.getServiceReference(RepositoryAdmin.class.getName());
        if (repositoryAdminReference == null) {
            throw new ServletException("OBR repository admin service is not available");
        }
        RepositoryAdmin repositoryAdmin = (RepositoryAdmin) bundleContext.getService(repositoryAdminReference);
        if (repositoryAdmin == null) {
            bundleContext.ungetService(repositoryAdminReference);
            throw new ServletException("OBR repository admin service is not available");
        }

        String uri = request.getPathInfo();

        // remove the starting /
        uri = uri.substring(1);

        // listing the repositories
        if (request.getParameter("repositories") != null) {
            ServiceReference caveRepositoryServiceReference = bundleContext.getServiceReference(CaveRepositoryService.class.getName());
            if (caveRepositoryServiceReference != null) {
                CaveRepositoryService caveRepositoryService = (CaveRepositoryService) bundleContext.getService(caveRepositoryServiceReference);
                if (caveRepositoryService != null) {
                    CaveRepository[] caveRepositories = caveRepositoryService.getRepositories();
                    response.setContentType("text/plain");
                    PrintWriter writer = response.getWriter();
                    for (CaveRepository caveRepository : caveRepositories) {
                        writer.println(caveRepository.getName());
                    }
                    writer.flush();
                    writer.close();
                }
                bundleContext.ungetService(caveRepositoryServiceReference);
            }
            return;
        }

        // wrapping content (repository.xml or directly artifacts)
        try {
            URL url = null;

            if (uri.endsWith("-repository.xml")) {
                // the user wants to get the Cave repository repository.xml
                // the expected format is {cave-repo-name}-repository.xml
                int index = uri.indexOf("-repository.xml");
                String caveRepositoryName = uri.substring(0, index);

                ServiceReference caveRepositoryServiceReference = bundleContext.getServiceReference(CaveRepositoryService.class.getName());
                if (caveRepositoryServiceReference != null) {
                    CaveRepositoryService caveRepositoryService = (CaveRepositoryService) bundleContext.getService(caveRepositoryServiceReference);
                    if (caveRepositoryService != null) {
                        CaveRepository caveRepository = caveRepositoryService.getRepository(caveRepositoryName);
                        if (caveRepository != null) {
                            url = caveRepository.getRepositoryXml();
                            response.setContentType("text/xml");
                        }
                    }
                    bundleContext.ungetService(caveRepositoryServiceReference);
                }
            } else {
                Resource[] resources = repositoryAdmin.discoverResources("(uri=*" + uri + ")");
                if (resources.length == 0) {
                    throw new ServletException("No resource found with URI " + uri);
                }
                if (resources.length > 1) {
                    throw new ServletException("Multiple resources found with URI " + uri);
View Full Code Here

  {
    // do not provision against the local runtime
    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "true");
    generateOBRRepoXML(false, TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + "_0.0.0.jar",  USE_BUNDLE_BY_REFERENCE+".jar");
   
    RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
   
    Repository[] repos = repositoryAdmin.listRepositories();
    for (Repository repo : repos) {
      repositoryAdmin.removeRepository(repo.getURI());
    }
   
    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());

    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("demo.eba")));
   
    app = manager.resolve(app);
View Full Code Here

  {
    // do not provision against the local runtime
    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "true");
    generateOBRRepoXML(false, TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + ".jar", USE_BUNDLE_BY_REFERENCE+".jar");
   
    RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
   
    Repository[] repos = repositoryAdmin.listRepositories();
    for (Repository repo : repos) {
      repositoryAdmin.removeRepository(repo.getURI());
    }
   
    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());

    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("demo.eba")));
    //installing requires a valid url for the bundle in repository.xml.
   
View Full Code Here

  public void testMutlipleServices() throws Exception{
    // provision against the local runtime
    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");
    generateOBRRepoXML(false, HELLO_WORLD_SERVICE_BUNDLE1 + ".jar", HELLO_WORLD_SERVICE_BUNDLE2 + ".jar");
   
    RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
   
    Repository[] repos = repositoryAdmin.listRepositories();
    for (Repository repo : repos) {
      repositoryAdmin.removeRepository(repo.getURI());
    }
   
    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());

    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("hello.eba")));
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
View Full Code Here

  @Test
  public void testTwitter() throws Exception
  {
    // provision against the local runtime
    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");
    RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
    Repository[] repos = repositoryAdmin.listRepositories();
    for (Repository repo : repos) {
      repositoryAdmin.removeRepository(repo.getURI());
    }

   
    // Use the superclasses' getUrlToEba() method instead of the pax-exam mavenBundle() method because pax-exam is running in a
    // diffference bundle which doesn't have visibility to the META-INF/maven/dependencies.properties file used to figure out the
    // version of the maven artifact.
    URL twitterEbaUrl = getUrlToEba("org.apache.aries.application.itest.twitter",
        "org.apache.aries.application.itest.twitter.eba");
    URL twitterCommonLangJar_url = getUrlToBundle("commons-lang", "commons-lang");
    URL twitterJar_url = getUrlToBundle("org.apache.aries.application", "twitter4j");
  
    // add the repository xml to the repository admin
    StringBuilder repositoryXML = new StringBuilder();
    BufferedReader reader = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("/obr/twitter/TwitterRepository.xml")));
    String line;
    while ((line = reader.readLine()) != null) {
      repositoryXML.append(line);
      repositoryXML.append("\r\n");
    }
  //replace the jar file url with the real url related to the environment
    String repo = repositoryXML.toString().replaceAll("commons.lang.location", twitterCommonLangJar_url.toExternalForm());
    repo = repo.replaceAll("twitter4j.location", twitterJar_url.toExternalForm());
   
    FileWriter writer = new FileWriter("twitterRepo.xml");
    writer.write(repo);
    writer.close();
    repositoryAdmin.addRepository(new File("twitterRepo.xml").toURI().toURL());
    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(twitterEbaUrl);
    app = manager.resolve(app);
    DeploymentMetadata depMeta = app.getDeploymentMetadata();
    List<DeploymentContent> provision = depMeta.getApplicationProvisionBundles();
View Full Code Here

    fout.close();
  }

  @After
  public void clearRepository() {
    RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
    Repository[] repos = repositoryAdmin.listRepositories();
    if ((repos != null) && (repos.length >0)) {
      for (Repository repo : repos) {
        repositoryAdmin.removeRepository(repo.getURI());
      }
    }
  }
View Full Code Here

    AppMgrClientBlueprintListener acbl = new AppMgrClientBlueprintListener();
    ServiceRegistration sr = bundleContext.registerService("org.osgi.service.blueprint.container.BlueprintListener", acbl, null);

    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("appmgrclienttest.eba")));
    RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);

    Repository[] repos = repositoryAdmin.listRepositories();
    for (Repository repo : repos) {
      repositoryAdmin.removeRepository(repo.getURI());
    }

    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());

    AriesApplicationContext ctx = manager.install(app);
    ctx.start();

    int sleepfor = 3000;
View Full Code Here

    }

    @Test
    public void testAppWithApplicationManifest() throws Exception {
     
      RepositoryAdmin repositoryAdmin = getOsgiService(RepositoryAdmin.class);
     
      repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());

      Repository[] repos = repositoryAdmin.listRepositories();
     
      for (Repository repo : repos) {
        Resource[] resources = repo.getResources();
       
        for (Resource r : resources) {
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.