[seam-commits] Seam SVN: r8626 - in trunk: src/main/org/jboss/seam and 10 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Thu Aug 7 15:50:09 EDT 2008
Author: pete.muir at jboss.org
Date: 2008-08-07 15:50:09 -0400 (Thu, 07 Aug 2008)
New Revision: 8626
Modified:
trunk/examples/wiki/src/etc/META-INF/components-test.xml
trunk/src/main/org/jboss/seam/Component.java
trunk/src/main/org/jboss/seam/async/AsynchronousInterceptor.java
trunk/src/main/org/jboss/seam/bpm/BusinessProcessInterceptor.java
trunk/src/main/org/jboss/seam/core-2.1.xsd
trunk/src/main/org/jboss/seam/core/BijectionInterceptor.java
trunk/src/main/org/jboss/seam/core/ConversationInterceptor.java
trunk/src/main/org/jboss/seam/core/ConversationalInterceptor.java
trunk/src/main/org/jboss/seam/core/EventInterceptor.java
trunk/src/main/org/jboss/seam/core/Init.java
trunk/src/main/org/jboss/seam/core/MethodContextInterceptor.java
trunk/src/main/org/jboss/seam/core/SynchronizationInterceptor.java
trunk/src/main/org/jboss/seam/ejb/RemoveInterceptor.java
trunk/src/main/org/jboss/seam/init/Initialization.java
trunk/src/main/org/jboss/seam/intercept/Interceptor.java
trunk/src/main/org/jboss/seam/persistence/EntityManagerProxyInterceptor.java
trunk/src/main/org/jboss/seam/persistence/HibernateSessionProxyInterceptor.java
trunk/src/main/org/jboss/seam/persistence/ManagedEntityIdentityInterceptor.java
trunk/src/main/org/jboss/seam/security/SecurityInterceptor.java
trunk/src/main/org/jboss/seam/transaction/RollbackInterceptor.java
trunk/src/main/org/jboss/seam/transaction/TransactionInterceptor.java
trunk/src/main/org/jboss/seam/webservice/WSSecurityInterceptor.java
Log:
JBSEAM-1485
Modified: trunk/examples/wiki/src/etc/META-INF/components-test.xml
===================================================================
--- trunk/examples/wiki/src/etc/META-INF/components-test.xml 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/examples/wiki/src/etc/META-INF/components-test.xml 2008-08-07 19:50:09 UTC (rev 8626)
@@ -43,8 +43,7 @@
<!-- Running tests in Embeddable JBoss -->
<core:init debug="false"
- jndi-pattern="#{ejbName}/local"
- disabled-interceptors="org.jboss.seam.persistence.ManagedEntityIdentityInterceptor"/>
+ jndi-pattern="#{ejbName}/local"/>
<transaction:ejb-transaction/>
Modified: trunk/src/main/org/jboss/seam/Component.java
===================================================================
--- trunk/src/main/org/jboss/seam/Component.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/Component.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -10,7 +10,6 @@
import static org.jboss.seam.ComponentType.JAVA_BEAN;
import static org.jboss.seam.ComponentType.MESSAGE_DRIVEN_BEAN;
import static org.jboss.seam.ComponentType.STATEFUL_SESSION_BEAN;
-import static org.jboss.seam.ComponentType.STATELESS_SESSION_BEAN;
import static org.jboss.seam.ScopeType.APPLICATION;
import static org.jboss.seam.ScopeType.CONVERSATION;
import static org.jboss.seam.ScopeType.EVENT;
@@ -48,15 +47,12 @@
import javassist.util.proxy.MethodFilter;
import javassist.util.proxy.MethodHandler;
-
-import org.jboss.seam.util.ProxyFactory;
import javassist.util.proxy.ProxyObject;
import javax.naming.NamingException;
import javax.servlet.http.HttpSessionActivationListener;
import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.Conversational;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.DataBinderClass;
import org.jboss.seam.annotations.DataSelectorClass;
@@ -68,13 +64,10 @@
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.PerNestedConversation;
-import org.jboss.seam.annotations.RaiseEvent;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Startup;
import org.jboss.seam.annotations.Synchronized;
-import org.jboss.seam.annotations.Transactional;
import org.jboss.seam.annotations.Unwrap;
-import org.jboss.seam.annotations.async.Asynchronous;
import org.jboss.seam.annotations.bpm.BeginTask;
import org.jboss.seam.annotations.bpm.EndTask;
import org.jboss.seam.annotations.bpm.StartTask;
@@ -87,25 +80,16 @@
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.annotations.security.RoleCheck;
import org.jboss.seam.annotations.web.RequestParameter;
-import org.jboss.seam.async.AsynchronousInterceptor;
-import org.jboss.seam.bpm.BusinessProcessInterceptor;
import org.jboss.seam.contexts.Context;
import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.core.BijectionInterceptor;
-import org.jboss.seam.core.ConversationInterceptor;
-import org.jboss.seam.core.ConversationalInterceptor;
-import org.jboss.seam.core.EventInterceptor;
import org.jboss.seam.core.Events;
import org.jboss.seam.core.Expressions;
import org.jboss.seam.core.Init;
-import org.jboss.seam.core.MethodContextInterceptor;
import org.jboss.seam.core.Mutable;
-import org.jboss.seam.core.SynchronizationInterceptor;
import org.jboss.seam.core.Expressions.MethodExpression;
import org.jboss.seam.core.Expressions.ValueExpression;
import org.jboss.seam.databinding.DataBinder;
import org.jboss.seam.databinding.DataSelector;
-import org.jboss.seam.ejb.RemoveInterceptor;
import org.jboss.seam.ejb.SeamInterceptor;
import org.jboss.seam.intercept.ClientSideInterceptor;
import org.jboss.seam.intercept.Interceptor;
@@ -113,20 +97,14 @@
import org.jboss.seam.intercept.Proxy;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
-import org.jboss.seam.persistence.HibernateSessionProxyInterceptor;
-import org.jboss.seam.persistence.ManagedEntityIdentityInterceptor;
-import org.jboss.seam.persistence.EntityManagerProxyInterceptor;
-import org.jboss.seam.security.SecurityInterceptor;
-import org.jboss.seam.transaction.RollbackInterceptor;
-import org.jboss.seam.transaction.TransactionInterceptor;
import org.jboss.seam.util.Conversions;
import org.jboss.seam.util.Naming;
+import org.jboss.seam.util.ProxyFactory;
import org.jboss.seam.util.Reflections;
import org.jboss.seam.util.SortItem;
import org.jboss.seam.util.Sorter;
import org.jboss.seam.util.Conversions.PropertyValue;
import org.jboss.seam.web.Parameters;
-import org.jboss.seam.webservice.WSSecurityInterceptor;
/**
* Metamodel class for component classes.
@@ -950,28 +928,19 @@
public void addInterceptor(Interceptor interceptor)
{
- if (isInterceptorEnabled(interceptor)) {
- if (interceptor.getType()==InterceptorType.SERVER) {
- interceptors.add(interceptor);
- } else {
- clientSideInterceptors.add(interceptor);
- }
- }
+ if (interceptor.isInterceptorEnabled())
+ {
+ if (interceptor.getType()==InterceptorType.SERVER)
+ {
+ interceptors.add(interceptor);
+ }
+ else
+ {
+ clientSideInterceptors.add(interceptor);
+ }
+ }
}
- private boolean isInterceptorEnabled(Interceptor interceptor) {
- if (Contexts.isApplicationContextActive()) {
- Class interceptorClass = interceptor.getUserInterceptorClass();
- if (interceptorClass != null) {
- if (Init.instance().getDisabledInterceptors().contains(interceptorClass.getName())) {
- return false;
- }
- }
- }
-
- return true;
- }
-
private List<Interceptor> newSort(List<Interceptor> list)
{
List<SortItem<Interceptor>> siList = new ArrayList<SortItem<Interceptor>>();
@@ -1016,77 +985,30 @@
private void initDefaultInterceptors()
{
- if (synchronize)
+ List<String> interceptors;
+ if (Contexts.isApplicationContextActive())
{
- addInterceptor( new Interceptor( new SynchronizationInterceptor(), this ) );
+ interceptors = Init.instance().getInterceptors();
}
- if (
- ( getType().isEjb() && businessInterfaceHasAnnotation(Asynchronous.class) ) ||
- ( getType()==JAVA_BEAN && beanClassHasAnnotation(Asynchronous.class) )
- )
+ else
{
- addInterceptor( new Interceptor( new AsynchronousInterceptor(), this ) );
+ // For unit tests
+ interceptors = Init.DEFAULT_INTERCEPTORS;
}
- if ( getType()==STATEFUL_SESSION_BEAN )
+ for (String interceptorName : interceptors)
{
- addInterceptor( new Interceptor( new RemoveInterceptor(), this ) );
- }
- if ( getType()==STATEFUL_SESSION_BEAN || getType()==STATELESS_SESSION_BEAN )
- {
- if (Reflections.isClassAvailable("org.hibernate.Session"))
+ Object interceptorInstance = null;
+ try
{
- addInterceptor( new Interceptor ( new HibernateSessionProxyInterceptor(), this ) );
+ Class<?> clazz = Reflections.classForName(interceptorName);
+ interceptorInstance = clazz.newInstance();
}
- addInterceptor( new Interceptor ( new EntityManagerProxyInterceptor(), this ) );
- }
- if ( getType()!=ENTITY_BEAN )
- {
- addInterceptor( new Interceptor( new MethodContextInterceptor(), this ) );
- }
- if ( beanClassHasAnnotation(RaiseEvent.class) )
- {
- addInterceptor( new Interceptor( new EventInterceptor(), this ) );
- }
- if ( beanClassHasAnnotation(Conversational.class) )
- {
- addInterceptor( new Interceptor( new ConversationalInterceptor(), this ) );
- }
- if ( Contexts.isApplicationContextActive() ) //ugh, for unit tests
- {
- if ( Init.instance().isJbpmInstalled() )
+ catch (Exception e)
{
- addInterceptor( new Interceptor( new BusinessProcessInterceptor(), this ) );
+ throw new IllegalArgumentException("Unable to load interceptor " + interceptorName, e);
}
+ addInterceptor(new Interceptor(interceptorInstance, this));
}
- if ( !conversationManagementMethods.isEmpty() )
- {
- addInterceptor( new Interceptor( new ConversationInterceptor(), this ) );
- }
- if ( needsInjection() || needsOutjection() )
- {
- addInterceptor( new Interceptor( new BijectionInterceptor(), this ) );
- }
- addInterceptor( new Interceptor( new RollbackInterceptor(), this ) );
- if ( getType()==JAVA_BEAN && beanClassHasAnnotation(Transactional.class))
- {
- addInterceptor( new Interceptor( new TransactionInterceptor(), this ) );
- }
- if ( getScope()==CONVERSATION )
- {
- addInterceptor( new Interceptor( new ManagedEntityIdentityInterceptor(), this ) );
- }
-
- if (secure)
- {
- if (beanClassHasAnnotation("javax.jws.WebService"))
- {
- addInterceptor( new Interceptor( new WSSecurityInterceptor(), this ) );
- }
- else
- {
- addInterceptor( new Interceptor( new SecurityInterceptor(), this ) );
- }
- }
}
private void initSecurity()
@@ -2423,6 +2345,11 @@
{
return startup;
}
+
+ public boolean isSynchronize()
+ {
+ return synchronize;
+ }
public String[] getDependencies()
{
@@ -2794,4 +2721,14 @@
{
return perNestedConversation;
}
+
+ public boolean hasConversationManagementMethods()
+ {
+ return !conversationManagementMethods.isEmpty();
+ }
+
+ public boolean isSecure()
+ {
+ return secure;
+ }
}
Modified: trunk/src/main/org/jboss/seam/async/AsynchronousInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/async/AsynchronousInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/async/AsynchronousInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -1,5 +1,7 @@
package org.jboss.seam.async;
+import static org.jboss.seam.ComponentType.JAVA_BEAN;
+
import org.jboss.seam.annotations.async.Asynchronous;
import org.jboss.seam.annotations.intercept.AroundInvoke;
import org.jboss.seam.annotations.intercept.Interceptor;
@@ -63,4 +65,10 @@
{
return Contexts.getEventContext().isSet(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL);
}
+
+ public boolean isInterceptorEnabled()
+ {
+ return ( getComponent().getType().isEjb() && getComponent().businessInterfaceHasAnnotation(Asynchronous.class) ) ||
+ ( getComponent().getType() == JAVA_BEAN && getComponent().beanClassHasAnnotation(Asynchronous.class) );
+ }
}
Modified: trunk/src/main/org/jboss/seam/bpm/BusinessProcessInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/bpm/BusinessProcessInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/bpm/BusinessProcessInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -15,8 +15,10 @@
import org.jboss.seam.annotations.bpm.StartTask;
import org.jboss.seam.annotations.intercept.AroundInvoke;
import org.jboss.seam.annotations.intercept.Interceptor;
+import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.BijectionInterceptor;
import org.jboss.seam.core.Expressions;
+import org.jboss.seam.core.Init;
import org.jboss.seam.intercept.AbstractInterceptor;
import org.jboss.seam.intercept.InvocationContext;
import org.jboss.seam.log.LogProvider;
@@ -171,4 +173,10 @@
throw new IllegalArgumentException("task/process id must be a string or long");
}
}
+
+ public boolean isInterceptorEnabled()
+ {
+ return Contexts.isApplicationContextActive() && Init.instance().isJbpmInstalled();
+ }
+
}
Modified: trunk/src/main/org/jboss/seam/core/BijectionInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/BijectionInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/core/BijectionInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -56,4 +56,9 @@
}
}
+ public boolean isInterceptorEnabled()
+ {
+ return getComponent().needsInjection() || getComponent().needsOutjection();
+ }
+
}
Modified: trunk/src/main/org/jboss/seam/core/ConversationInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/ConversationInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/core/ConversationInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -286,5 +286,10 @@
{
Manager.instance().endConversation(beforeRedirect);
}
+
+ public boolean isInterceptorEnabled()
+ {
+ return getComponent().hasConversationManagementMethods();
+ }
}
Modified: trunk/src/main/org/jboss/seam/core/ConversationalInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/ConversationalInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/core/ConversationalInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -72,5 +72,10 @@
{
return getComponent().getBeanClass().isAnnotationPresent(Conversational.class);
}
+
+ public boolean isInterceptorEnabled()
+ {
+ return getComponent().beanClassHasAnnotation(Conversational.class);
+ }
}
Modified: trunk/src/main/org/jboss/seam/core/EventInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/EventInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/core/EventInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -70,4 +70,10 @@
}
return result;
}
+
+ public boolean isInterceptorEnabled()
+ {
+ return getComponent().beanClassHasAnnotation(RaiseEvent.class);
+ }
+
}
Modified: trunk/src/main/org/jboss/seam/core/Init.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/Init.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/core/Init.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -23,9 +23,20 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.async.AsynchronousInterceptor;
+import org.jboss.seam.bpm.BusinessProcessInterceptor;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Expressions.MethodExpression;
import org.jboss.seam.core.Expressions.ValueExpression;
+import org.jboss.seam.ejb.RemoveInterceptor;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.persistence.EntityManagerProxyInterceptor;
+import org.jboss.seam.persistence.HibernateSessionProxyInterceptor;
+import org.jboss.seam.security.SecurityInterceptor;
+import org.jboss.seam.transaction.RollbackInterceptor;
+import org.jboss.seam.transaction.TransactionInterceptor;
+import org.jboss.seam.webservice.WSSecurityInterceptor;
/**
* A Seam component that holds Seam configuration settings
@@ -39,6 +50,26 @@
public class Init
{
+ public static List<String> DEFAULT_INTERCEPTORS = new ArrayList<String>(Arrays.asList(
+ SynchronizationInterceptor.class.getName(),
+ AsynchronousInterceptor.class.getName(),
+ RemoveInterceptor.class.getName(),
+ HibernateSessionProxyInterceptor.class.getName(),
+ EntityManagerProxyInterceptor.class.getName(),
+ MethodContextInterceptor.class.getName(),
+ EventInterceptor.class.getName(),
+ ConversationalInterceptor.class.getName(),
+ BusinessProcessInterceptor.class.getName(),
+ ConversationInterceptor.class.getName(),
+ BijectionInterceptor.class.getName(),
+ RollbackInterceptor.class.getName(),
+ TransactionInterceptor.class.getName(),
+ WSSecurityInterceptor.class.getName(),
+ SecurityInterceptor.class.getName()
+ ));
+
+ private LogProvider log = Logging.getLogProvider(Init.class);
+
private Namespace rootNamespace = new Namespace(null);
private Collection<Namespace> globalImports = new ArrayList<Namespace>();
@@ -50,7 +81,7 @@
private boolean myFacesLifecycleBug;
private boolean transactionManagementEnabled = true;
- private List<String> disabledInterceptors = new ArrayList<String>();
+ private List<String> interceptors = new ArrayList<String>(DEFAULT_INTERCEPTORS);
private Map<String, List<ObserverMethod>> observerMethods = new HashMap<String, List<ObserverMethod>>();
private Map<String, List<ObserverMethodExpression>> observerMethodBindings = new HashMap<String, List<ObserverMethodExpression>>();
@@ -534,14 +565,29 @@
{
return globalImports;
}
-
- public List<String> getDisabledInterceptors() {
- return disabledInterceptors;
- }
- public void setDisabledInterceptors(List<String> disabledInterceptors) {
- this.disabledInterceptors = disabledInterceptors;
- }
+ public List<String> getInterceptors()
+ {
+ return interceptors;
+ }
+
+ public void setInterceptors(List<String> interceptors)
+ {
+ this.interceptors = interceptors;
+ }
+ /**
+ * Sanity check to warn users if they have disabled core interceptors
+ */
+ public void checkDefaultInterceptors()
+ {
+ for (String defaultInterceptor : DEFAULT_INTERCEPTORS)
+ {
+ if (!interceptors.contains(defaultInterceptor))
+ {
+ log.warn("The built-in interceptor " + defaultInterceptor + " is missing. This application may not function as expected");
+ }
+ }
+ }
}
Modified: trunk/src/main/org/jboss/seam/core/MethodContextInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/MethodContextInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/core/MethodContextInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -1,5 +1,7 @@
package org.jboss.seam.core;
+import static org.jboss.seam.ComponentType.ENTITY_BEAN;
+
import java.lang.reflect.Method;
import org.jboss.seam.Component;
@@ -46,4 +48,10 @@
Lifecycle.endMethod(outerMethodContext);
}
}
+
+ public boolean isInterceptorEnabled()
+ {
+ return getComponent().getType()!=ENTITY_BEAN;
+ }
+
}
Modified: trunk/src/main/org/jboss/seam/core/SynchronizationInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/SynchronizationInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/core/SynchronizationInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -41,5 +41,10 @@
throw new IllegalStateException("could not acquire lock on @Synchronized component: " + getComponent().getName());
}
}
+
+ public boolean isInterceptorEnabled()
+ {
+ return getComponent().isSynchronize();
+ }
}
Modified: trunk/src/main/org/jboss/seam/core-2.1.xsd
===================================================================
--- trunk/src/main/org/jboss/seam/core-2.1.xsd 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/core-2.1.xsd 2008-08-07 19:50:09 UTC (rev 8626)
@@ -15,9 +15,26 @@
</xs:annotation>
<xs:complexType mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element name="disabled-interceptors" type="components:multiValuedProperty">
+ <xs:element name="interceptors" type="components:multiValuedProperty">
<xs:annotation>
- <xs:documentation>A list of interceptors that should be disabled for all components</xs:documentation>
+ <xs:documentation>A list of interceptors that should be enabled for all components. You must specify all built-in interceptors as well as any extras interceptors.
+
+These interceptors are enabled by default:
+ org.jboss.seam.core.SynchronizationInterceptor
+ org.jboss.seam.async.AsynchronousInterceptor
+ org.jboss.seam.ejb.RemoveInterceptor
+ org.jboss.seam.persistence.HibernateSessionProxyInterceptor
+ org.jboss.seam.persistence.EntityManagerProxyInterceptor
+ org.jboss.seam.core.MethodContextInterceptor
+ org.jboss.seam.core.EventInterceptor
+ org.jboss.seam.core.ConversationalInterceptor
+ org.jboss.seam.bpm.BusinessProcessInterceptor
+ org.jboss.seam.core.ConversationInterceptor
+ org.jboss.seam.core.BijectionInterceptor.class
+ org.jboss.seam.transaction.RollbackInterceptor.class.getName(),
+ org.jboss.seam.transaction.TransactionInterceptor.class.getName(),
+ org.jboss.seam.webservice.WSSecurityInterceptor.class.getName(),
+ org.jboss.seam.security.SecurityInterceptor.class.getName()</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
@@ -31,7 +48,6 @@
<xs:attribute name="jndi-pattern" type="components:string" />
<xs:attribute name="transaction-management-enabled" type="components:boolean"/>
<xs:attribute name="user-transaction-name" type="components:string"/>
- <xs:attribute name="disabled-interceptors" type="components:string" />
</xs:attributeGroup>
<xs:element name="manager">
Modified: trunk/src/main/org/jboss/seam/ejb/RemoveInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/ejb/RemoveInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/ejb/RemoveInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -1,6 +1,8 @@
//$Id$
package org.jboss.seam.ejb;
+import static org.jboss.seam.ComponentType.STATEFUL_SESSION_BEAN;
+
import java.lang.reflect.Method;
import java.rmi.RemoteException;
@@ -83,5 +85,10 @@
log.debug( "Stateful component was removed: " + getComponent().getName() );
}
}
+
+ public boolean isInterceptorEnabled()
+ {
+ return getComponent().getType() == STATEFUL_SESSION_BEAN;
+ }
}
Modified: trunk/src/main/org/jboss/seam/init/Initialization.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/Initialization.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/init/Initialization.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -606,6 +606,7 @@
{
init.setJbpmInstalled(true);
}
+ init.checkDefaultInterceptors();
init.setTimestamp( System.currentTimeMillis() );
if (hotDeploymentStrategy != null)
{
Modified: trunk/src/main/org/jboss/seam/intercept/Interceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/intercept/Interceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/intercept/Interceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -31,6 +31,7 @@
private Method prePassivateMethod;
private Method componentInjectorMethod;
private Method annotationInjectorMethod;
+ private Method interceptorEnabledMethod;
private InterceptorType type;
private Annotation annotation;
private Component component;
@@ -158,6 +159,12 @@
componentInjectorMethod = method;
Reflections.invokeAndWrap(method, statelessUserInterceptorInstance, component);
}
+ // if there is an interceptor enabled method, store it
+ if ( "isInterceptorEnabled".equals(method.getName()) && method.getReturnType().equals(boolean.class) )
+ {
+ interceptorEnabledMethod = method;
+ }
+
}
type = userInterceptorClass.isAnnotationPresent(org.jboss.seam.annotations.intercept.Interceptor.class) ?
@@ -207,4 +214,30 @@
Reflections.invoke( postActivateMethod, userInterceptor, invocation );
}
+ /**
+ * Return true if the interceptor should be enabled for the component instance
+ *
+ * Should only be called during deployment
+ */
+ public boolean isInterceptorEnabled()
+ {
+ if (interceptorEnabledMethod != null)
+ {
+ // Set up component metadata
+ if (componentInjectorMethod!=null)
+ {
+ Reflections.invokeAndWrap(componentInjectorMethod, statelessUserInterceptorInstance, component);
+ }
+ if (annotationInjectorMethod!=null)
+ {
+ Reflections.invokeAndWrap(annotationInjectorMethod, statelessUserInterceptorInstance, annotation);
+ }
+ return ((Boolean) Reflections.invokeAndWrap(interceptorEnabledMethod, statelessUserInterceptorInstance));
+ }
+ else
+ {
+ return true;
+ }
+ }
+
}
Modified: trunk/src/main/org/jboss/seam/persistence/EntityManagerProxyInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/persistence/EntityManagerProxyInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/persistence/EntityManagerProxyInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -1,5 +1,8 @@
package org.jboss.seam.persistence;
+import static org.jboss.seam.ComponentType.STATEFUL_SESSION_BEAN;
+import static org.jboss.seam.ComponentType.STATELESS_SESSION_BEAN;
+
import javax.annotation.PostConstruct;
import javax.ejb.PostActivate;
import javax.persistence.EntityManager;
@@ -55,4 +58,10 @@
}
}
}
+
+ public boolean isInterceptorEnabled()
+ {
+ return getComponent().getType()==STATEFUL_SESSION_BEAN || getComponent().getType()==STATELESS_SESSION_BEAN;
+ }
+
}
Modified: trunk/src/main/org/jboss/seam/persistence/HibernateSessionProxyInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/persistence/HibernateSessionProxyInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/persistence/HibernateSessionProxyInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -1,5 +1,8 @@
package org.jboss.seam.persistence;
+import static org.jboss.seam.ComponentType.STATEFUL_SESSION_BEAN;
+import static org.jboss.seam.ComponentType.STATELESS_SESSION_BEAN;
+
import javax.annotation.PostConstruct;
import javax.ejb.PostActivate;
@@ -9,6 +12,7 @@
import org.jboss.seam.annotations.intercept.Interceptor;
import org.jboss.seam.intercept.AbstractInterceptor;
import org.jboss.seam.intercept.InvocationContext;
+import org.jboss.seam.util.Reflections;
/**
* Proxy the Hibernate Session if injected using @PersistenceContext
@@ -56,6 +60,9 @@
}
}
-
+ public boolean isInterceptorEnabled()
+ {
+ return (getComponent().getType()==STATEFUL_SESSION_BEAN || getComponent().getType()==STATELESS_SESSION_BEAN) && Reflections.isClassAvailable("org.hibernate.Session");
+ }
}
Modified: trunk/src/main/org/jboss/seam/persistence/ManagedEntityIdentityInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/persistence/ManagedEntityIdentityInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/persistence/ManagedEntityIdentityInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -1,5 +1,6 @@
package org.jboss.seam.persistence;
+import static org.jboss.seam.ScopeType.CONVERSATION;
import static org.jboss.seam.util.JSF.DATA_MODEL;
import static org.jboss.seam.util.JSF.getWrappedData;
import static org.jboss.seam.util.JSF.setWrappedData;
@@ -35,6 +36,11 @@
{
private boolean reentrant;
//TODO: cache the non-ignored fields, probably on Component
+
+ public boolean isInterceptorEnabled()
+ {
+ return getComponent().getScope() == CONVERSATION;
+ }
@AroundInvoke
public Object aroundInvoke(InvocationContext ctx) throws Exception
Modified: trunk/src/main/org/jboss/seam/security/SecurityInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/SecurityInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/security/SecurityInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -262,4 +262,9 @@
return String.format( "#{s:hasPermission('%s','%s')}",
getComponent().getName(), method.getName() );
}
+
+ public boolean isInterceptorEnabled()
+ {
+ return getComponent().isSecure() && !getComponent().beanClassHasAnnotation("javax.jws.WebService");
+ }
}
Modified: trunk/src/main/org/jboss/seam/transaction/RollbackInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/transaction/RollbackInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/transaction/RollbackInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -41,4 +41,10 @@
}
}
+ public boolean isInterceptorEnabled()
+ {
+ // Just here for consistency
+ return true;
+ }
+
}
Modified: trunk/src/main/org/jboss/seam/transaction/TransactionInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/transaction/TransactionInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/transaction/TransactionInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -1,5 +1,7 @@
package org.jboss.seam.transaction;
+import static org.jboss.seam.ComponentType.JAVA_BEAN;
+
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
@@ -64,4 +66,9 @@
}.workInTransaction();
}
+ public boolean isInterceptorEnabled()
+ {
+ return getComponent().getType()==JAVA_BEAN && getComponent().beanClassHasAnnotation(Transactional.class);
+ }
+
}
Modified: trunk/src/main/org/jboss/seam/webservice/WSSecurityInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/seam/webservice/WSSecurityInterceptor.java 2008-08-07 15:03:11 UTC (rev 8625)
+++ trunk/src/main/org/jboss/seam/webservice/WSSecurityInterceptor.java 2008-08-07 19:50:09 UTC (rev 8626)
@@ -15,4 +15,9 @@
public class WSSecurityInterceptor extends SecurityInterceptor
{
+ public boolean isInterceptorEnabled()
+ {
+ return getComponent().isSecure() && getComponent().beanClassHasAnnotation("javax.jws.WebService");
+ }
+
}
More information about the seam-commits
mailing list