Package org.jboss.cache

Examples of org.jboss.cache.Region


   {
      String fqn1 = "/a";
      String fqn2 = "/a/b";
      String fqn3 = "/a/b/c";

      Region r1 = r.getRegion(fqn1, true);
      Region r2 = r.getRegion(fqn2, true);
      Region r3 = r.getRegion(fqn3, true);

      assertEquals("Expecting 3 regions", 3, r.getAllRegions(Region.Type.ANY).size());

      // test that removal doesn't affect parent traversal.
      assertEquals(r3, r.getRegion(fqn3, false));
View Full Code Here


   {
      String f1 = "/a", f2 = "/b", f3 = "/c", f4 = "/d";

      r.setDefaultInactive(true);

      @SuppressWarnings("unused")
      Region r1 = r.getRegion(f1, true), r2 = r.getRegion(f2, true), r3 = r.getRegion(f3, true), r4 = r.getRegion(f4, true);

      assertEquals("4 regions should exist", 4, r.getAllRegions(Region.Type.ANY).size());

      assertEquals("None of the regions should marshalling or active", 0, r.getAllRegions(Region.Type.MARSHALLING).size());
View Full Code Here

      assertEquals("v", caches.get(0).get(f, "k"));
      assertEquals("v", caches.get(1).get(f, "k"));

      // create the region on cache 0, make sure it is marked as a MARSHALLING region by attaching a class loader to it.
      Region region0 = caches.get(0).getRegionManager().getRegion(f, true);
      region0.registerContextClassLoader(this.getClass().getClassLoader()); // just to make sure this is recognised as a marshalling region.
      assertTrue("Should be active by default", region0.isActive());
      // make sure this newly created region is "recognised" as a marshalling region.
      assertTrue(caches.get(0).getRegionManager().getAllRegions(Region.Type.MARSHALLING).contains(region0));

      // now create a region on cache 1, as above.
      Region region1 = caches.get(1).getRegionManager().getRegion(f, true);
      region1.registerContextClassLoader(this.getClass().getClassLoader()); // just to make sure this is recognised as a marshalling region.
      assertTrue("Should be active by default", region1.isActive());
      // make sure this newly created region is "recognised" as a marshalling region.
      assertTrue(caches.get(1).getRegionManager().getAllRegions(Region.Type.MARSHALLING).contains(region1));

      // now deactivate the region on cache 1.
      region1.deactivate();
      assertFalse("Should be have deactivated", region1.isActive());

      caches.get(0).put(f, "k", "v2");
      assertEquals("v2", caches.get(0).get(f, "k"));
      assertNull(caches.get(1).get(f, "k"));
View Full Code Here

      c.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
   }

   protected void createAndActivateRegion(CacheSPI<Object, Object> c, Fqn f)
   {
      Region r = c.getRegion(f, true);
      r.registerContextClassLoader(getClass().getClassLoader());
      r.activate();
   }
View Full Code Here

      FooClassLoader loader = new FooClassLoader(originalClassLoaderTL.get());

      if (useRegionBased)
      {
         Region r = cache.getRegion(Fqn.ROOT, true);
         r.registerContextClassLoader(loader);
         r.activate();
      }

      Class clazz = loader.loadFoo();
      Object obj = clazz.newInstance();
View Full Code Here

      cache.start();

      URLClassLoader ucl1 = createOrphanClassLoader();
      Thread.currentThread().setContextClassLoader(ucl1);

      Region region = cache.getRegion(fqn("/"), true);
      region.registerContextClassLoader(Thread.currentThread().getContextClassLoader());
      region.activate();

      Class clazz1 = ucl1.loadClass(INSTANCE_CLASS_NAME);
      cache.put(fqn("/a"), "key", clazz1.newInstance());

      region.deactivate();
      region.unregisterContextClassLoader();

      Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());

      region.registerContextClassLoader(Thread.currentThread().getContextClassLoader());

      try
      {
         Global object = (Global) cache.get(fqn("/a"), "key");
         assertNull(object);
      }
      catch (ClassCastException cce)
      {
//         cce.printStackTrace();
         fail("Should not have produced a ClassCastException");
      }

      region.deactivate();
      region.unregisterContextClassLoader();
   }
View Full Code Here

      RegionManager rm = cr.getComponent(RegionManager.class);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      final Fqn region = Fqn.fromString("/hello");
      Region r = rm.getRegion(region, true);
      r.registerContextClassLoader(this.getClass().getClassLoader());
      cm200.objectToObjectStream(new ClusteredGetCommand(false, null), oos, region);
      oos.close();

      final byte[] stream = baos.toByteArray();
      // so now the stream starts with the Fqn "/hello".
View Full Code Here

    */
   private static <K, V> void addEvictionRegion(Fqn<String> fqn, Cache<K, V> cache, Configuration cfg)
   {
      EvictionConfig ec = cfg.getEvictionConfig();
      // Create the region and set the config
      Region region = cache.getRegion(fqn, true);
      if (ec != null && ec.getDefaultEvictionRegionConfig() != null)
      {
         EvictionRegionConfig erc = new EvictionRegionConfig(fqn);
         erc.setDefaults(ec.getDefaultEvictionRegionConfig());
         region.setEvictionRegionConfig(erc);
      }
   }
View Full Code Here

   {
      if (cache.getConfiguration().isInactiveOnStartup())
      {
         if (cache.getConfiguration().isUseRegionBasedMarshalling())
         {
            Region region =cache.getRegion(Fqn.fromElements(SSO), true);
            try
            {
               region.activate();
            }
            catch (RegionNotEmptyException e)
            {
               log.debug(SSO + " region already active", e);
            }
View Full Code Here

            if (root.hasChild(pathFqn) == false)
            {
               plainCache_.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
               root.addChild(pathFqn);
            }
            Region region = plainCache_.getRegion(pathFqn, true);
            region.registerContextClassLoader(webAppClassLoader_);
            region.activate();
         }
         catch (Exception ex)
         {
            throw new RuntimeException("Can't register class loader", ex);
         }
View Full Code Here

TOP

Related Classes of org.jboss.cache.Region

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.