public class Init extends Object implements org.springframework.beans.factory.BeanFactoryAware
Helper class to support GATE initialisation via Spring. The following is a typical XML fragment to initialise GATE.
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:gate="http://gate.ac.uk/ns/spring" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://gate.ac.uk/ns/spring http://gate.ac.uk/ns/spring.xsd"> <gate:init gate-home="path/to/GATE" site-config-file="site/gate.xml" user-config-file="user/gate.xml"> <gate:preload-plugins> <value>plugins/ANNIE</value> <value>http://plugins.org/another/plugin</value> </gate:preload-plugins> </gate:init>
Valid attributes are gate-home
,
plugins-home
, site-config-file
,
user-config-file
and builtin-creole-dir
-
Spring Resource
s corresponding to the equivalent static
set methods of Gate
. Also, preload-plugins
is a list of Resource
s that will be loaded as GATE
plugins after GATE is initialised.
Alternatively, instead of specifying gate-home
,
plugins-home
and the configuration files, specifying
run-in-sandbox="true"
will tell GATE to initialize without
reading any configuration files. See Gate.runInSandbox(boolean)
for
details.
As well as any plugins specified using preload-plugins
,
we also scan the defining bean factory for any beans of type
ExtraGatePlugin
, and load the plugins they refer to. This is
useful if bean definitions are provided in several separate files, or
if you are providing additional bean definitions to a context that
already defines an Init bean definition that you cannot edit.
The equivalent definition in "normal" Spring form (without the
gate:
namespace) would be:
<bean class="gate.util.spring.Init" init-method="init"> <property name="gateHome" value="path/to/GATE" /> <property name="siteConfigFile" value="site/gate.xml" /> <property name="userConfigFile" value="user/gate.xml" /> <property name="preloadPlugins"> <list> <value>plugins/ANNIE</value> <value>http://plugins.org/another/plugin</value> </list> </property> </bean>Note that when using this form the init-method="init" in the above definition is vital. GATE will not work if it is omitted.
Constructor and Description |
---|
Init() |
Modifier and Type | Method and Description |
---|---|
void |
init()
Initialises GATE and loads any preloadPlugins that have been
specified, as well as any defined by
ExtraGatePlugin beans
in the containing factory. |
void |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) |
void |
setBuiltinCreoleDir(org.springframework.core.io.Resource builtinCreoleDir) |
void |
setGateHome(org.springframework.core.io.Resource gateHome) |
void |
setMavenCaches(List<org.springframework.core.io.Resource> caches) |
void |
setPluginsHome(org.springframework.core.io.Resource pluginsHome) |
void |
setPreloadPlugins(List<org.springframework.core.io.Resource> plugins) |
void |
setRunInSandbox(boolean runInSandbox) |
void |
setSiteConfigFile(org.springframework.core.io.Resource siteConfigFile) |
void |
setUserConfigFile(org.springframework.core.io.Resource userConfigFile) |
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
setBeanFactory
in interface org.springframework.beans.factory.BeanFactoryAware
public void setGateHome(org.springframework.core.io.Resource gateHome) throws IOException
IOException
public void setPluginsHome(org.springframework.core.io.Resource pluginsHome) throws IOException
IOException
public void setSiteConfigFile(org.springframework.core.io.Resource siteConfigFile) throws IOException
IOException
public void setUserConfigFile(org.springframework.core.io.Resource userConfigFile) throws IOException
IOException
public void setBuiltinCreoleDir(org.springframework.core.io.Resource builtinCreoleDir) throws IOException
IOException
public void setRunInSandbox(boolean runInSandbox)
public void setMavenCaches(List<org.springframework.core.io.Resource> caches)
public void setPreloadPlugins(List<org.springframework.core.io.Resource> plugins)
public void init() throws Exception
ExtraGatePlugin
beans
in the containing factory.Exception
Copyright © 2023 GATE. All rights reserved.