1.web.xml
<!-- compass -->
<servlet>
<servlet-name>compass</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>compass</servlet-name>
<url-pattern>*.cmp</url-pattern>
</servlet-mapping>
2.compass-servlet.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!--
- DispatcherServlet application context for Petclinic's web tier.
-->
<beans>
<!-- ========================= MESSAGE SOURCE DEFINITION ========================= -->
<!--
- Message source for this context, loaded from localized "messages_xx" files.
- Could also reside in the root application context, as it is generic,
- but is currently just used within Petclinic's web tier.
-->
<bean id="messageSources"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename">
<value>messages</value>
</property>
</bean>
<!-- ========================= MAPPING DEFINITIONS ========================= -->
<!--
- This bean provides explicit View mappings in a resource bundle instead of the
- default InternalResourceViewResolver. It fetches the view mappings from
- localized "views_xx" classpath files, i.e. "/WEB-INF/classes/views.properties"
- or "/WEB-INF/classes/views_de.properties".
-
- Symbolic view names returned by Controllers will be resolved by this bean
- using the respective properties file, which defines arbitrary mappings between
- view names and resources.
-->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="basename">
<value>views</value>
</property>
</bean>
<!--
- This bean resolves specific types of exception to corresponding error views.
- The default behaviour of DispatcherServlet is to propagate all exceptions to the
- servlet container: This will happen here with all other types of exception.
-->
<bean id="exceptionResolver"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="org.compass.core.CompassException">
dataAccessFailure
</prop>
<prop
key="org.springframework.dao.DataAccessException">
dataAccessFailure
</prop>
<prop
key="org.springframework.transaction.TransactionException">
dataAccessFailure
</prop>
</props>
</property>
</bean>
<!--
- This bean is an explicit URL mapper that is used by the "petclinic" DispatcherServlet
- It is used instead of the default BeanNameUrlHandlerMapping.
-->
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/buildindex.cmp">indexController</prop>
<prop key="/search.cmp">searchController</prop>
</props>
</property>
</bean>
<!-- ========================= CONTROLLER DEFINITIONS ========================= -->
<!-- 默认的SearchController -->
<!--
<bean id="searchController" class="org.compass.spring.web.mvc.CompassSearchController">
<property name="compass"><ref bean="compass"/></property>
<property name="searchView"><value>searchView</value></property>
<property name="searchResultsView"><value>searchResultsView</value></property>
<property name="pageSize"><value>3</value></property>
<property name="searchHelper" ref="advanceCompassSearchHelper" />
</bean>
-->
<!-- 自定义的SearchController -->
<bean id="searchController"
class="com.stone.service.impl.SearchController" lazy-init="true">
<property name="compass" ref="compass" />
<property name="searchView" value="search.jsp" />
<property name="searchResultsView" value="searchResultsView" />
<property name="pageSize" value="10" />
<property name="sectionSize" value="10" />
<property name="searchHelper">
<ref bean="advanceCompassSearchHelper" />
</property>
</bean>
<bean id="indexController"
class="org.compass.spring.web.mvc.CompassIndexController">
<property name="compassGps">
<ref bean="compassGps" />
</property>
<property name="indexView">
<value>indexView</value>
</property>
<property name="indexResultsView">
<value>indexResultsView</value>
</property>
</bean>
</beans>
3.applicationContext-compass.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "/WEB-INF/dtd/spring-beans.dtd">
<beans>
<bean id="compassConfiguration"
class="org.compass.core.config.CompassConfiguration" />
<bean id="compass" class="org.compass.spring.LocalCompassBean">
<!-- 这里配置用作建立索引的映射文件 -->
<property name="resourceDirectoryLocations">
<list>
<value>classpath:com/stone/compass/cpm</value>
</list>
</property>
<property name="compassConfiguration"
ref="compassConfiguration" />
<property name="compassSettings">
<props>
<prop key="compass.transaction.factory">
org.compass.spring.transaction.SpringSyncTransactionFactory
</prop>
<prop key="compass.engine.connection">target/test</prop>
<prop key="compass.engine.mergeFactor">100</prop>
<prop key="compass.engine.maxBufferedDocs">1000</prop>
<prop key="compass.engine.maxFieldLength">10000</prop>
<!--
<prop key="compass.engine.analyzer.default.type">
org.mira.lucene.analysis.IK_CAnalyzer
</prop>
-->
<prop key="compass.engine.highlighter.default.formatter.simple.pre">
<![CDATA[<font color="red"><b>]]>
</prop>
<prop key="compass.engine.highlighter.default.formatter.simple.post">
<![CDATA[</b></font>]]>
</prop>
</props>
</property>
<property name="transactionManager" ref="transactionManager" />
</bean>
<bean id="compassTemplate"
class="org.compass.core.CompassTemplate">
<property name="compass">
<ref bean="compass" />
</property>
</bean>
<bean id="ibatisGpsDevice"
class="org.compass.gps.device.ibatis.SqlMapClientGpsDevice">
<property name="name">
<value>ibatisDevice</value>
</property>
<property name="sqlMapClient">
<ref bean="sqlMapClient"/>
</property>
<property name="selectStatementsIds">
<list>
<value>selectTest</value>
</list>
</property>
</bean>
<bean id="compassGps" class="org.compass.gps.impl.SingleCompassGps"
init-method="start" destroy-method="stop">
<property name="compass" ref="compass" />
<property name="gpsDevices">
<list>
<bean class="org.compass.spring.device.SpringSyncTransactionGpsDeviceWrapper">
<property name="gpsDevice" ref="ibatisGpsDevice"/>
</bean>
</list>
</property>
</bean>
<bean id="compassCreateAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<bean class="org.compass.spring.aop.CompassCreateAdvice">
<property name="compass" ref="compass"/>
</bean>
</property>
<property name="patterns">
<list>
<value>.*addJobTrans</value>
<value>.*createResume</value>
<value>.*create</value>
</list>
</property>
</bean>
<bean id="compassSaveAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<bean class="org.compass.spring.aop.CompassSaveAdvice">
<property name="compass" ref="compass"/>
</bean>
</property>
<property name="patterns">
<list>
<value>.*modifyJobTrans</value>
<value>.*operationResume</value>
</list>
</property>
</bean>
<bean id="compassDeleteAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<bean class="org.compass.spring.aop.CompassDeleteAdvice">
<property name="compass" ref="compass"/>
</bean>
</property>
<property name="patterns">
<list>
<value>.*deleteJob</value>
<value>.*batchDelete</value>
<value>.*operationResume</value>
</list>
</property>
</bean>
<bean id="myAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<bean class="com.stone.service.impl.BeforeAdvice"/>
</property>
<property name="pattern" value=".*addJobTrans"/>
</bean>
<bean id="proxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<idref bean="jobService"/>
<idref bean="resumeService"/>
<!-- <idref bean="articleDao"/>-->
</list>
</property>
<property name="proxyTargetClass" value="false"/>
<property name="interceptorNames">
<list>
<value>compassCreateAdvisor</value>
<value>compassSaveAdvisor</value>
<value>compassDeleteAdvisor</value>
<value>myAdvisor</value>
</list>
</property>
</bean>
<bean id="advanceCompassSearchHelper"
class="com.stone.service.impl.AdvanceCompassSearchHelper">
<property name="highlightFields">
<list>
<value>jobName</value>
<value>resumeName</value>
</list>
</property>
<constructor-arg ref="compass" />
</bean>
</beans>
<!-- compass -->
<servlet>
<servlet-name>compass</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>compass</servlet-name>
<url-pattern>*.cmp</url-pattern>
</servlet-mapping>
2.compass-servlet.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!--
- DispatcherServlet application context for Petclinic's web tier.
-->
<beans>
<!-- ========================= MESSAGE SOURCE DEFINITION ========================= -->
<!--
- Message source for this context, loaded from localized "messages_xx" files.
- Could also reside in the root application context, as it is generic,
- but is currently just used within Petclinic's web tier.
-->
<bean id="messageSources"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename">
<value>messages</value>
</property>
</bean>
<!-- ========================= MAPPING DEFINITIONS ========================= -->
<!--
- This bean provides explicit View mappings in a resource bundle instead of the
- default InternalResourceViewResolver. It fetches the view mappings from
- localized "views_xx" classpath files, i.e. "/WEB-INF/classes/views.properties"
- or "/WEB-INF/classes/views_de.properties".
-
- Symbolic view names returned by Controllers will be resolved by this bean
- using the respective properties file, which defines arbitrary mappings between
- view names and resources.
-->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="basename">
<value>views</value>
</property>
</bean>
<!--
- This bean resolves specific types of exception to corresponding error views.
- The default behaviour of DispatcherServlet is to propagate all exceptions to the
- servlet container: This will happen here with all other types of exception.
-->
<bean id="exceptionResolver"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="org.compass.core.CompassException">
dataAccessFailure
</prop>
<prop
key="org.springframework.dao.DataAccessException">
dataAccessFailure
</prop>
<prop
key="org.springframework.transaction.TransactionException">
dataAccessFailure
</prop>
</props>
</property>
</bean>
<!--
- This bean is an explicit URL mapper that is used by the "petclinic" DispatcherServlet
- It is used instead of the default BeanNameUrlHandlerMapping.
-->
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/buildindex.cmp">indexController</prop>
<prop key="/search.cmp">searchController</prop>
</props>
</property>
</bean>
<!-- ========================= CONTROLLER DEFINITIONS ========================= -->
<!-- 默认的SearchController -->
<!--
<bean id="searchController" class="org.compass.spring.web.mvc.CompassSearchController">
<property name="compass"><ref bean="compass"/></property>
<property name="searchView"><value>searchView</value></property>
<property name="searchResultsView"><value>searchResultsView</value></property>
<property name="pageSize"><value>3</value></property>
<property name="searchHelper" ref="advanceCompassSearchHelper" />
</bean>
-->
<!-- 自定义的SearchController -->
<bean id="searchController"
class="com.stone.service.impl.SearchController" lazy-init="true">
<property name="compass" ref="compass" />
<property name="searchView" value="search.jsp" />
<property name="searchResultsView" value="searchResultsView" />
<property name="pageSize" value="10" />
<property name="sectionSize" value="10" />
<property name="searchHelper">
<ref bean="advanceCompassSearchHelper" />
</property>
</bean>
<bean id="indexController"
class="org.compass.spring.web.mvc.CompassIndexController">
<property name="compassGps">
<ref bean="compassGps" />
</property>
<property name="indexView">
<value>indexView</value>
</property>
<property name="indexResultsView">
<value>indexResultsView</value>
</property>
</bean>
</beans>
3.applicationContext-compass.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "/WEB-INF/dtd/spring-beans.dtd">
<beans>
<bean id="compassConfiguration"
class="org.compass.core.config.CompassConfiguration" />
<bean id="compass" class="org.compass.spring.LocalCompassBean">
<!-- 这里配置用作建立索引的映射文件 -->
<property name="resourceDirectoryLocations">
<list>
<value>classpath:com/stone/compass/cpm</value>
</list>
</property>
<property name="compassConfiguration"
ref="compassConfiguration" />
<property name="compassSettings">
<props>
<prop key="compass.transaction.factory">
org.compass.spring.transaction.SpringSyncTransactionFactory
</prop>
<prop key="compass.engine.connection">target/test</prop>
<prop key="compass.engine.mergeFactor">100</prop>
<prop key="compass.engine.maxBufferedDocs">1000</prop>
<prop key="compass.engine.maxFieldLength">10000</prop>
<!--
<prop key="compass.engine.analyzer.default.type">
org.mira.lucene.analysis.IK_CAnalyzer
</prop>
-->
<prop key="compass.engine.highlighter.default.formatter.simple.pre">
<![CDATA[<font color="red"><b>]]>
</prop>
<prop key="compass.engine.highlighter.default.formatter.simple.post">
<![CDATA[</b></font>]]>
</prop>
</props>
</property>
<property name="transactionManager" ref="transactionManager" />
</bean>
<bean id="compassTemplate"
class="org.compass.core.CompassTemplate">
<property name="compass">
<ref bean="compass" />
</property>
</bean>
<bean id="ibatisGpsDevice"
class="org.compass.gps.device.ibatis.SqlMapClientGpsDevice">
<property name="name">
<value>ibatisDevice</value>
</property>
<property name="sqlMapClient">
<ref bean="sqlMapClient"/>
</property>
<property name="selectStatementsIds">
<list>
<value>selectTest</value>
</list>
</property>
</bean>
<bean id="compassGps" class="org.compass.gps.impl.SingleCompassGps"
init-method="start" destroy-method="stop">
<property name="compass" ref="compass" />
<property name="gpsDevices">
<list>
<bean class="org.compass.spring.device.SpringSyncTransactionGpsDeviceWrapper">
<property name="gpsDevice" ref="ibatisGpsDevice"/>
</bean>
</list>
</property>
</bean>
<bean id="compassCreateAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<bean class="org.compass.spring.aop.CompassCreateAdvice">
<property name="compass" ref="compass"/>
</bean>
</property>
<property name="patterns">
<list>
<value>.*addJobTrans</value>
<value>.*createResume</value>
<value>.*create</value>
</list>
</property>
</bean>
<bean id="compassSaveAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<bean class="org.compass.spring.aop.CompassSaveAdvice">
<property name="compass" ref="compass"/>
</bean>
</property>
<property name="patterns">
<list>
<value>.*modifyJobTrans</value>
<value>.*operationResume</value>
</list>
</property>
</bean>
<bean id="compassDeleteAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<bean class="org.compass.spring.aop.CompassDeleteAdvice">
<property name="compass" ref="compass"/>
</bean>
</property>
<property name="patterns">
<list>
<value>.*deleteJob</value>
<value>.*batchDelete</value>
<value>.*operationResume</value>
</list>
</property>
</bean>
<bean id="myAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<bean class="com.stone.service.impl.BeforeAdvice"/>
</property>
<property name="pattern" value=".*addJobTrans"/>
</bean>
<bean id="proxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<idref bean="jobService"/>
<idref bean="resumeService"/>
<!-- <idref bean="articleDao"/>-->
</list>
</property>
<property name="proxyTargetClass" value="false"/>
<property name="interceptorNames">
<list>
<value>compassCreateAdvisor</value>
<value>compassSaveAdvisor</value>
<value>compassDeleteAdvisor</value>
<value>myAdvisor</value>
</list>
</property>
</bean>
<bean id="advanceCompassSearchHelper"
class="com.stone.service.impl.AdvanceCompassSearchHelper">
<property name="highlightFields">
<list>
<value>jobName</value>
<value>resumeName</value>
</list>
</property>
<constructor-arg ref="compass" />
</bean>
</beans>