If you need more control, you can set up a CAE Feeder which does not automatically send updates to the search engine. Instead, you can use the public API to do so. Such a setup does not require a database. It is based on the CAE Feeder but requires some manual configuration.
For wiring such a Feeder, use the
following Spring bean definitions, for example, as file
config/feeder/spring/applicationContext.xml
.
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" 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"> <bean class="org.springframework.beans.factory.config. PropertyPlaceholderConfigurer"> <property name="ignoreUnresolvablePlaceholders" value="true"/> <property name="locations" value= "file:config/feeder/spring/environment.properties"/> </bean> <import resource= "classpath:/framework/spring/feeder/feeder-core.xml"/> <import resource= "classpath:/framework/spring/feeder/solr/feeder-solr.xml"/> <import resource= "classpath:/framework/spring/feeder/tika/feeder-tika.xml"/> <bean class="com.coremedia.springframework.context. LifecycleManager"> <property name="startableBeans" ref="feederStartables"/> </bean> </beans>
Example 5.12. caefeeder.xml
The first bean PropertyPlaceholderConfigurer
makes the CAE
Feeder use the settings from the configured property files. Create the file
environment.properties
with the search engine connection settings as follows:
feeder.solr.url=http://localhost:8082/solr/mycore feeder.solr.collection=collection
Next, required beans are imported using Spring import statements. To this end, you need the following libraries on your classpath as runtime dependencies.
<dependency> <groupId>com.coremedia.cms</groupId> <artifactId>cap-search-impl</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>com.coremedia.cms</groupId> <artifactId>cap-search-solr</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>com.coremedia.cms</groupId> <artifactId>cap-search-tika</artifactId> <scope>runtime</scope> </dependency>
The LifecycleManager
bean starts the feeder when the Spring application context is created and
stops it when the application context is closed.
In your custom Java code, access the Feeder API as follows. The example has a compile
dependency to the artifact cap-search-api
.
FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext( "config/feeder/spring/applicationContext.xml"); context.registerShutdownHook(); Feeder feeder = (Feeder)context.getBean("feeder"); FeedableFactory feedableFactory = (FeedableFactory)context.getBean("feedableFactory");
Example 5.13. Create CAE Feeder
First the Spring application context is created. FileSystemXmlApplicationContext
is part of the Spring Framework in the Java package
org.springframework.context.support
. The next statements retrieve
Feeder
and
FeedableFactory
implementations from the application context. You can use them to send data to the
Search Engine as described in the API documentation of the
Java package com.coremedia.cap.feeder
.