blob: a38d38881510c929e361e1a2161ffd7d5388b755 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/**
*
* Copyright 2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.tuscany.core.loader;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.apache.tuscany.core.config.ConfigurationLoadException;
import org.apache.tuscany.model.assembly.AssemblyContext;
import org.apache.tuscany.model.assembly.AssemblyObject;
/**
* Registry for XML loaders that can parse a StAX input stream and return model objects.
* <p/>
* Loaders will typically be contributed to the system by any extension that needs to
* handle extension specific information contained in some XML configuration file.
* The loader can be contributed as a system component with an autowire reference
* to this registry which is used during initialization to actually register.
* </p>
* This registry can also be used to parse an input stream, dispatching to the
* appropriate loader for each element accepted. Loaders can call back to the
* registry to load sub-elements that they are not able to handle directly.
*
* @version $Rev$ $Date$
*/
public interface StAXLoaderRegistry {
/**
* Register a loader. This operation will typically be called by a loader
* during its initialization.
*
* @param element the element that should be delegated to the contibuted loader
* @param loader a loader that is being contributed to the system
*/
<T extends AssemblyObject> void registerLoader(QName element, StAXElementLoader<T> loader);
/**
* Unregister a loader. This will typically be called by a loader as it is being destroyed.
*
* @param element the element that was being delegated to the contibuted loader
* @param loader a loader that should no longer be used
*/
<T extends AssemblyObject> void unregisterLoader(QName element, StAXElementLoader<T> loader);
/**
* Parse the supplied XML stream dispatching to the appropriate registered loader
* for each element encountered in the stream.
* <p/>
* This method must be called with the XML cursor positioned on a START_ELEMENT event.
* When this method returns, the stream will be positioned on the corresponding
* END_ELEMENT event.
*
* @param reader the XML stream to parse
* @param loaderContext
* @return the model object obtained by parsing the current element on the stream
* @throws XMLStreamException if there was a problem reading the stream
*/
AssemblyObject load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException;
/**
* Hack to allow loaders to initialize model objects on the fly.
* Remove when initialization has been moved from the model implementation to the loader.
*
* @return the model context for this load operation
*/
@Deprecated
AssemblyContext getContext();
/**
* Hack to allow loaders to initialize model objects on the fly.
* Remove when initialization has been moved from the model implementation to the loader.
*
* @param context the model context for this load operation
*/
@Deprecated
void setContext(AssemblyContext context);
}
|