01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jmeter.monitor.model;
18:
19: // For unit tests, @see TestObjectFactory
20:
21: import org.apache.jmeter.monitor.parser.Parser;
22: import org.apache.jmeter.monitor.parser.ParserImpl;
23: import org.apache.jmeter.samplers.SampleResult;
24:
25: /**
26: * ObjectFactory is a simple factory class which creates new instances of
27: * objects. It also provides convienant method to parse XML status results.
28: */
29: public class ObjectFactory {
30:
31: private static ObjectFactory FACTORY = null;
32:
33: private Parser PARSER = null;
34:
35: /**
36: *
37: */
38: protected ObjectFactory() {
39: super ();
40: PARSER = new MonitorParser(this );
41: }
42:
43: public static ObjectFactory getInstance() {
44: if (FACTORY == null) {
45: FACTORY = new ObjectFactory();
46: }
47: return FACTORY;
48: }
49:
50: public synchronized Status parseBytes(byte[] bytes) {
51: return PARSER.parseBytes(bytes);
52: }
53:
54: public Status parseString(String content) {
55: return PARSER.parseString(content);
56: }
57:
58: public Status parseSampleResult(SampleResult result) {
59: return PARSER.parseSampleResult(result);
60: }
61:
62: public Status createStatus() {
63: return new StatusImpl();
64: }
65:
66: public Connector createConnector() {
67: return new ConnectorImpl();
68: }
69:
70: public Jvm createJvm() {
71: return new JvmImpl();
72: }
73:
74: public Memory createMemory() {
75: return new MemoryImpl();
76: }
77:
78: public RequestInfo createRequestInfo() {
79: return new RequestInfoImpl();
80: }
81:
82: public ThreadInfo createThreadInfo() {
83: return new ThreadInfoImpl();
84: }
85:
86: public Worker createWorker() {
87: return new WorkerImpl();
88: }
89:
90: public Workers createWorkers() {
91: return new WorkersImpl();
92: }
93:
94: protected static class MonitorParser extends ParserImpl {
95: public MonitorParser(ObjectFactory factory) {
96: super(factory);
97: }
98: }
99: }
|