[jboss-cvs] jboss-seam/src/main/org/jboss/seam ...
Gavin King
gavin.king at jboss.com
Sat Mar 3 13:22:41 EST 2007
User: gavin
Date: 07/03/03 13:22:41
Modified: src/main/org/jboss/seam Component.java
Log:
JBSEAM-980, @Converter, @Validator
Revision Changes Path
1.242 +35 -4 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.241
retrieving revision 1.242
diff -u -b -r1.241 -r1.242
--- Component.java 26 Feb 2007 20:31:09 -0000 1.241
+++ Component.java 3 Mar 2007 18:22:41 -0000 1.242
@@ -78,6 +78,8 @@
import org.jboss.seam.annotations.Transactional;
import org.jboss.seam.annotations.Unwrap;
import org.jboss.seam.annotations.datamodel.DataModel;
+import org.jboss.seam.annotations.jsf.Converter;
+import org.jboss.seam.annotations.jsf.Validator;
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.contexts.Context;
import org.jboss.seam.contexts.Contexts;
@@ -206,8 +208,8 @@
name = componentName;
scope = componentScope;
- type = Seam.getComponentType(getBeanClass());
- interceptionType = Seam.getInterceptionType(getBeanClass());
+ type = Seam.getComponentType( getBeanClass() );
+ interceptionType = Seam.getInterceptionType (getBeanClass() );
initNamespaces(componentName, applicationContext);
@@ -247,10 +249,10 @@
( jndiName==null ? "" : ", JNDI: " + jndiName )
);
- initMembers(beanClass, applicationContext);
+ initMembers( getBeanClass(), applicationContext );
checkDestroyMethod();
- businessInterfaces = getBusinessInterfaces(getBeanClass());
+ businessInterfaces = getBusinessInterfaces( getBeanClass() );
if ( interceptionType!=InterceptionType.NEVER)
{
@@ -259,6 +261,35 @@
initInitializers(applicationContext);
+ registerConverterOrValidator(applicationContext);
+
+ }
+
+ private void registerConverterOrValidator(Context applicationContext)
+ {
+ if (applicationContext!=null) //for unit tests!
+ {
+ Init init = (Init) applicationContext.get( Seam.getComponentName(Init.class) );
+ if (init!=null)
+ {
+ if ( getBeanClass().isAnnotationPresent(Converter.class) )
+ {
+ Converter converter = getBeanClass().getAnnotation(Converter.class);
+ if ( converter.forClass()!=void.class )
+ {
+ init.getConvertersByClass().put( converter.forClass(), getName() );
+ }
+ String id = converter.id().equals("") ? getName() : converter.id();
+ init.getConverters().put( id, getName() );
+ }
+ if ( getBeanClass().isAnnotationPresent(Validator.class) )
+ {
+ Validator validator = getBeanClass().getAnnotation(Validator.class);
+ String id = validator.id().equals("") ? getName() : validator.id();
+ init.getValidators().put( id, getName() );
+ }
+ }
+ }
}
private void initNamespaces(String componentName, Context applicationContext)
More information about the jboss-cvs-commits
mailing list