polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject zest-qi4j git commit: Metrics gets a little bit of care.
Date Mon, 06 Jul 2015 13:43:21 GMT
Repository: zest-qi4j
Updated Branches:
  refs/heads/develop bbeb69e4b -> 579090ed6


Metrics gets a little bit of care.


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/579090ed
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/579090ed
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/579090ed

Branch: refs/heads/develop
Commit: 579090ed640d9b9ca5e2949a84208894988773d8
Parents: bbeb69e
Author: Niclas Hedhman <hedmann@betfair.com>
Authored: Mon Jul 6 16:43:11 2015 +0300
Committer: Niclas Hedhman <hedmann@betfair.com>
Committed: Mon Jul 6 16:43:11 2015 +0300

----------------------------------------------------------------------
 libraries/metrics/dev-status.xml                |  2 +-
 libraries/metrics/src/docs/metrics.txt          | 26 ++++++-
 .../library/metrics/DocumentationSupport.java   | 79 ++++++++++++++++++++
 .../org/qi4j/library/metrics/MetricsTest.java   |  3 +-
 4 files changed, 106 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/579090ed/libraries/metrics/dev-status.xml
----------------------------------------------------------------------
diff --git a/libraries/metrics/dev-status.xml b/libraries/metrics/dev-status.xml
index d3fd848..4ad3244 100644
--- a/libraries/metrics/dev-status.xml
+++ b/libraries/metrics/dev-status.xml
@@ -24,7 +24,7 @@
     <codebase>early</codebase>
 
     <!-- none, brief, good, complete -->
-    <documentation>none</documentation>
+    <documentation>brief</documentation>
 
     <!-- none, some, good, complete -->
     <unittests>none</unittests>

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/579090ed/libraries/metrics/src/docs/metrics.txt
----------------------------------------------------------------------
diff --git a/libraries/metrics/src/docs/metrics.txt b/libraries/metrics/src/docs/metrics.txt
index 3072992..7ac1061 100644
--- a/libraries/metrics/src/docs/metrics.txt
+++ b/libraries/metrics/src/docs/metrics.txt
@@ -25,8 +25,8 @@ include::../../build/docs/buildinfo/artifact.txt[]
 == Usage ==
 There are currently the following possibilities available;
 
-    * @TimingCapture
-    * @Counting
+    * @TimingCapture - capture timing on a single method
+    * TimingCaptureAll - capture timing on all methods of a composite
 
 Before looking at the details of these, we need to point out that there are some pre-conditions
for Metrics to be
 working. First of all, you need to install a Metrics Extensions, most likely the
@@ -39,3 +39,25 @@ production plant and likewise a good front-end to view this. See your chosen
Met
 There is a TimingCaptureAllConcern, which when added to a composite will install a _Timer_
for every method call
 in the composite.
 
+== @TimingCapture ==
+The +@TimingCapture+ annotation can be placed on any method of the composite, to indicate
that
+a Timer is wanted on that method.
+
+Example;
+
+[snippet,java]
+----
+source=libraries/metrics/src/test/java/org/qi4j/library/metrics/DocumentationSupport.java
+tag=capture
+----
+
+== Which method? ==
+It is valid to annotate either the composite interface methods or the mixin implementation
methods.
+Any of the method declarations should work. From the testcases we have the following example;
+
+[snippet,java]
+----
+source=libraries/metrics/src/test/java/org/qi4j/library/metrics/MetricsTest.java
+tag=complex-capture
+----
+

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/579090ed/libraries/metrics/src/test/java/org/qi4j/library/metrics/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/libraries/metrics/src/test/java/org/qi4j/library/metrics/DocumentationSupport.java
b/libraries/metrics/src/test/java/org/qi4j/library/metrics/DocumentationSupport.java
new file mode 100644
index 0000000..bd5dc4e
--- /dev/null
+++ b/libraries/metrics/src/test/java/org/qi4j/library/metrics/DocumentationSupport.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.qi4j.library.metrics;
+
+
+import java.util.List;
+import org.qi4j.bootstrap.Assembler;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+
+public class DocumentationSupport
+{
+// START SNIPPET: capture
+    public interface Router
+    {
+        @TimingCapture
+        List<Coordinate> route( String source, String destination );
+    }
+
+    public class RouterAlgorithm1
+        implements Router
+    {
+        @Override
+        public List<Coordinate> route( String source, String destination )
+        {
+// END SNIPPET: capture
+            return null;
+// START SNIPPET: capture
+        }
+    }
+
+    public class RouterAlgorithm2
+        implements Router
+    {
+        @Override
+        public List<Coordinate> route( String source, String destination )
+        {
+// END SNIPPET: capture
+            return null;
+// START SNIPPET: capture
+        }
+
+// END SNIPPET: capture
+        public class MyAsembler implements Assembler
+        {
+// START SNIPPET: capture
+            @Override
+            public void assemble( ModuleAssembly module )
+                throws AssemblyException
+            {
+                module.addServices( Router.class ).identifiedBy( "router1" ).withMixins(
RouterAlgorithm1.class );
+                module.addServices( Router.class ).identifiedBy( "router2" ).withMixins(
RouterAlgorithm2.class );
+// END SNIPPET: capture
+// START SNIPPET: capture
+            }
+        }
+    }
+// END SNIPPET: capture
+
+    public class Coordinate
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/579090ed/libraries/metrics/src/test/java/org/qi4j/library/metrics/MetricsTest.java
----------------------------------------------------------------------
diff --git a/libraries/metrics/src/test/java/org/qi4j/library/metrics/MetricsTest.java b/libraries/metrics/src/test/java/org/qi4j/library/metrics/MetricsTest.java
index 9b4f1cc..2ec08be 100644
--- a/libraries/metrics/src/test/java/org/qi4j/library/metrics/MetricsTest.java
+++ b/libraries/metrics/src/test/java/org/qi4j/library/metrics/MetricsTest.java
@@ -133,6 +133,7 @@ public class MetricsTest extends AbstractQi4jTest
         return result.toString();
     }
 
+// START SNIPPET: complex-capture
     public interface Country extends TransientComposite
     {
         @Optional
@@ -183,7 +184,6 @@ public class MetricsTest extends AbstractQi4jTest
     public static abstract class Country3Mixin
         implements Country3
     {
-
         @Override
         @TimingCapture
         public void updateName( String newName )
@@ -191,4 +191,5 @@ public class MetricsTest extends AbstractQi4jTest
             name().set( newName );
         }
     }
+// END SNIPPET: complex-capture
 }


Mime
View raw message