gate.util.spring
Class SpringFactory

java.lang.Object
  extended by gate.util.spring.SpringFactory

public class SpringFactory
extends Object

This class contains spring-aware factory methods for useful GATE components. Most of these methods have now been superseded by (and delegate their processing to) the specific factory beans in this package, but are retained for compatibility with existing configurations.


Constructor Summary
SpringFactory()
           
 
Method Summary
static FeatureMap createFeatureMap(Map 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringFactory

public SpringFactory()
Method Detail

createFeatureMap

public static FeatureMap createFeatureMap(Map sourceMap)
                                   throws IOException
Creates a feature map from a source map. Any values in the source map that are of type 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.

Throws:
IOException

loadObjectFromResource

public static Object loadObjectFromResource(org.springframework.core.io.Resource res)
                                     throws GateException,
                                            IOException
Loads a saved application state (gapp file) from the given Spring resource. The resource is first looked up as a 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.

Throws:
GateException
IOException

resourceToUrl

public static URL resourceToUrl(org.springframework.core.io.Resource res)
                         throws IOException
Convert a Spring resource to a URL. The resource is first looked up as a 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>

Throws:
IOException