01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.components;
18:
19: import java.util.HashMap;
20: import java.util.Map;
21:
22: import org.apache.cocoon.Processor;
23:
24: /**
25: *
26: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
27: * @deprecated This functionality will be replaced in 2.2 with a more flexible
28: * configuration mechanism.
29: * @version CVS $Id: DefaultSitemapConfigurationHolder.java 433543 2006-08-22 06:22:54Z crossley $
30: */
31: public final class DefaultSitemapConfigurationHolder implements
32: SitemapConfigurationHolder {
33:
34: /** The role of the sitemap component */
35: private String role;
36:
37: /** The prepared configurations indexed by the ChainedConfiguration */
38: private Map preparedConfigurations;
39:
40: public DefaultSitemapConfigurationHolder(String role) {
41: this .role = role;
42: }
43:
44: /**
45: * @see SitemapConfigurationHolder#getConfiguration()
46: */
47: public ChainedConfiguration getConfiguration() {
48: final Processor processor = CocoonComponentManager
49: .getCurrentProcessor();
50: if (processor == null) {
51: return null;
52: }
53: Map confs = processor.getComponentConfigurations();
54: return (ChainedConfiguration) (confs == null ? null : confs
55: .get(this .role));
56: }
57:
58: /**
59: * @see SitemapConfigurationHolder#getPreparedConfiguration()
60: */
61: public Object getPreparedConfiguration() {
62: if (null != this .preparedConfigurations) {
63: ChainedConfiguration conf = this .getConfiguration();
64: if (null != conf) {
65: return this .preparedConfigurations.get(conf);
66: }
67: }
68: return null;
69: }
70:
71: /**
72: * @see SitemapConfigurationHolder#setPreparedConfiguration(ChainedConfiguration, java.lang.Object)
73: */
74: public void setPreparedConfiguration(
75: ChainedConfiguration configuration, Object preparedConfig) {
76: if (null == this .preparedConfigurations) {
77: this .preparedConfigurations = new HashMap(5);
78: }
79: this.preparedConfigurations.put(configuration, preparedConfig);
80: }
81:
82: }
|