package com.apobates.forum.core.impl;

import com.apobates.forum.core.entity.ActionEventDescriptor;
import com.apobates.forum.utils.cache.AbstractCubbyHole;
import com.apobates.forum.utils.cache.CubbyHoleLinkedDeque;
import com.apobates.forum.utils.cache.CubbyHoleProcessor;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.*;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * 
 * @author xiaofanku
 * @since 20200512
 */
@Configuration
@EnableCaching
@EnableAspectJAutoProxy(proxyTargetClass=true)
@EnableTransactionManagement(proxyTargetClass = true)
@ComponentScan(basePackages={"com.apobates.forum.core.impl"}, useDefaultFilters=false, includeFilters={@ComponentScan.Filter(classes={org.springframework.stereotype.Service.class}),@ComponentScan.Filter(classes={org.springframework.stereotype.Repository.class}),@ComponentScan.Filter(classes={org.springframework.stereotype.Component.class})})
@Import(value={RedisCoreEventConfig.class})
public class CoreAppConfig {
    @Bean
    public CoreModuleActionEventAspect buildCmae() {
        return new com.apobates.forum.core.impl.CoreModuleActionEventAspect();
    }
    
    @Bean
    public CubbyHoleProcessor<ActionEventDescriptor> getCubbyHoleProcessor(){
        return new ActionEventCubbyHoleProcessor();
    }
    
    @Bean("cubbyHole")
    public AbstractCubbyHole<ActionEventDescriptor> getCubbyHole(CubbyHoleProcessor<ActionEventDescriptor> cubbyHoleProcessor){
        return new CubbyHoleLinkedDeque<>(cubbyHoleProcessor);
    }
}