Skip to content

Commit

Permalink
SEAMINTL-33
Browse files Browse the repository at this point in the history
  • Loading branch information
kenfinnigan committed Mar 24, 2011
1 parent 3ab39f3 commit a29f3f0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
41 changes: 27 additions & 14 deletions impl/src/main/java/org/jboss/seam/international/status/Bundles.java
Expand Up @@ -23,7 +23,10 @@
import java.util.ResourceBundle;
import java.util.Set;

import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.inject.Named;

import org.jboss.seam.solder.core.Client;

Expand All @@ -32,61 +35,71 @@
*
* @author <a href="http://community.jboss.org/people/ssachtleben">Sebastian Sachtleben</a>
*/
@Named
@RequestScoped
public class Bundles implements Map<String, ResourceBundle>, Serializable {
private static final long serialVersionUID = -1608918108928277728L;

@Inject
private ApplicationBundles bundles;
private Instance<ApplicationBundles> bundlesInstance;

@Inject
@Client
private Locale locale;
private Instance<Locale> localeInstance;

private ApplicationBundles getAppBundle() {
return bundlesInstance.get();
}

private Locale getClientLocale() {
return localeInstance.get();
}

public int size() {
return bundles.size(locale);
return getAppBundle().size(getClientLocale());
}

public boolean isEmpty() {
return bundles.isEmpty(locale);
return getAppBundle().isEmpty(getClientLocale());
}

public boolean containsKey(final Object key) {
return bundles.containsKey(locale, key);
return getAppBundle().containsKey(getClientLocale(), key);
}

public boolean containsValue(final Object value) {
return bundles.containsValue(locale, value);
return getAppBundle().containsValue(getClientLocale(), value);
}

public ResourceBundle get(final Object key) {
return bundles.get(locale, key);
return getAppBundle().get(getClientLocale(), key);
}

public ResourceBundle put(final String key, final ResourceBundle value) {
return bundles.put(locale, key, value);
return getAppBundle().put(getClientLocale(), key, value);
}

public ResourceBundle remove(final Object key) {
return bundles.remove(locale, key);
return getAppBundle().remove(getClientLocale(), key);
}

public void putAll(final Map<? extends String, ? extends ResourceBundle> m) {
bundles.putAll(locale, m);
getAppBundle().putAll(getClientLocale(), m);
}

public void clear() {
bundles.clear(locale);
getAppBundle().clear(getClientLocale());
}

public Set<String> keySet() {
return bundles.keySet(locale);
return getAppBundle().keySet(getClientLocale());
}

public Collection<ResourceBundle> values() {
return bundles.values(locale);
return getAppBundle().values(getClientLocale());
}

public Set<java.util.Map.Entry<String, ResourceBundle>> entrySet() {
return bundles.entrySet(locale);
return getAppBundle().entrySet(getClientLocale());
}
}
Expand Up @@ -21,6 +21,7 @@

import java.util.ResourceBundle;

import javax.enterprise.inject.Instance;
import javax.inject.Inject;

import org.jboss.arquillian.api.Deployment;
Expand All @@ -32,7 +33,7 @@
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand All @@ -45,9 +46,9 @@ public class BundlesTest {
private static final String BUNDLE_PATH = "org.jboss.seam.international.test.status.TestBundle";

@Deployment
public static JavaArchive createTestArchive() {
public static WebArchive createTestArchive() {
return ShrinkWrap
.create(JavaArchive.class, "test.jar")
.create(WebArchive.class, "test.war")
.addPackage(DefaultLocaleProducer.class.getPackage())
.addPackage(ApplicationBundles.class.getPackage())
.addClass(DefaultLocale.class)
Expand All @@ -56,10 +57,11 @@ public static JavaArchive createTestArchive() {
}

@Inject
Bundles bundles;
Instance<Bundles> bundlesInstance;

@Test
public void testGetBundles() {
Bundles bundles = bundlesInstance.get();
bundles.put("keyTest", ResourceBundle.getBundle(BUNDLE_PATH));
assertEquals(1, bundles.size());
ResourceBundle bdle = bundles.get("keyTest");
Expand Down

0 comments on commit a29f3f0

Please sign in to comment.