public class SpringFactory extends Object
| Constructor and Description |
|---|
SpringFactory() |
| Modifier and Type | Method and Description |
|---|---|
static gate.FeatureMap |
createFeatureMap(Map<Object,Object> sourceMap)
Creates a feature map from a source map.
|
static Object |
loadObjectFromResource(org.springframework.core.io.Resource res)
Loads a saved application state (gapp file) from the given Spring
resource.
|
static URL |
resourceToUrl(org.springframework.core.io.Resource res)
Convert a Spring resource to a URL.
|
public static gate.FeatureMap createFeatureMap(Map<Object,Object> sourceMap) throws IOException
org.springframework.core.io.Resource are converted to
their corresponding URL. For example:
<bean id="feature-map" class="gate.util.spring.SpringFactory"
factory-method="createFeatureMap">
<constructor-arg>
<map>
<entry key="inputASName" value="Extra" />
<entry key="config">
<value type="org.springframework.core.io.Resource">path/to/config.xml</value>
</entry>
</map>
</constructor-arg>
</bean>
For an easier way to achieve this see FeatureMapFactoryBean,
to which this method delegates.IOExceptionpublic static Object loadObjectFromResource(org.springframework.core.io.Resource res) throws gate.util.GateException, IOException
File, and if
found the application is loaded using
loadObjectFromFile. If the resource cannot be accessed as a file
it is accessed as a URL and the application loaded with
loadObjectFromUrl
. This is useful as many PRs either require or function better with
file: URLs than with other kinds of URL. For an easier way to
achieve this, see SavedApplicationFactoryBean, to which
this method delegates.gate.util.GateExceptionIOExceptionpublic static URL resourceToUrl(org.springframework.core.io.Resource res) throws IOException
File, and if this succeeds then the file is converted
to a URL. If the resource cannot be accessed as a file then it is
converted directly to a URL. This is useful as many PRs either
require or function better with file: URLs than with other kinds of
URL. In a Spring configuration this method may be accessed using
the shorthand
<gate:url>WEB-INF/file.txt</gate:url>IOExceptionCopyright © 2023 GATE. All rights reserved.