<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<!--
  - Application context definition for PortletEntity using Apache OJB.
	-->
<beans>	
     
     <!-- define our caching service.  This one uses a simple hashmap and counts method access
     	- for testing purposes 
       -->
     <bean id="systemCache" class="org.apache.jetspeed.cache.general.InvocationCountingCache" />
     
     <!-- This interceptor is responsible for retreiving/adding objects to the cache. -->
     <bean id="systemCachingInterceptor" class="org.apache.jetspeed.components.interceptors.CachingInterceptor" >
    	<constructor-arg>
    		<ref bean="systemCache"/>
    	</constructor-arg>
     </bean>
    
    <!-- This interceptor is responsible for removing items from the cache -->
    <bean id="systemRemoveFromCacheInterceptor" class="org.apache.jetspeed.components.interceptors.RemoveFromCacheInterceptor" >
    	<constructor-arg>
    		<ref bean="systemCache"/>
    	</constructor-arg>
    </bean>   	
    
    <!-- We use a RegEx advisor to indicate when we should invoke the caching interceptor -->
    <bean id="mockCachingAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
        <property name="advice">
             <ref bean="systemCachingInterceptor"/>
        </property>
        <property name="patterns">
         <list>
            <value>.*getValue</value>
        </list>
       </property>
    </bean>
    
    <!-- We use a RegEx advisor to indicate when we should invoke the remove from cache interceptor -->
    <bean id="mockRemoveFromCacheAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
        <property name="advice">
             <ref bean="systemRemoveFromCacheInterceptor"/>
        </property>
        <property name="patterns">
         <list>
            <value>.*setValue</value>
        </list>
       </property>
    </bean>
    
    
    <!-- Simple object that will have its methods wrapped with cachinng aspects -->
    <bean id="baseMockTarget" class="org.apache.jetspeed.components.BaseMockComponent" >
    	<constructor-arg index="0">
    		<value>1</value> 		
    	</constructor-arg>
    	<constructor-arg index="1">
    		<value>value1</value> 		
    	</constructor-arg>
    </bean>
    
    <!-- Actual proxied component we will access from the bean factory.-->
	<bean id="mockComponent" 
         class="org.springframework.aop.framework.ProxyFactoryBean">
      <property name="proxyInterfaces">
      	<value>org.apache.jetspeed.components.MockComponent</value>
      </property>

      <property name="target"><ref local="baseMockTarget"/></property>
      <property name="interceptorNames">
        <list>
            <value>mockCachingAdvisor</value>
            <value>mockRemoveFromCacheAdvisor</value>
        </list>
      </property>
    </bean>


</beans>