PageRenderTime 181ms CodeModel.GetById 171ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/stat/src/test/java/com/google/sitebricks/stat/testservices/ChildDummyService.java

http://github.com/dhanji/sitebricks
Java | 45 lines | 15 code | 8 blank | 22 comment | 0 complexity | c854e9ca7d24d6a1b074659bf4ca5d18 MD5 | raw file
 1/**
 2 * Copyright (C) 2011 Google Inc.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License");
 5 * you may not use this file except in compliance with the License.
 6 * You may obtain a copy of the License at
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package com.google.sitebricks.stat.testservices;
19
20import com.google.sitebricks.stat.Stat;
21
22import java.util.concurrent.atomic.AtomicInteger;
23
24/**
25 * This subclass of {@link DummyService} exists to illustrate how stats are
26 * published (or not published) within a class hierarchy.
27 *
28 * @author ffaber@gmail.com (Fred Faber)
29 */
30public class ChildDummyService extends DummyService {
31
32  public static final String NUMBER_OF_CHILD_CALLS = "number-of-child-calls";
33
34  private final AtomicInteger childCalls = new AtomicInteger();
35
36  @Override public void call() {
37    super.call();
38    childCalls.incrementAndGet();
39  }
40
41  @Stat(NUMBER_OF_CHILD_CALLS)
42  public AtomicInteger getChildCalls() {
43    return childCalls;
44  }
45}