View Javadoc

1   package org.e2etrace.trace;
2   
3   /*
4    * Copyright 2006 Gunther Popp
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import org.e2etrace.timer.DefaultTimerFactory;
20  import org.e2etrace.timer.ITimerFactory;
21  
22  /**
23   * Default Factory class for trace steps.
24   *
25   * @author Gunther Popp
26   *
27   */
28  public class DefaultTraceStepFactory implements ITraceStepFactory {
29  
30    private ITimerFactory timerFactory;
31  
32    /**
33     * Default constructor.
34     * <p>
35     *
36     * A factory created with this constructor uses
37     * <code>DefaultTimerFactor</code> as timer factories.
38     *
39     */
40    public DefaultTraceStepFactory() {
41      this.timerFactory = new DefaultTimerFactory();
42  
43    }
44  
45    /**
46     * Constructor: Use a custom timer factory.
47     * <p>
48     *
49     * @param timerFactory custom timer factory
50     */
51    public DefaultTraceStepFactory(ITimerFactory timerFactory) {
52      this.timerFactory = timerFactory;
53    }
54  
55    /** {@inheritDoc} */
56    public ITraceStep newInstance(ITraceStepId id) {
57      return new DefaultTraceStep(id, this.timerFactory);
58    }
59  
60  }