[jboss-cvs] jboss-seam/src/main/org/jboss/seam ...
Gavin King
gavin.king at jboss.com
Mon Sep 18 18:26:00 EDT 2006
User: gavin
Date: 06/09/18 18:26:00
Modified: src/main/org/jboss/seam Component.java
Log:
JBSEAM-22 disinjection
Revision Changes Path
1.160 +51 -2 jboss-seam/src/main/org/jboss/seam/Component.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Component.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/Component.java,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -b -r1.159 -r1.160
--- Component.java 8 Sep 2006 00:13:40 -0000 1.159
+++ Component.java 18 Sep 2006 22:26:00 -0000 1.160
@@ -88,7 +88,7 @@
*
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @author Gavin King
- * @version $Revision: 1.159 $
+ * @version $Revision: 1.160 $
*/
@Scope(ScopeType.APPLICATION)
public class Component
@@ -839,6 +839,13 @@
}
}
+ /**
+ * Inject context variable values into @In attributes
+ * of a component instance.
+ *
+ * @param bean a Seam component instance
+ * @param enforceRequired should we enforce required=true?
+ */
public void inject(Object bean, boolean enforceRequired)
{
//injectLog(bean);
@@ -848,6 +855,17 @@
injectParameters(bean);
}
+ /**
+ * Null out any @In attributes of a component instance.
+ *
+ * @param bean a Seam component instance
+ */
+ public void disinject(Object bean)
+ {
+ disinjectMethods(bean);
+ disinjectFields(bean);
+ }
+
private void injectLog(Object bean)
{
if (logField!=null)
@@ -934,6 +952,13 @@
return converter.getAsObject( facesContext, facesContext.getViewRoot(), requestParameter );
}
+ /**
+ * Outject context variable values from @Out attributes
+ * of a component instance.
+ *
+ * @param bean a Seam component instance
+ * @param enforceRequired should we enforce required=true?
+ */
public void outject(Object bean, boolean enforceRequired)
{
outjectMethods(bean, enforceRequired);
@@ -1094,6 +1119,18 @@
}
}
+ private void disinjectMethods(Object bean)
+ {
+ for (Method method : getInMethods())
+ {
+ if ( !method.getParameterTypes()[0].isPrimitive() )
+ {
+ String name = toName( method.getAnnotation(In.class).value(), method );
+ setPropertyValue(bean, method, name, null);
+ }
+ }
+ }
+
private void injectFields(Object bean, boolean enforceRequired)
{
for (Field field : getInFields())
@@ -1104,6 +1141,18 @@
}
}
+ private void disinjectFields(Object bean)
+ {
+ for (Field field : getInFields())
+ {
+ if ( !field.getType().isPrimitive() )
+ {
+ String name = toName( field.getAnnotation(In.class).value(), field );
+ setFieldValue(bean, field, name, null);
+ }
+ }
+ }
+
private void outjectFields(Object bean, boolean enforceRequired)
{
for (Field field : getOutFields())
More information about the jboss-cvs-commits
mailing list