@Override
	public void sampleOccurred(SampleEvent e) {
		if (e.getResult().isSuccessful()){
            if (isErrorsOnly()){
                return;
            }
        } else {
            if (isSuccessOnly()){
                return;
            }
        }
		JMeterVariables variables = JMeterContextService.getContext().getVariables();
		MongoDBConfig config = (MongoDBConfig)variables.getObject(this.getMongoDBConfigName());
		if(config == null){
			log.error("can not find mongo db config with name:"+this.getMongoDBConfigName());
		}else{
			log.info("save result to mongodb :"+config.toString());
			String result = null;
			if(StringUtils.isBlank(this.getResultVarName())){
				result = e.getResult().getResponseDataAsString();
			}else{
				result = variables.get(this.getResultVarName());
			}
			if(StringUtils.isBlank(result)||"NULL".equalsIgnoreCase(result)){
				log.error("result is blank.");
			}else{
				if(log.isDebugEnabled()){
					log.debug("result:"+result);
				}
				JSONParser parser = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
				DBCollection collection = config.getCollection(this.getMongoDBCollectionName());
				try {
					Object obj = parser.parse(result);
					saveObject(obj, collection);
				} catch (ParseException ex) {
					log.error("parse json error:"+ex.getMessage()+", responseStr:"+result);
				}
			}
		}
	}