In fact, this could be probably implemented using a {{javax.enterprise.context.Conversation}} decorator and Weld Context Mgmt API - see also the pseudo-code below:
{code:java} @Priority(10) @Decorator abstract class ConversationDecorator implements Conversation {
@Inject @Delegate Conversation delegate; @Inject HttpConversationContext context; // Do the same for Conversation.begin(String) public void begin() { Collection<ManagedConversation> conversations = context.getConversations(); if (conversations.size() > LIMIT) { // ...iterate over conversations and end() those who that match some conditions } delegate.begin(); } } {code} |
|