[jboss-cvs] jboss-seam/src/main/org/jboss/seam ...
Gavin King
gavin.king at jboss.com
Fri Jun 8 03:08:26 EDT 2007
User: gavin
Date: 07/06/08 03:08:26
Modified: src/main/org/jboss/seam Component.java
Log:
better semantics for @Create/@Destroy/@Unwrap with inheritance
Revision Changes Path
1.251 +30 -8 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.250
retrieving revision 1.251
diff -u -b -r1.250 -r1.251
--- Component.java 7 Jun 2007 11:34:11 -0000 1.250
+++ Component.java 8 Jun 2007 07:08:26 -0000 1.251
@@ -155,10 +155,15 @@
private Method destroyMethod;
private Method createMethod;
private Method unwrapMethod;
+
+ //TODO: check the EJB3 spec, I think you
+ // are allowed to have multiple
+ // lifecycle methods on a bean!
private Method preDestroyMethod;
private Method postConstructMethod;
private Method prePassivateMethod;
private Method postActivateMethod;
+
private Map<String, Method> removeMethods = new HashMap<String, Method>();
private Set<Method> validateMethods = new HashSet<Method>();
private Set<Method> lifecycleMethods = new HashSet<Method>();
@@ -483,30 +488,44 @@
}
if ( method.isAnnotationPresent(Destroy.class) )
{
+ /*if ( method.getParameterTypes().length>0 ) and it doesnt take a Component paramater
+ {
+ throw new IllegalStateException("@Destroy methods may not have parameters: " + name);
+ }*/
if (type!=JAVA_BEAN && type!=STATEFUL_SESSION_BEAN)
{
throw new IllegalArgumentException("Only JavaBeans and stateful session beans support @Destroy methods: " + name);
}
- if (destroyMethod!=null)
+ if ( destroyMethod!=null&& !destroyMethod.getName().equals( method.getName() ) )
{
throw new IllegalStateException("component has two @Destroy methods: " + name);
}
+ if (destroyMethod==null)
+ {
destroyMethod = method;
lifecycleMethods.add(method);
}
+ }
if ( method.isAnnotationPresent(Create.class) )
{
+ /*if ( method.getParameterTypes().length>0 ) and it doesnt take a Component paramater
+ {
+ throw new IllegalStateException("@Create methods may not have parameters: " + name);
+ }*/
if (type!=JAVA_BEAN && type!=STATEFUL_SESSION_BEAN)
{
throw new IllegalArgumentException("Only JavaBeans and stateful session beans support @Create methods: " + name);
}
- if (createMethod!=null)
+ if ( createMethod!=null && !createMethod.getName().equals( method.getName() ) )
{
throw new IllegalStateException("component has two @Create methods: " + name);
}
+ if (createMethod==null)
+ {
createMethod = method;
lifecycleMethods.add(method);
}
+ }
if ( method.isAnnotationPresent(In.class) )
{
In in = method.getAnnotation(In.class);
@@ -521,12 +540,15 @@
}
if ( method.isAnnotationPresent(Unwrap.class) )
{
- if (unwrapMethod!=null)
+ if ( unwrapMethod!=null && !unwrapMethod.getName().equals( method.getName() ) )
{
throw new IllegalStateException("component has two @Unwrap methods: " + name);
}
+ if (unwrapMethod==null )
+ {
unwrapMethod = method;
}
+ }
if ( method.isAnnotationPresent(DataModel.class) ) //TODO: generalize
{
checkDataModelScope( method.getAnnotation(DataModel.class) );
More information about the jboss-cvs-commits
mailing list