/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. package com.google.sitebricks.stat.testservices;
  18. import com.google.sitebricks.stat.Stat;
  19. import java.util.concurrent.atomic.AtomicInteger;
  20. /**
  21. * This subclass of {@link DummyService} exists to illustrate how stats are
  22. * published (or not published) within a class hierarchy.
  23. *
  24. * @author ffaber@gmail.com (Fred Faber)
  25. */
  26. public class ChildDummyService extends DummyService {
  27. public static final String NUMBER_OF_CHILD_CALLS = "number-of-child-calls";
  28. private final AtomicInteger childCalls = new AtomicInteger();
  29. @Override public void call() {
  30. super.call();
  31. childCalls.incrementAndGet();
  32. }
  33. @Stat(NUMBER_OF_CHILD_CALLS)
  34. public AtomicInteger getChildCalls() {
  35. return childCalls;
  36. }
  37. }