KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > beans > factory > parsing > ReaderContext


1 /*
2  * Copyright 2002-2007 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.beans.factory.parsing;
18
19 import org.springframework.core.io.Resource;
20
21 /**
22  * Context that gets passed along a bean definition reading process,
23  * encapsulating all relevant configuration as well as state.
24  *
25  * @author Rob Harrop
26  * @author Juergen Hoeller
27  * @since 2.0
28  */

29 public class ReaderContext {
30
31     private final Resource resource;
32
33     private final ProblemReporter problemReporter;
34
35     private final ReaderEventListener eventListener;
36
37     private final SourceExtractor sourceExtractor;
38
39
40     public ReaderContext(Resource resource, ProblemReporter problemReporter,
41             ReaderEventListener eventListener, SourceExtractor sourceExtractor) {
42
43         this.resource = resource;
44         this.problemReporter = problemReporter;
45         this.eventListener = eventListener;
46         this.sourceExtractor = sourceExtractor;
47     }
48
49     public final Resource getResource() {
50         return this.resource;
51     }
52
53
54     public void fatal(String JavaDoc message, Object JavaDoc source) {
55         fatal(message, source, null, null);
56     }
57
58     public void fatal(String JavaDoc message, Object JavaDoc source, Throwable JavaDoc ex) {
59         fatal(message, source, null, ex);
60     }
61
62     public void fatal(String JavaDoc message, Object JavaDoc source, ParseState parseState) {
63         fatal(message, source, parseState, null);
64     }
65
66     public void fatal(String JavaDoc message, Object JavaDoc source, ParseState parseState, Throwable JavaDoc cause) {
67         Location location = new Location(getResource(), source);
68         this.problemReporter.fatal(new Problem(message, location, parseState, cause));
69     }
70
71     public void error(String JavaDoc message, Object JavaDoc source) {
72         error(message, source, null, null);
73     }
74
75     public void error(String JavaDoc message, Object JavaDoc source, Throwable JavaDoc ex) {
76         error(message, source, null, ex);
77     }
78
79     public void error(String JavaDoc message, Object JavaDoc source, ParseState parseState) {
80         error(message, source, parseState, null);
81     }
82
83     public void error(String JavaDoc message, Object JavaDoc source, ParseState parseState, Throwable JavaDoc cause) {
84         Location location = new Location(getResource(), source);
85         this.problemReporter.error(new Problem(message, location, parseState, cause));
86     }
87
88     public void warning(String JavaDoc message, Object JavaDoc source) {
89         warning(message, source, null, null);
90     }
91
92     public void warning(String JavaDoc message, Object JavaDoc source, Throwable JavaDoc ex) {
93         warning(message, source, null, ex);
94     }
95
96     public void warning(String JavaDoc message, Object JavaDoc source, ParseState parseState) {
97         warning(message, source, parseState, null);
98     }
99
100     public void warning(String JavaDoc message, Object JavaDoc source, ParseState parseState, Throwable JavaDoc cause) {
101         Location location = new Location(getResource(), source);
102         this.problemReporter.warning(new Problem(message, location, parseState, cause));
103     }
104
105
106     public void fireDefaultsRegistered(DefaultsDefinition defaultsDefinition) {
107         this.eventListener.defaultsRegistered(defaultsDefinition);
108     }
109
110     public void fireComponentRegistered(ComponentDefinition componentDefinition) {
111         this.eventListener.componentRegistered(componentDefinition);
112     }
113
114     public void fireAliasRegistered(String JavaDoc beanName, String JavaDoc alias, Object JavaDoc source) {
115         this.eventListener.aliasRegistered(new AliasDefinition(beanName, alias, source));
116     }
117
118     public void fireImportProcessed(String JavaDoc importedResource, Object JavaDoc source) {
119         this.eventListener.importProcessed(new ImportDefinition(importedResource, source));
120     }
121
122
123     public SourceExtractor getSourceExtractor() {
124         return this.sourceExtractor;
125     }
126
127     public Object JavaDoc extractSource(Object JavaDoc sourceCandidate) {
128         return this.sourceExtractor.extractSource(sourceCandidate, this.resource);
129     }
130
131 }
132
Popular Tags