<commit_before>package com.shinemo.mpush.common.handler;


import com.shinemo.mpush.api.Constants;
import com.shinemo.mpush.api.Message;
import com.shinemo.mpush.api.MessageHandler;
import com.shinemo.mpush.api.connection.Connection;
import com.shinemo.mpush.api.exception.CryptoException;
import com.shinemo.mpush.api.protocol.Packet;

/**
 * Created by ohun on 2015/12/22.
 */
public abstract class BaseMessageHandler<T extends Message> implements MessageHandler {
    public abstract T decode(Packet packet, Connection connection);

    public abstract void handle(T message);

    public void handle(Packet packet, Connection connection) {
    	if(checkCrypto(packet)){
    		T t = decode(packet, connection);
            if (t != null) {
                handle(t);
            }
    	}
    }
    
    public boolean checkCrypto(Packet packet){
    	if(packet.hasFlag(Constants.CRYPTO_FLAG)){
    		return true;
    	}else{
    		throw new CryptoException("need crypto");
    	}
    }
}<commit_msg>add http proxy<commit_after>package com.shinemo.mpush.common.handler;


import com.shinemo.mpush.api.Message;
import com.shinemo.mpush.api.MessageHandler;
import com.shinemo.mpush.api.connection.Connection;
import com.shinemo.mpush.api.protocol.Packet;

/**
 * Created by ohun on 2015/12/22.
 */
public abstract class BaseMessageHandler<T extends Message> implements MessageHandler {
    public abstract T decode(Packet packet, Connection connection);

    public abstract void handle(T message);

    public void handle(Packet packet, Connection connection) {
        T t = decode(packet, connection);
        if (t != null) {
            handle(t);
        }
    }
}
{'fraction_non_alphanumeric': 0.10479041916167664, 'fraction_numerical': 0.009580838323353293, 'mean_word_length': 3.3515625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7491350', 'n_tokens_mistral': 533, 'n_tokens_neox': 499, 'n_words': 117}