[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Gavin King
gavin.king at jboss.com
Sun Oct 8 16:58:03 EDT 2006
User: gavin
Date: 06/10/08 16:58:03
Modified: src/main/org/jboss/seam/core Events.java
Expressions.java Pages.java ResourceBundle.java
Log:
JBSEAM-178 delimited bundleNames
temp fix for bug in new context events stuff
Revision Changes Path
1.6 +12 -8 jboss-seam/src/main/org/jboss/seam/core/Events.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Events.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Events.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- Events.java 29 Sep 2006 22:48:50 -0000 1.5
+++ Events.java 8 Oct 2006 20:58:03 -0000 1.6
@@ -8,9 +8,6 @@
import java.util.List;
import java.util.Map;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
@@ -25,6 +22,7 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.Expressions.MethodBinding;
import org.jboss.seam.core.Init.ObserverMethod;
import org.jboss.seam.util.Resources;
@@ -56,6 +54,10 @@
for (Element event: elements)
{
String type = event.attributeValue("type");
+ if (type==null)
+ {
+ throw new IllegalArgumentException("must specify type for <event/> declaration");
+ }
List<MethodBinding> methodBindings = new ArrayList<MethodBinding>();
listeners.put(type, methodBindings);
@@ -63,8 +65,11 @@
for (Element action: actions)
{
String actionExpression = action.attributeValue("expression");
- MethodBinding methodBinding = FacesContext.getCurrentInstance().getApplication()
- .createMethodBinding(actionExpression, null);
+ if (actionExpression==null)
+ {
+ throw new IllegalArgumentException("must specify expression for <action/> declaration");
+ }
+ MethodBinding methodBinding = Expressions.instance().createMethodBinding(actionExpression);
methodBindings.add(methodBinding);
}
}
@@ -73,8 +78,7 @@
public void addListener(String type, String methodBindingExpression)
{
- MethodBinding methodBinding = FacesContext.getCurrentInstance().getApplication()
- .createMethodBinding(methodBindingExpression, null);
+ MethodBinding methodBinding = Expressions.instance().createMethodBinding(methodBindingExpression);
List<MethodBinding> list = listeners.get(type);
if (list==null)
{
@@ -92,7 +96,7 @@
{
for (MethodBinding listener: list )
{
- listener.invoke( FacesContext.getCurrentInstance(), null );
+ listener.invoke();
}
}
List<Init.ObserverMethod> observers = Init.instance().getObservers(type);
1.2 +4 -4 jboss-seam/src/main/org/jboss/seam/core/Expressions.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Expressions.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Expressions.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Expressions.java 3 Oct 2006 17:16:44 -0000 1.1
+++ Expressions.java 8 Oct 2006 20:58:03 -0000 1.2
@@ -1,4 +1,4 @@
-//$Id: Expressions.java,v 1.1 2006/10/03 17:16:44 gavin Exp $
+//$Id: Expressions.java,v 1.2 2006/10/08 20:58:03 gavin Exp $
package org.jboss.seam.core;
import static org.jboss.seam.InterceptionType.NEVER;
@@ -76,9 +76,9 @@
return mb.getType( FacesContext.getCurrentInstance() );
}
- public Object invoke(Object[] aobj)
+ public Object invoke(Object... args)
{
- return mb.invoke( FacesContext.getCurrentInstance(), aobj );
+ return mb.invoke( FacesContext.getCurrentInstance(), args );
}
};
@@ -103,7 +103,7 @@
public Class getType();
- public Object invoke( Object aobj[] );
+ public Object invoke(Object... args);
}
public static Expressions instance()
1.27 +2 -2 jboss-seam/src/main/org/jboss/seam/core/Pages.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Pages.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Pages.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- Pages.java 8 Oct 2006 14:01:53 -0000 1.26
+++ Pages.java 8 Oct 2006 20:58:03 -0000 1.27
@@ -235,7 +235,7 @@
{
fromAction = methodBinding.getExpressionString();
result = true;
- outcome = toString( methodBinding.invoke(null) );
+ outcome = toString( methodBinding.invoke() );
}
}
@@ -290,7 +290,7 @@
if ( !isActionAllowed(facesContext, expression) ) return result;
result = true;
MethodBinding actionBinding = Expressions.instance().createMethodBinding(expression);
- outcome = toString( actionBinding.invoke(null) );
+ outcome = toString( actionBinding.invoke() );
fromAction = expression;
}
}
1.10 +56 -8 jboss-seam/src/main/org/jboss/seam/core/ResourceBundle.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ResourceBundle.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ResourceBundle.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- ResourceBundle.java 15 May 2006 00:31:22 -0000 1.9
+++ ResourceBundle.java 8 Oct 2006 20:58:03 -0000 1.10
@@ -3,6 +3,7 @@
import static org.jboss.seam.InterceptionType.NEVER;
import java.io.Serializable;
+import java.util.Enumeration;
import java.util.MissingResourceException;
import org.apache.commons.logging.Log;
@@ -27,40 +28,87 @@
private static final Log log = LogFactory.getLog(ResourceBundle.class);
- private String bundleName = "messages";
+ private String[] bundleNames = {"messages"};
private transient java.util.ResourceBundle bundle;
- public String getBundleName()
+ public String[] getBundleNames()
{
- return bundleName;
+ return bundleNames;
}
- public void setBundleName(String bundleName)
+ public void setBundleNames(String[] bundleNames)
{
- this.bundleName = bundleName;
+ this.bundleNames = bundleNames;
}
- private void loadBundle()
+ private java.util.ResourceBundle loadBundle(String bundleName)
{
try
{
- bundle = java.util.ResourceBundle.getBundle(
+ java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(
bundleName,
Locale.instance(),
Thread.currentThread().getContextClassLoader()
);
log.debug("loaded resource bundle: " + bundleName);
+ return bundle;
}
catch (MissingResourceException mre)
{
log.debug("resource bundle missing: " + bundleName);
+ return null;
+ }
+ }
+
+ private void createUberBundle()
+ {
+ if ( bundleNames!=null && bundleNames.length>0 )
+ {
+
+ final java.util.ResourceBundle[] littleBundles = new java.util.ResourceBundle[bundleNames.length];
+ for (int i=0; i<bundleNames.length; i++)
+ {
+ littleBundles[i] = loadBundle( bundleNames[i] );
+ }
+
+ bundle = new java.util.ResourceBundle()
+ {
+
+ @Override
+ public java.util.Locale getLocale()
+ {
+ return littleBundles[0].getLocale();
+ }
+
+ @Override
+ public Enumeration<String> getKeys()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected Object handleGetObject(String key)
+ {
+ for (java.util.ResourceBundle littleBundle: littleBundles)
+ {
+ try
+ {
+ return littleBundle.getObject(key);
+ }
+ catch (MissingResourceException mre) {}
+ }
+ throw new MissingResourceException("Can't find resource in bundles: " + key, getClass().getName(), key );
+ }
+
+ };
+
}
}
@Unwrap
public java.util.ResourceBundle getBundle()
{
- if (bundle==null) loadBundle();
+ if (bundle==null) createUberBundle();
return bundle;
}
More information about the jboss-cvs-commits
mailing list