All Downloads are FREE. Search and download functionalities are using the official Maven repository.

yui.comn.hub.data.handler.AbstractHubDataHandler Maven / Gradle / Ivy

The newest version!
/**
* Project: yui3-common-hub
 * Class AbstractHubDataHandler
 * Version 1.0
 * File Created at 2018年8月14日
 * $Id$
 * 
 * Copyright 2010-2015 Yui.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Yui Personal. ("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 Yui.com.
 */
package yui.comn.hub.data.handler;

import java.util.Map;

import javax.annotation.PostConstruct;

import org.apache.commons.lang3.StringUtils;

import yui.comn.hub.model.HubXmlHandlerConfig;

/**
 * 抽象数据中转处理
 * @author yuyi ([email protected])
 */ 
public abstract class AbstractHubDataHandler implements IHubDataHandler{
 
    protected abstract void doHandle(HubXmlHandlerConfig dataConfig, Map dataMap);
    
    @PostConstruct
    public void init() {
        if (StringUtils.isNotBlank(getRegisterName())) {
            HubDataHandlerRegister.registerHandler(getRegisterName(), this);
        }
    }
    
    @Override
    public Object handle(HubXmlHandlerConfig dataConfig, Map dataMap) {
        doHandle(dataConfig, dataMap);
        return null;
    }
    
    //也可以在类中直接注册
    protected String getRegisterName() {
        return null;   
    }

    protected Object getMapData(Map dataMap, String name, String group) {
        if (StringUtils.isBlank(group)) {
            return dataMap.get(name);
        } else {
            Map groupMap = (Map) dataMap.get(group);
            return groupMap.get(name);
        }
    }

    protected Object putMapData(Map dataMap, Object val, String name, String group) {
        if (StringUtils.isBlank(group)) {
            return dataMap.put(name, val);
        } else {
            Map groupMap = (Map) dataMap.get(group);
            return groupMap.put(name, val);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy