Package org.apache.aries.application.management

Examples of org.apache.aries.application.management.AriesApplicationManager


    @Test
    public void test() throws Exception {
 
  /* Install and start the blog eba */
  URL urlToEba = getUrlToEba("org.apache.aries.samples.blog", "org.apache.aries.samples.blog.jpa.eba");
  AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
  AriesApplication app = manager.createApplication(urlToEba);
  AriesApplicationContext ctx = manager.install(app);
  ctx.start();

    /* Find and check all the blog sample bundles */

  Bundle bapi = getInstalledBundle("org.apache.aries.samples.blog.api");
    assertNotNull(bapi);
  assertEquals(bapi.ACTIVE, bapi.getState());

  Bundle bweb = getInstalledBundle("org.apache.aries.samples.blog.web");
    assertNotNull(bweb);
  assertEquals(bweb.ACTIVE, bweb.getState());

  Bundle bbiz = getInstalledBundle("org.apache.aries.samples.blog.biz");
    assertNotNull(bbiz);
  assertEquals(bbiz.ACTIVE, bbiz.getState());

  Bundle bper = getInstalledBundle("org.apache.aries.samples.blog.persistence.jpa");
    assertNotNull(bper);
  assertEquals(bper.ACTIVE, bper.getState());
    /* Datasource and transaction manager services are used by the blog sample */
  Bundle bds = getInstalledBundle("org.apache.aries.samples.blog.datasource");
  Bundle txs = getInstalledBundle("org.apache.aries.transaction.manager");

    /*Wait for all the required services to be registered */
    waitForServices(bbiz, "org.apache.aries.samples.blog.api.BloggingService");
    waitForServices(bper, "org.apache.aries.samples.blog.api.persistence.BlogPersistenceService");
    waitForServices(bds, "javax.sql.XADataSource");
    waitForServices(txs, "javax.transaction.TransactionManager");


    /*Check that they haven't timed out trying to register*/
  assertTrue("No services reistered for " + bbiz.getSymbolicName(), isServiceRegistered(bbiz));
  assertTrue("No services reistered for " + bper.getSymbolicName(), isServiceRegistered(bper));
  assertTrue("No services reistered for " + bds.getSymbolicName(), isServiceRegistered(bds));
  assertTrue("No services reistered for " + txs.getSymbolicName(), isServiceRegistered(txs));

  /*Check what services are registered - uncomment for additional debug */
  /*
  listBundleServices(bbiz);
  listBundleServices(bper);
  listBundleServices(bds);
  listBundleServices(txs);
   
  System.out.println("In test and trying to get connection....");
  */

  HttpURLConnection conn = makeConnection("http://localhost:8080/org.apache.aries.samples.blog.web/ViewBlog");
    String response = getHTTPResponse(conn);

  /* Uncomment for additional debug */
  /*
  System.out.println("ZZZZZ " + response);
    System.out.println("ZZZZZ " + conn.getResponseCode());
    System.out.println("ZZZZZ " + HttpURLConnection.HTTP_OK);
  */


    assertEquals(HttpURLConnection.HTTP_OK,
        conn.getResponseCode());

    assertTrue("The response did not contain the expected content", response.contains("Blog home"));
  ctx.stop();
    manager.uninstall(ctx);

    }
View Full Code Here


    @Test
    public void test() throws Exception {

        URL urlToEba = getUrlToEba("org.apache.aries.samples.blog", "org.apache.aries.samples.blog.jdbc.eba");

        AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
        AriesApplication app = manager.createApplication(urlToEba);
        AriesApplicationContext ctx = manager.install(app);
        ctx.start();

    /* Check that the Blog Sample bundles are present an started */
        Bundle bapi = getInstalledBundle("org.apache.aries.samples.blog.api");
        assertNotNull(bapi);
    assertEquals(bapi.ACTIVE, bapi.getState());

        Bundle bweb = getInstalledBundle("org.apache.aries.samples.blog.web");
        assertNotNull(bweb);

        Bundle bbiz = getInstalledBundle("org.apache.aries.samples.blog.biz");
        assertNotNull(bbiz);
    assertEquals(bbiz.ACTIVE, bbiz.getState());

        Bundle bper = getInstalledBundle("org.apache.aries.samples.blog.persistence.jdbc");
        assertNotNull(bper);
    assertEquals(bper.ACTIVE, bper.getState());

        /* Require services from biz and persistence - wait for them to register */
        waitForServices(bbiz, "org.apache.aries.samples.blog.api.BloggingService");
        waitForServices(bper, "org.apache.aries.samples.blog.api.persistence.BlogPersistenceService");

       /*Check that they haven't timed out trying to register*/
      assertTrue("No services reistered for " + bbiz.getSymbolicName(), isServiceRegistered(bbiz));
      assertTrue("No services reistered for " + bper.getSymbolicName(), isServiceRegistered(bper));

    /*Check what services are registered - uncomment for additional debug */
    /*
      listBundleServices(bbiz);
      listBundleServices(bper);

      System.out.println("In test and trying to get connection....");
    */
        HttpURLConnection conn = makeConnection("http://localhost:8080/org.apache.aries.samples.blog.web/ViewBlog");
        String response = getHTTPResponse(conn);
    /* Uncomment for additional debug */
    /*
        System.out.println("ZZZZZ " + response);
        System.out.println("ZZZZZ " + conn.getResponseCode());
        System.out.println("ZZZZZ " + HttpURLConnection.HTTP_OK);
    */

        assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());

        assertTrue("The response did not contain the expected content",
                response.contains("Blog home"));

        ctx.stop();
        manager.uninstall(ctx);
    }
