[jboss-cvs] jboss-seam/src/main/org/jboss/seam ...
Gavin King
gavin.king at jboss.com
Thu Jun 14 01:40:02 EDT 2007
User: gavin
Date: 07/06/14 01:40:02
Modified: src/main/org/jboss/seam Component.java
Log:
JBSEAM-1076, JBSEAM-1108
Revision Changes Path
1.254 +52 -33 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.253
retrieving revision 1.254
diff -u -b -r1.253 -r1.254
--- Component.java 12 Jun 2007 16:46:43 -0000 1.253
+++ Component.java 14 Jun 2007 05:40:02 -0000 1.254
@@ -229,35 +229,16 @@
}
initNamespaces(componentName, applicationContext);
+ initSynchronize();
+ initStartup();
checkScopeForComponentType();
+ checkSynchronizedForComponentType();
+ checkSerializableForComponentType();
jndiName = componentJndiName == null ?
getJndiName(applicationContext) : componentJndiName;
- startup = getBeanClass().isAnnotationPresent(Startup.class);
- if (startup)
- {
- if (scope!=SESSION && scope!=APPLICATION)
- {
- throw new IllegalArgumentException("@Startup only supported for SESSION or APPLICATION scoped components: " + name);
- }
- dependencies = getBeanClass().getAnnotation(Startup.class).depends();
- }
-
- synchronize = ( scope==SESSION /*&& ! beanClass.isAnnotationPresent(ReadOnly.class)*/ ) ||
- getBeanClass().isAnnotationPresent(Synchronized.class);
- if (synchronize)
- {
- if (scope==STATELESS)
- {
- throw new IllegalArgumentException("@Synchronized not meaningful for stateless components: " + name);
- }
- timeout = getBeanClass().isAnnotationPresent(Synchronized.class) ?
- getBeanClass().getAnnotation(Synchronized.class).timeout() :
- Synchronized.DEFAULT_TIMEOUT;
- }
-
log.info(
"Component: " + getName() +
", scope: " + getScope() +
@@ -282,6 +263,31 @@
}
+ private void initStartup()
+ {
+ startup = getBeanClass().isAnnotationPresent(Startup.class);
+ if (startup)
+ {
+ if (scope!=SESSION && scope!=APPLICATION)
+ {
+ throw new IllegalArgumentException("@Startup only supported for SESSION or APPLICATION scoped components: " + name);
+ }
+ dependencies = getBeanClass().getAnnotation(Startup.class).depends();
+ }
+ }
+
+ private void initSynchronize()
+ {
+ synchronize = ( scope==SESSION /*&& ! beanClass.isAnnotationPresent(ReadOnly.class)*/ ) ||
+ getBeanClass().isAnnotationPresent(Synchronized.class);
+ if (synchronize)
+ {
+ timeout = getBeanClass().isAnnotationPresent(Synchronized.class) ?
+ getBeanClass().getAnnotation(Synchronized.class).timeout() :
+ Synchronized.DEFAULT_TIMEOUT;
+ }
+ }
+
private void registerConverterOrValidator(Context applicationContext)
{
if (applicationContext!=null) //for unit tests!
@@ -351,10 +357,21 @@
{
throw new IllegalArgumentException("Message-driven beans must be bound to STATELESS context: " + name);
}
+ }
+
+ protected void checkSynchronizedForComponentType()
+ {
+ if (scope==STATELESS && synchronize)
+ {
+ throw new IllegalArgumentException("@Synchronized not meaningful for stateless components: " + name);
+ }
+ }
+ private void checkSerializableForComponentType()
+ {
boolean serializableScope = scope==PAGE || scope==SESSION || scope==CONVERSATION;
boolean serializableType = type==JAVA_BEAN || type==ENTITY_BEAN;
- if ( serializableType && serializableScope && !Serializable.class.isAssignableFrom(getBeanClass()) )
+ if ( serializableType && serializableScope && !Serializable.class.isAssignableFrom( getBeanClass() ) )
{
log.warn("Component class should be serializable: " + name);
}
@@ -601,10 +618,7 @@
}
if ( method.isAnnotationPresent(PERSISTENCE_CONTEXT) )
{
- if ( !type.isSessionBean() && type!=MESSAGE_DRIVEN_BEAN )
- {
- throw new IllegalArgumentException("@PersistenceContext may only be used on session bean or message driven bean components: " + name);
- }
+ checkPersistenceContextForComponentType();
pcAttributes.add( new BijectedMethod( toName(null, method), method, null ) );
}
if ( method.isAnnotationPresent(Begin.class) ||
@@ -691,10 +705,7 @@
}
if ( field.isAnnotationPresent(PERSISTENCE_CONTEXT) )
{
- if ( !type.isSessionBean() && type!=MESSAGE_DRIVEN_BEAN )
- {
- throw new IllegalArgumentException("@PersistenceContext may only be used on session bean or message driven bean components: " + name);
- }
+ checkPersistenceContextForComponentType();
pcAttributes.add( new BijectedField( toName(null, field), field, null ) );
}
for ( Annotation ann: field.getAnnotations() )
@@ -751,6 +762,14 @@
}
+ protected void checkPersistenceContextForComponentType()
+ {
+ if ( !type.isSessionBean() && type!=MESSAGE_DRIVEN_BEAN )
+ {
+ throw new IllegalArgumentException("@PersistenceContext may only be used on session bean or message driven bean components: " + name);
+ }
+ }
+
private String getDataModelSelectionName(Set<String> dataModelNames, boolean hasMultipleDataModels, String defaultDataModelName, Annotation ann)
{
String name = createUnwrapper(ann).getVariableName(ann);
More information about the jboss-cvs-commits
mailing list