1 /*
2 * Copyright 2010, 2011 Christopher Pheby
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.jadira.bindings.core.loader;
17
18 import java.util.ArrayList;
19 import java.util.Collections;
20 import java.util.List;
21
22 /**
23 * Represents the contents of a bindings.xml configuration file. The
24 * configuration contains providers which represent implementations of a
25 * facility capable of resolving converters at runtime and binding configuration
26 * entries which specifically register converters for a given class
27 */
28 public class BindingConfiguration {
29
30 private List<Provider> providers = new ArrayList<Provider>();
31
32 private List<Extension<?>> extensions = new ArrayList<Extension<?>>();
33
34 private List<BindingConfigurationEntry> bindingEntries = new ArrayList<BindingConfigurationEntry>();
35
36 /**
37 * Return the registered providers
38 * @return List of {@link Provider}
39 */
40 public List<Provider> getProviders() {
41 return Collections.unmodifiableList(providers);
42 }
43
44 /**
45 * Registers a new provider
46 * @param provider The new {@link Provider}
47 */
48 public void addProvider(Provider provider) {
49 providers.add(provider);
50 }
51
52 /**
53 * Return the registered extensions
54 * @return List of {@link Extension}
55 */
56 public List<Extension<?>> getExtensions() {
57 return Collections.unmodifiableList(extensions);
58 }
59
60 /**
61 * Registers a new extension
62 * @param extension The new {@link Extension}
63 */
64 public void addExtension(Extension<?> extension) {
65 extensions.add(extension);
66 }
67
68 /**
69 * Return the registered {@link BindingConfigurationEntry} instances
70 * @return List of {@link BindingConfigurationEntry}
71 */
72 public List<BindingConfigurationEntry> getBindingEntries() {
73 return Collections.unmodifiableList(bindingEntries);
74 }
75
76 /**
77 * Registers a new binding entry
78 * @param bindingEntry The new {@link BindingConfigurationEntry}
79 */
80 public void addBindingEntry(BindingConfigurationEntry bindingEntry) {
81 bindingEntries.add(bindingEntry);
82 }
83 }