View Full Code Here

        IDirectory in = FileSystem.getFSRoot(sourceApplication);
        if (in == null) {
            System.err.println("File not found: " + applicationPath);
            return in;
        }
        AriesApplicationManager manager = getAriesApplicationManager();
        AriesApplication application = manager.createApplication(in);
       
        if (application.isResolved()) {
            System.out.println("Application " + application.getApplicationMetadata().getApplicationSymbolicName() + " is already resolved.");
        } else {
            System.out.println("Attempting to resolve " + application.getApplicationMetadata().getApplicationSymbolicName() + " application.");
           
            AriesApplication resolved = manager.resolve(application);
            File targetApplication = null;
            if (resovledApplicationPath == null) {
                String baseName = null;
                if (applicationPath.endsWith(".eba")) {
                    baseName = applicationPath.substring(0, applicationPath.length() - 4);
View Full Code Here

                                                Collection<ConfigurationStore> configurationStores,
                                                ArtifactResolver artifactResolver,
                                                ConfigurationStore targetConfigurationStore)
        throws IOException, DeploymentException {

        AriesApplicationManager appManager = getAriesApplicationManager();

        AriesApplication app = null;
        try {
            app = appManager.createApplication(FileSystem.getFSRoot(new File(jarFile.getName())));
        } catch (Exception e) {
            throw new DeploymentException("Error creating Aries Application", e);
        }

        if (!app.isResolved() && getResolveOnDeploy()) {
            try {
                app = appManager.resolve(app);
            } catch (Exception e) {
                throw new DeploymentException("Error resolving Aries Application", e);
            }
        }
View Full Code Here

        }
        return service;
    }
   
    private AriesApplicationManager getAriesApplicationManager() throws ManagementException {
        AriesApplicationManager service = (AriesApplicationManager) applicationManagerTracker.getService();
        if (service == null) {
            throw new ManagementException(new ServiceException(AriesApplicationManager.class.getName(), ServiceException.UNREGISTERED));          
        }
        return service;
    }
View Full Code Here

      repositoryAdmin.removeRepository(repo.getURI());
    }
   
    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());

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

      repositoryAdmin.removeRepository(repo.getURI());
    }
   
    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());

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

      repositoryAdmin.removeRepository(repo.getURI());
    }
   
    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());

    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("blog.eba")));
    //installing requires a valid url for the bundle in repository.xml.
   
    app = manager.resolve(app);
   
    DeploymentMetadata depMeta = app.getDeploymentMetadata();
   
    List<DeploymentContent> provision = depMeta.getApplicationProvisionBundles();
   
    assertEquals(provision.toString(), 3, provision.size());
   
    List<String> bundleSymbolicNames = new ArrayList<String>();
   
    for (DeploymentContent dep : provision) {
      bundleSymbolicNames.add(dep.getContentName());
    }
   
    assertTrue("Bundle " + TRANSITIVE_BUNDLE_BY_REFERENCE + " not found.", bundleSymbolicNames.contains(TRANSITIVE_BUNDLE_BY_REFERENCE));
    assertTrue("Bundle " + TRANSITIVE_BUNDLE_BY_VALUE + " not found.", bundleSymbolicNames.contains(TRANSITIVE_BUNDLE_BY_VALUE));
    assertTrue("Bundle " + BUNDLE_IN_FRAMEWORK + " not found.", bundleSymbolicNames.contains(BUNDLE_IN_FRAMEWORK));
   
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();

    Set<Bundle> bundles = ctx.getApplicationContent();
   
    assertEquals("Number of bundles provisioned in the app", 4, bundles.size());
   
    ctx.stop();
    manager.uninstall(ctx);
  }
View Full Code Here

    createdApplications = true;
  }
 
  @Test
  public void testFullUpdate() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = setupApp();
   
    updateApp(manager, app);

    assertAppMessage("hello brave new world");
View Full Code Here

    assertAppMessage("hello brave new world");
  }
 
  @Test
  public void testFineUpdate() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = setupApp();
   
    BundleContext oldCtx = IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, SAMPLE_APP_NAME);
   
    installMockUpdateStrategy();
View Full Code Here

TOP

Related Classes of org.apache.aries.application.management.AriesApplicationManager

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.