1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 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>Access-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 }