1 /**
2 * $Id: BaseConfigurationImpl.java 58 2006-11-08 14:52:38Z maldito_orco $
3 *
4 * =========================================================================
5 *
6 * Copyright 2005 Tubo
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 package org.tubo.configuration.def.baseimpl;
21
22
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25
26 import org.tubo.configuration.def.*;
27
28 import org.tubo.exception.TuboConfigurationException;
29
30 import java.util.Map;
31 import java.util.HashMap;
32 import java.util.List;
33 import java.util.ArrayList;
34
35 /**
36 * <p></p>
37 * <p>
38 * Created: Jun 26, 2005 4:49:44 PM <br>
39 * Last Modification Date: $Date: 2006-11-08 11:52:38 -0300 (Wed, 08 Nov 2006) $
40 * </p>
41 *
42 * @author maldito_orco (maldito_orco@users.sourceforge.net)
43 * @version $Revision: 58 $
44 */
45 public class BaseConfigurationImpl implements Configuration {
46 public static final String RCS_ID = "$Id: BaseConfigurationImpl.java 58 2006-11-08 14:52:38Z maldito_orco $";
47 private static Log log = LogFactory.getLog(BaseConfigurationImpl.class);
48
49 private String kernelBuilderClassName = null;
50 private List includeDefs = new ArrayList();
51
52 private Map exceptionDefs = new HashMap();
53 private List messageResources = new ArrayList();
54
55 private Map connectionDefs = new HashMap();
56 private Map consumerDefs = new HashMap();
57 private Map componentDefs = new HashMap();
58 private Map flowDefs = new HashMap();
59
60 private Map referenceableItemDefs = new HashMap();
61
62
63 public String getKernelBuilderClassName() { return kernelBuilderClassName; }
64 public void setKernelBuilderClassName(String kernelBuilderClassName) {
65 this.kernelBuilderClassName = kernelBuilderClassName;
66 }
67
68 public boolean existId(String id) {
69 return (referenceableItemDefs.get(id) != null);
70 }
71 public ReferenceableItemDef getReferenceableItemDef(String id) {
72 return (ReferenceableItemDef)referenceableItemDefs.get(id);
73 }
74 protected void add(ReferenceableItemDef itemDef) throws TuboConfigurationException {
75 if (existId(itemDef.getId()))
76 throw new TuboConfigurationException("ID duplicated in configuration ["+itemDef.getId()+"]");
77 referenceableItemDefs.put(itemDef.getId(),itemDef);
78 }
79
80 public List getIncludeDefs() { return includeDefs; }
81 public IncludeDef getIncludeDef(String id) {
82 return (IncludeDef)getReferenceableItemDef(id);
83 }
84 public void add(IncludeDef includeDef) throws TuboConfigurationException {
85 includeDefs.add(includeDef);
86 }
87
88
89 public Map getExceptionDefs() { return exceptionDefs; }
90 public ExceptionDef getExceptionDef(String id) {
91 return (ExceptionDef)exceptionDefs.get(id);
92 }
93 public void add(ExceptionDef exceptionDef) throws TuboConfigurationException {
94 add((ReferenceableItemDef)exceptionDef);
95 exceptionDefs.put(exceptionDef.getId(),exceptionDef);
96 }
97
98 public List getMessageResources() { return messageResources; }
99 public void addMessagesResource(String resource) {
100 messageResources.add(resource);
101 }
102
103
104 public Map getConnectionDefs() { return connectionDefs; }
105 public ConnectionDef getConnectionDef(String id) {
106 return (ConnectionDef)connectionDefs.get(id);
107 }
108 public void add(ConnectionDef connectionDef) throws TuboConfigurationException {
109 add((ReferenceableItemDef)connectionDef);
110 connectionDefs.put(connectionDef.getId(),connectionDef);
111 }
112
113 public Map getConsumerDefs() { return consumerDefs; }
114 public ConsumerDef getConsumerDef(String id) {
115 return (ConsumerDef)consumerDefs.get(id);
116 }
117 public void add(ConsumerDef consumerDef) throws TuboConfigurationException {
118 add((ReferenceableItemDef)consumerDef);
119 consumerDefs.put(consumerDef.getId(),consumerDef);
120 }
121
122 public Map getComponentDefs() { return componentDefs; }
123 public ComponentDef getComponentDef(String id) {
124 return (ComponentDef)componentDefs.get(id);
125 }
126 public void add(ComponentDef componentDef) throws TuboConfigurationException {
127 add((ReferenceableItemDef)componentDef);
128 componentDefs.put(componentDef.getId(),componentDef);
129 }
130
131 public Map getFlowDefs() { return flowDefs; }
132 public FlowDef getFlowDef(String id) {
133 return (FlowDef)flowDefs.get(id);
134 }
135 public void add(FlowDef flowDef) throws TuboConfigurationException {
136 add((ReferenceableItemDef)flowDef);
137 flowDefs.put(flowDef.getId(),flowDef);
138 }
139
140 }