Package org.apache.aries.application.management

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


  @Test
  public void testAppWithApplicationManifest() throws Exception {
    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
   
    HelloWorld hw = getOsgiService(HelloWorld.class);
    String result = hw.getMessage();
    assertEquals (result, "hello world");
   
    ctx.stop();
    manager.uninstall(ctx);
  }
View Full Code Here


  public AriesApplicationContext install(AriesApplication app) throws BundleException, ManagementException, ResolverException {
    if (!app.isResolved()) {
        app = resolve(app);
    }
    AriesApplicationContext result = _applicationContextManager.getApplicationContext(app);
    return result;
  }
View Full Code Here

    }
   
    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));
   
    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

  public synchronized AriesApplicationContext getApplicationContext(AriesApplication app)
      throws BundleException, ManagementException
  {
    LOGGER.debug(LOG_ENTRY, "getApplicationContext", app);
       
    AriesApplicationContext result;
    if (_appToContextMap.containsKey(app)) {
      result = _appToContextMap.get(app);
    } else {
      result = new ApplicationContextImpl(app, this);
      AriesApplicationContext previous = _appToContextMap.putIfAbsent(app, result);
      if (previous != null) {
        result = previous;
      }
    }
   
View Full Code Here

    String provision_bundle2 = "twitter4j";
    assertTrue("Bundle " + provision_bundle1 + " not found.", provisionBundleSymbolicNames.contains(provision_bundle1));
    assertTrue("Bundle " + provision_bundle2 + " not found.", provisionBundleSymbolicNames.contains(provision_bundle2));
    assertEquals(useBundles.toString(), 0, useBundles.size());
    assertEquals(appContent.toString(), 1, appContent.size());
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
  }
View Full Code Here

     
        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(Bundle.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(Bundle.ACTIVE, bbiz.getState());

        Bundle bper = getInstalledBundle("org.apache.aries.samples.blog.persistence.jdbc");
        assertNotNull(bper);
    assertEquals(Bundle.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 registered for " + bbiz.getSymbolicName(), isServiceRegistered(bbiz));
      assertTrue("No services registered 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/blog/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

     
  /* 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/blog/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"));
   
   
    //So Blog is working properly, let's quiesce it, we would expect to get a JPA and a Blueprint
    //participant
   
    QuiesceManager quiesceMgr = getOsgiService(QuiesceManager.class);
    List<Bundle> bundleList = new ArrayList<Bundle>();
    bundleList.add(bapi);
    quiesceMgr.quiesce(500,bundleList);
    Thread.sleep(1000);
   
    //blog api bundle should now be stopped, but others should still be running
    assertTrue("Blog api bundle should have been quiesced, but it's state is "+bapi.getState(), bapi.getState() != bapi.ACTIVE);
  assertEquals(bweb.ACTIVE, bweb.getState());
  assertEquals(bbiz.ACTIVE, bbiz.getState());
  assertEquals(bper.ACTIVE, bper.getState());
 
  bundleList.add(bweb);
  bundleList.add(bbiz);
  bundleList.add(bper);
 
  quiesceMgr.quiesce(500,bundleList);
    Thread.sleep(1000);
   
    //all blog bundles should now be stopped
    assertTrue("Blog api bundle should have been quiesced, but it's state is "+bapi.getState(), bapi.getState() != bapi.ACTIVE);
    assertTrue("Blog web bundle should have been quiesced, but it's state is "+bweb.getState(), bweb.getState() != bweb.ACTIVE);
    assertTrue("Blog biz bundle should have been quiesced, but it's state is "+bbiz.getState(), bbiz.getState() != bbiz.ACTIVE);
    assertTrue("Blog persistence bundle should have been quiesced, but it's state is "+bper.getState(), bper.getState() != bper.ACTIVE);
   
    //check we can start them again after quiesce and everything works as before
    bapi.start();
    bweb.start();
    bbiz.start();
    bper.start();

    /*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));
   
  conn = makeConnection("http://localhost:8080/blog/ViewBlog");
    response = getHTTPResponse(conn);

    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

     
  /* 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(Bundle.ACTIVE, bapi.getState());

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

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

  Bundle bper = getInstalledBundle("org.apache.aries.samples.blog.persistence.jpa");
    assertNotNull(bper);
  assertEquals(Bundle.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 registered for " + bbiz.getSymbolicName(), isServiceRegistered(bbiz));
  assertTrue("No services registered for " + bper.getSymbolicName(), isServiceRegistered(bper));
  assertTrue("No services registered for " + bds.getSymbolicName(), isServiceRegistered(bds));
  assertTrue("No services registered 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/blog/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

          " cannot be updated because it is not installed");
    }
   
    uninstall(oldCtx);
    try {
      AriesApplicationContext newCtx = getApplicationContext(app);
      if (oldCtx.getApplicationState() == ApplicationState.ACTIVE) {
        newCtx.start();
      }
     
      return newCtx;
    } catch (BundleException e) {
      throw new UpdateException("Update failed: "+e.getMessage(), e, false, null);
View Full Code Here

    LOGGER.debug("created app from {} : {} {} with contents {}", new Object[] {
        applicationLocation.getName(), appSymName, appVersion,
        app.getApplicationMetadata().getApplicationContents() });

    AriesApplicationContext context = applicationManager.install(app);

    LOGGER.debug("installed app {} {} state: {}", new Object[] {
        appSymName, appVersion,
        context.getApplicationState() });
   
    context.start();

    LOGGER.debug("started app {} {} state: {}", new Object[] {
        appSymName, appVersion,
        context.getApplicationState() });
   
    // Store the application context away because it is the application context we need
    // to pass to the application manager if we're later asked to uninstall the application
    appContexts.put(applicationLocation, context);
  }
View Full Code Here

TOP

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

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.