5e2fffe4829009b1d67cc26c8f66bc2808b776a7
[xmlrouter] / impl / src / main / java / org / wamblee / xmlrouter / impl / SingleRouterConfig.java
1 /*
2  * Copyright 2005-2011 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 package org.wamblee.xmlrouter.impl;
17
18 import org.wamblee.xmlrouter.common.Id;
19 import org.wamblee.xmlrouter.config.Config;
20 import org.wamblee.xmlrouter.config.DocumentType;
21 import org.wamblee.xmlrouter.config.Filter;
22 import org.wamblee.xmlrouter.config.RouterConfig;
23 import org.wamblee.xmlrouter.config.Transformation;
24
25 /**
26  * Represents a single configuration set of a single configuration client of the
27  * XML router.
28  * 
29  * @author Erik Brakkee
30  */
31 public class SingleRouterConfig implements ExtendedRouterConfig {
32     private Id<RouterConfig> id;
33     private ExtendedConfig<DocumentType> documentTypes;
34     private ExtendedConfig<Transformation> transformations;
35     private ExtendedConfig<Filter> filters;
36
37     /**
38      * Constructs a router configuration.
39      * 
40      * @param aSequenceNumberGenerator
41      *            Sequence number generator to use.
42      */
43     public SingleRouterConfig(Id<RouterConfig> aId) {
44         id = aId;
45         documentTypes = new ConfigImpl<DocumentType>(new Id<Config>(
46             "documentTypes")) {
47             @Override
48             public DocumentType wrap(DocumentType aT) {
49                 return new RobustDocumentType(aT);
50             }
51         };
52         transformations = new ConfigImpl<Transformation>(new Id<Config>(
53             "transformations")) {
54             @Override
55             public Transformation wrap(Transformation aTransformation) {
56                 return new RobustTransformation(aTransformation);
57             }
58         };
59         filters = new ConfigImpl<Filter>(new Id<Config>("filters")) {
60             @Override
61             public Filter wrap(Filter aFilter) {
62                 return new RobustFilter(aFilter);
63             }
64         };
65     }
66
67     // TODO test getId.
68     @Override
69     public Id<RouterConfig> getId() {
70         return id;
71     }
72
73     @Override
74     public Config<DocumentType> documentTypeConfig() {
75         return documentTypes;
76     }
77
78     @Override
79     public Config<Transformation> transformationConfig() {
80         return transformations;
81     }
82
83     @Override
84     public Config<Filter> filterConfig() {
85         return filters;
86     }
87 }