1 /*
2 * Copyright 2005-2010 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.springframework.ws.context;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.springframework.util.StringUtils;
23
24 /**
25 * Abstract base class for {@link MessageContext} instances.
26 *
27 * @author Arjen Poutsma
28 * @since 1.0.0
29 */
30 public abstract class AbstractMessageContext implements MessageContext {
31
32 /**
33 * Keys are <code>Strings</code>, values are <code>Objects</code>. Lazily initialized by
34 * <code>getProperties()</code>.
35 */
36 private Map<String, Object> properties;
37
38 public boolean containsProperty(String name) {
39 return getProperties().containsKey(name);
40 }
41
42 public Object getProperty(String name) {
43 return getProperties().get(name);
44 }
45
46 public String[] getPropertyNames() {
47 return StringUtils.toStringArray(getProperties().keySet());
48 }
49
50 public void removeProperty(String name) {
51 getProperties().remove(name);
52 }
53
54 public void setProperty(String name, Object value) {
55 getProperties().put(name, value);
56 }
57
58 private Map<String, Object> getProperties() {
59 if (properties == null) {
60 properties = new HashMap<String, Object>();
61 }
62 return properties;
63 }
64 }