<commit_before>// $Header$
/*
 * Copyright 2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jmeter.monitor.model;


import org.apache.jmeter.monitor.parser.Parser;
import org.apache.jmeter.monitor.parser.ParserImpl;
import org.apache.jmeter.samplers.SampleResult;

/**
 * ObjectFactory is a simple factory class which creates
 * new instances of objects. It also provides convienant
 * method to parse XML status results.
 */
public class ObjectFactory
{

	private static ObjectFactory FACTORY = null;
	private static Parser PARSER = null;
	
    /**
     * 
     */
    protected ObjectFactory()
    {
        super();
		PARSER = new MonitorParser(this);
    }

	public static ObjectFactory getInstance(){
		if (FACTORY == null){
			FACTORY = new ObjectFactory();
		}
		return FACTORY;
	}
	
	public Status parseBytes(byte[] bytes){
		return PARSER.parseBytes(bytes);
	}
	
	public Status parseString(String content){
		return PARSER.parseString(content);
	}

	public Status parseSampleResult(SampleResult result){
		return PARSER.parseSampleResult(result);
	}
	
	public Status createStatus(){
		return new StatusImpl();
	}
	
	public Connector createConnector(){
		return new ConnectorImpl();
	}

	public Jvm createJvm(){
		return new JvmImpl();
	}

	public Memory createMemory(){
		return new MemoryImpl();	
	}<commit_msg>when there are several monitor threadgroups, the probability of another thread calling parseBytes() while the parser is busy is low, but it does happen. When it does, it cases SAX to throw an exception. Adding sync fixes the problem and doesn't appear to have any performance impact. <NAME><commit_after>// $Header$
/*
 * Copyright 2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jmeter.monitor.model;


import org.apache.jmeter.monitor.parser.Parser;
import org.apache.jmeter.monitor.parser.ParserImpl;
import org.apache.jmeter.samplers.SampleResult;

/**
 * ObjectFactory is a simple factory class which creates
 * new instances of objects. It also provides convienant
 * method to parse XML status results.
 */
public class ObjectFactory
{

	private static ObjectFactory FACTORY = null;
	private static Parser PARSER = null;
	
    /**
     * 
     */
    protected ObjectFactory()
    {
        super();
		PARSER = new MonitorParser(this);
    }

	public static ObjectFactory getInstance(){
		if (FACTORY == null){
			FACTORY = new ObjectFactory();
		}
		return FACTORY;
	}
	
	public synchronized Status parseBytes(byte[] bytes){
		return PARSER.parseBytes(bytes);
	}
	
	public Status parseString(String content){
		return PARSER.parseString(content);
	}

	public Status parseSampleResult(SampleResult result){
		return PARSER.parseSampleResult(result);
	}
	
	public Status createStatus(){
		return new StatusImpl();
	}
	
	public Connector createConnector(){
		return new ConnectorImpl();
	}

	public Jvm createJvm(){
		return new JvmImpl();
	}

	public Memory createMemory(){
		return new MemoryImpl();	
	}
{'fraction_non_alphanumeric': 0.08730939498278406, 'fraction_numerical': 0.003935071323167732, 'mean_word_length': 3.9, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3634137', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1097, 'n_words': 426}