Examples of QuiesceParticipant


Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

  System.out.println("In testBasicQuieseEmptyCounter");
  Object obj = context().getService(TestBean.class);
 
  if (obj != null)
  {
    QuiesceParticipant participant = getParticipant("org.apache.aries.blueprint");
   
    if (participant != null)
    {
      System.out.println(obj.getClass().getName());

      TestQuiesceCallback callback = new TestQuiesceCallback();
     
      Bundle bundle = getBundle("org.apache.aries.blueprint.testquiescebundle");
     
      System.out.println("Got the bundle");
     
      List<Bundle> bundles = new ArrayList<Bundle>();
      bundles.add(bundle);
     
      Thread t = new Thread(new TestBeanClient((TestBean)obj, 2000));
      t.start();

      System.out.println("Thread Started");
     
      participant.quiesce(callback, bundles);
     
      System.out.println("Called Quiesce");
     
      Thread.sleep(1000);
     
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

   System.out.println("In testNoServicesQuiesce");
  Object obj = context().getService(TestBean.class);
 
  if (obj != null)
  {   
    QuiesceParticipant participant = getParticipant("org.apache.aries.blueprint");
   
    if (participant != null)
    {
      TestQuiesceCallback callbackA = new TestQuiesceCallback();
      TestQuiesceCallback callbackB = new TestQuiesceCallback();
       
      //bundlea provides the ns handlers, bean processors, interceptors etc for this test.
          Bundle bundlea = getBundle("org.apache.aries.blueprint.testbundlea");
          assertNotNull(bundlea);
          bundlea.start();
         
          //bundleb has no services and makes use of the extensions provided by bundlea
          Bundle bundleb = getBundle("org.apache.aries.blueprint.testbundleb");
          assertNotNull(bundleb);
          bundleb.start();
         
          Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.blueprint.testbundleb");
         
      participant.quiesce(callbackB, Collections.singletonList(getBundle(
        "org.apache.aries.blueprint.testbundleb")));
     
        System.out.println("Called Quiesce");
       
        Thread.sleep(200);
       
        Assert.assertTrue("Quiesce callback B should have occurred; calls should be 1, but it is "+callbackB.getCalls(), callbackB.getCalls()==1);
        Assert.assertTrue("Quiesce callback A should not have occurred yet; calls should be 0, but it is "+callbackA.getCalls(), callbackA.getCalls()==0);
       
        bundleb.stop();
       
        participant.quiesce(callbackA, Collections.singletonList(getBundle(
      "org.apache.aries.blueprint.testbundlea")));
           
        Thread.sleep(1000);
       
        System.out.println("After second sleep");
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

   System.out.println("In testMultiBundleQuiesce");
  Object obj = context().getService(TestBean.class);
 
  if (obj != null)
  {   
    QuiesceParticipant participant = getParticipant("org.apache.aries.blueprint");
   
    if (participant != null)
    {
      TestQuiesceCallback callback = new TestQuiesceCallback();
       
      //bundlea provides the ns handlers, bean processors, interceptors etc for this test.
          Bundle bundlea = getBundle("org.apache.aries.blueprint.testbundlea");
          assertNotNull(bundlea);
          bundlea.start();
         
          //quiesce bundle will sleep for a second so will quiesce after that
        Bundle bundleq = getBundle("org.apache.aries.blueprint.testquiescebundle");
       
        System.out.println("Got the bundle");
       
        List<Bundle> bundles = new ArrayList<Bundle>();
        bundles.add(bundlea);
        bundles.add(bundleq);
       
        Thread t = new Thread(new TestBeanClient((TestBean)obj, 1500));
        t.start();
        Thread.sleep(200);
         
        participant.quiesce(callback, bundles);
     
        System.out.println("Called Quiesce");
       
        Thread.sleep(500);
       
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

   System.out.println("In testMultiRequestQuiesce");
  Object obj = context().getService(TestBean.class);
 
  if (obj != null)
  {   
    QuiesceParticipant participant = getParticipant("org.apache.aries.blueprint");
   
    if (participant != null)
    {
      TestQuiesceCallback callback = new TestQuiesceCallback();
      TestBeanClient client =  new TestBeanClient((TestBean)obj, 1500);
       

          //quiesce bundle will sleep for a second so will quiesce after that
        Bundle bundle = getBundle("org.apache.aries.blueprint.testquiescebundle");
       
        System.out.println("Got the bundle");
       
        List<Bundle> bundles = new ArrayList<Bundle>();
        bundles.add(bundle);
       
        Thread t = new Thread(client);
        t.start();
         
      participant.quiesce(callback, bundles);
     
        System.out.println("Called Quiesce, putting in a new request");
       
        Thread t2 = new Thread(client);
        t2.start();
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

  System.out.println("In testBasicQuieseEmptyCounter");
  Object obj = getOsgiService(TestBean.class);
 
  if (obj != null)
  {
    QuiesceParticipant participant = getParticipant("org.apache.aries.blueprint");
   
    if (participant != null)
    {
      System.out.println(obj.getClass().getName());

      TestQuiesceCallback callback = new TestQuiesceCallback();
     
      Bundle bundle = getBundle("org.apache.aries.blueprint.testquiescebundle");
     
      System.out.println("Got the bundle");
     
      List<Bundle> bundles = new ArrayList<Bundle>();
      bundles.add(bundle);
     
      Thread t = new Thread(new TestBeanClient((TestBean)obj, 2000));
      t.start();

      System.out.println("Thread Started");
     
      participant.quiesce(callback, bundles);
     
      System.out.println("Called Quiesce");
     
      Thread.sleep(1000);
     
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

   System.out.println("In testNoServicesQuiesce");
  Object obj = getOsgiService(TestBean.class);
 
  if (obj != null)
  {   
    QuiesceParticipant participant = getParticipant("org.apache.aries.blueprint");
   
    if (participant != null)
    {
      TestQuiesceCallback callbackA = new TestQuiesceCallback();
      TestQuiesceCallback callbackB = new TestQuiesceCallback();
       
      //bundlea provides the ns handlers, bean processors, interceptors etc for this test.
          Bundle bundlea = getBundle("org.apache.aries.blueprint.testbundlea");
          assertNotNull(bundlea);
          bundlea.start();
         
          //bundleb has no services and makes use of the extensions provided by bundlea
          Bundle bundleb = getBundle("org.apache.aries.blueprint.testbundleb");
          assertNotNull(bundleb);
          bundleb.start();
         
      participant.quiesce(callbackB, Collections.singletonList(getBundle(
        "org.apache.aries.blueprint.testbundleb")));
     
        System.out.println("Called Quiesce");
       
        Thread.sleep(200);
       
        Assert.assertTrue("Quiesce callback B should have occurred; calls should be 1, but it is "+callbackB.getCalls(), callbackB.getCalls()==1);
        Assert.assertTrue("Quiesce callback A should not have occurred yet; calls should be 0, but it is "+callbackA.getCalls(), callbackA.getCalls()==0);
       
        participant.quiesce(callbackA, Collections.singletonList(getBundle(
      "org.apache.aries.blueprint.testbundlea")));
           
        Thread.sleep(1000);
       
        System.out.println("After second sleep");
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

   System.out.println("In testMultiBundleQuiesce");
  Object obj = getOsgiService(TestBean.class);
 
  if (obj != null)
  {   
    QuiesceParticipant participant = getParticipant("org.apache.aries.blueprint");
   
    if (participant != null)
    {
      TestQuiesceCallback callback = new TestQuiesceCallback();
       
      //bundlea provides the ns handlers, bean processors, interceptors etc for this test.
          Bundle bundlea = getBundle("org.apache.aries.blueprint.testbundlea");
          assertNotNull(bundlea);
          bundlea.start();
         
          //quiesce bundle will sleep for a second so will quiesce after that
        Bundle bundleq = getBundle("org.apache.aries.blueprint.testquiescebundle");
       
        System.out.println("Got the bundle");
       
        List<Bundle> bundles = new ArrayList<Bundle>();
        bundles.add(bundlea);
        bundles.add(bundleq);
       
        Thread t = new Thread(new TestBeanClient((TestBean)obj, 1500));
        t.start();
        Thread.sleep(200);
         
      participant.quiesce(callback, bundles);
     
        System.out.println("Called Quiesce");
       
        Thread.sleep(500);
       
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

   System.out.println("In testMultiRequestQuiesce");
  Object obj = getOsgiService(TestBean.class);
 
  if (obj != null)
  {   
    QuiesceParticipant participant = getParticipant("org.apache.aries.blueprint");
   
    if (participant != null)
    {
      TestQuiesceCallback callback = new TestQuiesceCallback();
      TestBeanClient client =  new TestBeanClient((TestBean)obj, 1500);
       

          //quiesce bundle will sleep for a second so will quiesce after that
        Bundle bundle = getBundle("org.apache.aries.blueprint.testquiescebundle");
       
        System.out.println("Got the bundle");
       
        List<Bundle> bundles = new ArrayList<Bundle>();
        bundles.add(bundle);
       
        Thread t = new Thread(client);
        t.start();
         
      participant.quiesce(callback, bundles);
     
        System.out.println("Called Quiesce, putting in a new request");
       
        Thread t2 = new Thread(client);
        t2.start();
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
   
   
    //Quiesce it
    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container.context");
   
    TestQuiesceCallback callback = new TestQuiesceCallback();
   
    participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
   
    Thread.sleep(1000);
   
    assertTrue("Quiesce not finished", callback.bundleClearedUp());
View Full Code Here

Examples of org.apache.aries.quiesce.participant.QuiesceParticipant

   
    tm.begin();
   
    emf.createEntityManager().getProperties();
   
    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container.context");
   
    TestQuiesceCallback callback = new TestQuiesceCallback();
   
    participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
   
    Thread.sleep(1000);
   
    assertFalse("Quiesce finished", callback.bundleClearedUp());
   
    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)("
        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
   
    tm.commit();
   
    assertTrue("Quiesce not finished", callback.bundleClearedUp());
   
    ServiceReference[] refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)("
          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
   
    assertNull("No context should exist",refs);
   
   
    //Restart the bundle to check the context gets re-registered, then ensure it isn't
    //tidied up immediately again!
    Bundle b = context().getBundleByName("org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle");
    b.stop();
    b.start();
   
    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)("
        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
   
    tm.begin();
   
    emf.createEntityManager().getProperties();
   
    tm.commit();
   
    Thread.sleep(1000);
   
    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)("
        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))", 100);
   
    //Test again to make sure we don't hold state over
   
    tm.begin();
   
    emf.createEntityManager().getProperties();
   
    callback = new TestQuiesceCallback();
   
    participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
   
    Thread.sleep(1000);
   
    assertFalse("Quiesce finished", callback.bundleClearedUp());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.