1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.orchestra.conversation;
20
21 import java.util.HashMap;
22 import java.util.Map;
23
24 /***
25 * Maintains a list of aspects the system might attach to a conversation instance.
26 * <p>
27 * Aspects are a way of extending the functionality of a class without modifying it;
28 * it acts something like the "decorator" pattern, but with many different decorator
29 * classes being supported at once.
30 * <p>
31 * In the simplest form, an Aspect can be attached to a Conversation simply as a "marker"
32 * to indicate whether the conversation should be treated in a certain way or not.
33 * <p>
34 * In more sophisticated form, an Aspect can provide an API. Code that wants to
35 * manipulate some "conversation-related" property can query the conversation for the
36 * appropriate Aspect object, then invoke the aspect api to read or write the
37 * Conversation instance via an implementation that is isolated from both the caller
38 * and the Conversation.
39 * <p>
40 * Examples of aspects that can be attached to a conversation are:
41 * <ul>
42 * <li>Timeout handling</li>
43 * <li>Flash Scope handling</li>
44 * </ul>
45 */
46 public class ConversationAspects
47 {
48 private Map conversationAspects = new HashMap();
49
50 public void addAspect(ConversationAspect aspect)
51 {
52 conversationAspects.put(aspect.getClass().getName(), aspect);
53 }
54
55 public ConversationAspect getAspect(Class aspectClass)
56 {
57 return (ConversationAspect) conversationAspects.get(aspectClass.getName());
58 }
59 }