Skip to content

Commit

Permalink
Add a second cache
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Sep 7, 2010
1 parent 30340d2 commit 486ae38
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
Expand Up @@ -23,5 +23,22 @@ public Configuration getTinyConfiguration()
configuration.setEvictionMaxEntries(1);
return configuration;
}


/**
* Configure a "small" cache (with a pretty low number of entries), and associate
* it with the qualifier {@link Small}.
*
* This will use the default cache container.
*/
@Produces
@Infinispan("small")
@Small
public Configuration getSmallConfiguration()
{
Configuration configuration = new Configuration();
configuration.setEvictionMaxEntries(10);
return configuration;
}

}
Expand Up @@ -34,16 +34,29 @@ public static Archive<?> deployment()
}

/**
* Inject a cache configured by application
* Inject a cache configured by the application
*/
@Inject @Tiny
private AdvancedCache<String, String> tinyCache;

/**
* Inject a cache configured by application
*/
@Inject @Small
private AdvancedCache<String, String> smallCache;

@Test
public void testTinyCache()
{
// Check that we have the correctly configured cache
assertEquals(1, tinyCache.getConfiguration().getEvictionMaxEntries());
}

@Test
public void testSmallCache()
{
// Check that we have the correctly configured cache
assertEquals(10, smallCache.getConfiguration().getEvictionMaxEntries());
}

}
21 changes: 21 additions & 0 deletions src/test/java/org/jboss/seam/infinispan/test/configured/Small.java
@@ -0,0 +1,21 @@
package org.jboss.seam.infinispan.test.configured;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.inject.Qualifier;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Qualifier
@Target({ TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
public @interface Small {

}

0 comments on commit 486ae38

Please sign in to comment.