Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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:

- Maintain the `Conversation.getCurrentInstance()`
- End the conversation if it has been invalidated

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

Constructor Summary
`CurrentConversationAdvice(Conversation conversation, java.lang.String beanName)`

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`

Constructor Detail

### CurrentConversationAdvice

    public CurrentConversationAdvice(Conversation conversation,
                                     java.lang.String beanName)

Method Detail

### 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`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 The Apache Software Foundation. All Rights Reserved.