org.apache.myfaces.orchestra.conversation
Class CurrentConversationAdvice
java.lang.Object
org.apache.myfaces.orchestra.conversation.CurrentConversationAdvice
- All Implemented Interfaces:
- java.io.Serializable, org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor
public class CurrentConversationAdvice
- extends java.lang.Object
- implements org.aopalliance.intercept.MethodInterceptor, java.io.Serializable
An advice which is added to all conversation scoped beans.
It does the following:
A bean that is declared as belonging to a particular conversation is
always wrapped by the IOC system in a proxy object. When any method is
called on that proxy, the call is forwarded to the "invoke" method here.
This class then ensures that the "current conversation" is set to the
conversation configured for that target bean. The result is that the real
bean can call Conversation.getCurrentInstance() and always receives a
reference to the conversation object that has been configured for it.
In addition, on return from the target bean method, this object
checks whether the conversation has been marked as invalid. If so (and
the conversation is not in use by something further up the call stack)
then destroy the conversation object.
Attempting to invoke a methods on a bean that is associated with a
conversation that has been destroyed will cause an IllegalStateException
to be thrown. This is a safety-net to detect cases where a reference to a
proxy object bound to a specific conversation has been kept for longer than the
conversation lifetime. This is bad, as it (a) attempts to access a "stale"
conversation, and (b) prevents the destroyed conversation from being
garbage-collected (although all the beans in it will already have been
removed).
- See Also:
- Serialized Form
Method Summary |
java.lang.Object |
invoke(org.aopalliance.intercept.MethodInvocation methodInvocation)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CurrentConversationAdvice
public CurrentConversationAdvice(Conversation conversation,
java.lang.String beanName)
invoke
public java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation)
throws java.lang.Throwable
- Specified by:
invoke
in interface org.aopalliance.intercept.MethodInterceptor
- Throws:
java.lang.Throwable
Copyright © 2009 The Apache Software Foundation. All Rights Reserved.