父类bean无法注入问题

package com.alifi.hades.biz.access.rule.ctu;

import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.alifi.hades.biz.access.rule.AccessRule;
import com.alifi.hades.biz.crm.manager.CrmMemberManager;
import com.alifi.hades.common.model.CustListDO;
import com.alifi.hades.dal.dao.CustListDao;
import com.alifi.hyperion.common.model.Member;

/**
 * 黑名单准入规则
 *
 */
public abstract class AbstractCTUAccessRule implements AccessRule {
    private static final Log logger = LogFactory.getLog(AbstractCTUAccessRule.class);
    protected static final String KEY_MEMBER = "member";
    
    private CrmMemberManager crmMemberManager;
    private CustListDao       custListDao;


    public boolean checkAccess(String prodId, Map<String, Object> context) {
        if (context.containsKey(KEY_MEMBER)) {
            Member member = (Member) context.get(KEY_MEMBER);
            String site = crmMemberManager.getSiteBySource(member.getSource());
            String siteMemId = member.getUserId();
            String ruleCode = getAccessRuleCode();
            // 白名单
            CustListDO whiteList = custListDao.getWhiteListByRuleCode(site, siteMemId, ruleCode);
            if (whiteList != null) {
                logger.info("该规则的白名单用户,跳过此规则校验。ruleCode:" + ruleCode + "    siteMemId:" + siteMemId);
                return true;
            }
            return doCheckAccess(prodId, member);
        }
        return false;
    }


    protected abstract boolean doCheckAccess(String prodId, Member member);


    public void setCustListDao(CustListDao custListDao) {
        this.custListDao = custListDao;
    }


    public void setCrmMemberManager(CrmMemberManager crmMemberManager) {
        this.crmMemberManager = crmMemberManager;
    }

}





/*
 * Project: Hades
 * 
 * File Created at 2011-03-15
 * $Id$
 * 
 * Copyright 2011 B2B Technology, Alibaba.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Alibaba Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Alibaba.com.
 */

package com.alifi.hades.biz.access.rule.ctu;

import static com.alifi.hades.biz.common.util.TemplatedLog.log;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.alifi.ctu.service.BlackListService;
import com.alifi.hades.biz.common.dictionary.MsgTemplateDictionary.DataError;
import com.alifi.hades.biz.common.dictionary.MsgTemplateDictionary.RpcCallError;
import com.alifi.hades.biz.common.exception.LoanLogMsg;
import com.alifi.hades.biz.crm.manager.CrmMemberManager;
import com.alifi.hyperion.common.model.Member;

/**
 * 黑名单不准入
 *
 */
public class BlackListAccessRule extends AbstractCTUAccessRule {

    private static final Log logger = LogFactory.getLog(BlackListAccessRule.class);
    
    private CrmMemberManager crmMemberManager;
    
    private BlackListService blackListService;
    
    @Override
    /**
     * 黑名单不准入
     */
    protected boolean doCheckAccess(String prodId, Member member) {
        String site = crmMemberManager.getSiteBySource(member.getSource());
        String siteMemId = member.getUserId();
        try {
            if(blackListService.checkBlackListBySiteMemeber(site, siteMemId, prodId, "1")){
                logger.debug(log(DataError.UNEXPECTED, "黑名单用户不准入。siteMemId:" + siteMemId));
                return false;
            }else{
                return true;
            }
        } catch (Exception e) {
            logger.error(log(RpcCallError.MSG_00001, LoanLogMsg.BLACKLIST_EXCEPTION), e);
            return false;
        }
    }
    
    public String getAccessRuleCode() {
        return "2000";
    }

    
    public void setCrmMemberManager(CrmMemberManager crmMemberManager) {
        this.crmMemberManager = crmMemberManager;
        super.setCrmMemberManager(crmMemberManager);//处理父类无法注入问题
    }

    public void setBlackListService(BlackListService blackListService) {
        this.blackListService = blackListService;
    }
}

你可能感兴趣的:(DAO,apache,bean,Access)