Modified: tomee/site/trunk/content/latest/examples/cdi-request-scope.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/cdi-request-scope.html?rev=1849998&r1=1849997&r2=1849998&view=diff ============================================================================== --- tomee/site/trunk/content/latest/examples/cdi-request-scope.html (original) +++ tomee/site/trunk/content/latest/examples/cdi-request-scope.html Sun Dec 30 19:02:51 2018 @@ -95,12 +95,34 @@ <div class="row"> <div class="col-md-12"> - <p>This example show the use of <code>@RequestScoped</code> annotation for injected objects. An object which is defined as <code>@RequestScoped</code> is created once for every request and is shared by all the beans that inject it throughout a same request.</p> -<h1>Example</h1> -<p>This example depicts a similar scenario to cdi-application-scope. A restaurant guest orders a soup from the waiter. The order is passed to the chef who prepares it and passes it back the waiter who in turn delivers it to the guest.</p> -<h2>Waiter</h2> -<p>The <code>Waiter</code> session bean receives a request from the test class via the <code>orderSoup()</code> method. A <code>Soup</code> insance will be created in this method and will be shared throughout the request with the <code>Chef</code> bean. The method passes the request to the <code>Chef</code> bean. It then returns the name of the soup to the test class. </p> -<pre><code>@Stateless + <div id="preamble"> +<div class="sectionbody"> +<div class="paragraph"> +<p>This example show the use of <code>@RequestScoped</code> annotation for injected objects. An object +which is defined as <code>@RequestScoped</code> is created once for every request and is shared by all the +beans that inject it throughout a same request.</p> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_example">Example</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>This example depicts a similar scenario to cdi-application-scope. A restaurant guest orders +a soup from the waiter. The order is passed to the chef who prepares it and passes it back +the waiter who in turn delivers it to the guest.</p> +</div> +<div class="sect2"> +<h3 id="_waiter">Waiter</h3> +<div class="paragraph"> +<p>The <code>Waiter</code> session bean receives a request from the test class via the <code>orderSoup()</code> method. +A <code>Soup</code> insance will be created in this method and will be shared throughout the request with +the <code>Chef</code> bean. The method passes the request to the <code>Chef</code> bean. It then returns the name of +the soup to the test class.</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@Stateless public class Waiter { @Inject @@ -113,18 +135,26 @@ public class Waiter { soup.setName(name); return chef.prepareSoup().getName(); } -} -</code></pre> -<h2>Soup</h2> -<p>The <code>Soup</code> class is an injectable POJO, defined as <code>@RequestScoped</code>. This means that an instance will be created only once for every request and will be shared by all the beans injecting it.</p> -<pre><code>@RequestScoped +}</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_soup">Soup</h3> +<div class="paragraph"> +<p>The <code>Soup</code> class is an injectable POJO, defined as <code>@RequestScoped</code>. This means that an instance +will be created only once for every request and will be shared by all the beans injecting it.</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@RequestScoped public class Soup { - private String name = "Soup of the day"; + private String name = "Soup of the day"; @PostConstruct public void afterCreate() { - System.out.println("Soup created"); + System.out.println("Soup created"); } public String getName() { @@ -134,11 +164,20 @@ public class Soup { public void setName(String name){ this.name = name; } -} -</code></pre> -<h2>Chef</h2> -<p>The <code>Chef</code> class is a simple session bean with an injected <code>Soup</code> field. Normally, the soup parameter would be passed as a <code>prepareSoup()</code> argument, but for the need of this example it's passed by the request context. </p> -<pre><code>@Stateless +}</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_chef">Chef</h3> +<div class="paragraph"> +<p>The <code>Chef</code> class is a simple session bean with an injected <code>Soup</code> field. Normally, the soup +parameter would be passed as a <code>prepareSoup()</code> argument, but for the need of this example +it’s passed by the request context.</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@Stateless public class Chef { @Inject @@ -147,13 +186,23 @@ public class Chef { public Soup prepareSoup() { return soup; } -} -</code></pre> -<h1>Test Case</h1> +}</pre> +</div> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_test_case">Test Case</h2> +<div class="sectionbody"> +<div class="paragraph"> <p>This is the entry class for this example.</p> -<pre><code>public class RestaurantTest { +</div> +<div class="literalblock"> +<div class="content"> +<pre>public class RestaurantTest { - private static String TOMATO_SOUP = "Tomato Soup"; + private static String TOMATO_SOUP = "Tomato Soup"; private EJBContainer container; @EJB @@ -162,7 +211,7 @@ public class Chef { @Before public void startContainer() throws Exception { container = EJBContainer.createEJBContainer(); - container.getContext().bind("inject", this); + container.getContext().bind("inject", this); } @Test @@ -177,11 +226,21 @@ public class Chef { public void closeContainer() throws Exception { container.close(); } -} -</code></pre> -<h1>Running</h1> -<p>In the output you can see that there were two <code>Soup</code> instances created - one for each request.</p> -<pre><code>------------------------------------------------------- +}</pre> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_running">Running</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>In the output you can see that there were two <code>Soup</code> instances created - one for +each request.</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>------------------------------------------------------- T E S T S ------------------------------------------------------- Running org.superbiz.cdi.requestscope.RestaurantTest @@ -189,7 +248,7 @@ Apache OpenEJB 7.0.0-SNAPSHOT build: http://tomee.apache.org/ INFO - openejb.home = C:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope INFO - openejb.base = C:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope -INFO - Using 'javax.ejb.embeddable.EJBContainer=true' +INFO - Using 'javax.ejb.embeddable.EJBContainer=true' INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service) INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager) INFO - Found EjbModule in classpath: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope\target\classes @@ -199,12 +258,12 @@ INFO - Configuring Service(id=Default Ma INFO - Auto-creating a container for bean cdi-request-scope.Comp: Container(type=MANAGED, id=Default Managed Container) INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container) INFO - Auto-creating a container for bean Chef: Container(type=STATELESS, id=Default Stateless Container) -INFO - Enterprise application "c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope" loaded. +INFO - Enterprise application "c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope" loaded. INFO - Assembling app: c:\Users\Daniel\workspaces\openejb\openejb\examples\cdi-request-scope -INFO - Jndi(name="java:global/cdi-request-scope/Chef!org.superbiz.cdi.requestscope.Chef") -INFO - Jndi(name="java:global/cdi-request-scope/Chef") -INFO - Jndi(name="java:global/cdi-request-scope/Waiter!org.superbiz.cdi.requestscope.Waiter") -INFO - Jndi(name="java:global/cdi-request-scope/Waiter") +INFO - Jndi(name="java:global/cdi-request-scope/Chef!org.superbiz.cdi.requestscope.Chef") +INFO - Jndi(name="java:global/cdi-request-scope/Chef") +INFO - Jndi(name="java:global/cdi-request-scope/Waiter!org.superbiz.cdi.requestscope.Waiter") +INFO - Jndi(name="java:global/cdi-request-scope/Waiter") INFO - Created Ejb(deployment-id=Chef, ejb-name=Chef, container=Default Stateless Container) INFO - Created Ejb(deployment-id=Waiter, ejb-name=Waiter, container=Default Stateless Container) INFO - Started Ejb(deployment-id=Chef, ejb-name=Chef, container=Default Stateless Container) @@ -217,8 +276,11 @@ Tests run: 1, Failures: 0, Errors: 0, Sk Results : -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 -</code></pre> +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0</pre> +</div> +</div> +</div> +</div> </div> </div>
Modified: tomee/site/trunk/content/latest/examples/cdi-session-scope.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/cdi-session-scope.html?rev=1849998&r1=1849997&r2=1849998&view=diff ============================================================================== --- tomee/site/trunk/content/latest/examples/cdi-session-scope.html (original) +++ tomee/site/trunk/content/latest/examples/cdi-session-scope.html Sun Dec 30 19:02:51 2018 @@ -88,95 +88,189 @@ <div class="col-md-12"> <div class='page-header'> - <h1>CDI @SessionScoped</h1> + <h1>null</h1> </div> </div> </div> <div class="row"> <div class="col-md-12"> - <p>This example show the use of <code>@SessionScoped</code> annotation for injected objects. An object which is defined as <code>@SessionScoped</code> is created once for every HTTPSession and is shared by all the beans that inject it throughout the same HTTPSession.</p> -<h5>Run the application:</h5> -<pre><code>mvn clean install tomee:run -</code></pre> -<h1>Example</h1> -<p>This example has an end point wherein a user provides a request parameter 'name' which is persisted as a feild in a session scoped bean SessionBean and then retrieved through another endpoint.</p> -<h1>Request</h1> -<p>GET <a href="http://localhost:8080/cdi-session-scope-8.0.0-SNAPSHOT/set-name?name=Puneeth">http://localhost:8080/cdi-session-scope-8.0.0-SNAPSHOT/set-name?name=Puneeth</a></p> -<h1>Response</h1> -<p>done, go to /name servlet </p> -<h1>Request</h1> -<p>GET <a href="http://localhost:8080/cdi-session-scope-8.0.0-SNAPSHOT/name">http://localhost:8080/cdi-session-scope-8.0.0-SNAPSHOT/name</a></p> -<h1>Response</h1> -<p>name = {Puneeth} </p> -<h2>SessionBean</h2> -<p>The annotation @SessionScoped specifies that a bean is session scoped ie there will be only one instance of the class associated with a particular HTTPSession. </p> -<p>@SessionScoped<br/>public class SessionBean implements Serializable {</p> -<pre><code>private String name; - -public String getName() { - return name; -} - -public void setName(String name) { - this.name = name; -} -</code></pre> -<p>} </p> -<h2>InputServlet</h2> -<p>InputServlet is a generic servlet which is mapped to the url pattern '/set-name'. The session scoped bean 'SessionBean' has been injected into this servlet, and the incoming request parameter is set to the feild name of the bean. </p> -<p>@WebServlet(name = "input-servlet", urlPatterns = {"/set-name"})<br/>public class InputServlet extends HttpServlet {</p> -<pre><code>@Inject -private SessionBean bean; - -@Override -protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - final String name = req.getParameter("name"); - if (name == null || name.isEmpty()) { - resp.getWriter().write("please add a parameter name=xxx"); - } else { - bean.setName(name); - resp.getWriter().write("done, go to /name servlet"); - } - -} -</code></pre> -<p>}</p> -<h2>AnswerBean</h2> + <div class="paragraph"> +<p>index-group=Unrevised +type=page +status=unpublished</p> +</div> +<h1 id="_cdi_sessionscoped" class="sect0">CDI @SessionScoped</h1> +<div class="paragraph"> +<p>This example show the use of <code>@SessionScoped</code> annotation for injected objects. An object +which is defined as <code>@SessionScoped</code> is created once for every HTTPSession and is shared by all the +beans that inject it throughout the same HTTPSession.</p> +</div> +<div class="sect1"> +<h2 id="_run_the_application">Run the application:</h2> +<div class="sectionbody"> +<div class="literalblock"> +<div class="content"> +<pre>mvn clean install tomee:run</pre> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_example">Example</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>This example has an end point wherein a user provides a request parameter 'name' which is persisted as a feild in a session scoped bean SessionBean and +then retrieved through another endpoint.</p> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_request">Request</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>GET <a href="http://localhost:8080/cdi-session-scope/set-name?name=Puneeth" class="bare">http://localhost:8080/cdi-session-scope/set-name?name=Puneeth</a></p> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_response">Response</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>done, go to /name servlet</p> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_request_2">Request</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>GET <a href="http://localhost:8080/cdi-session-scope/name" class="bare">http://localhost:8080/cdi-session-scope/name</a></p> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_response_2">Response</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>name = {Puneeth}</p> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_sessionbean">SessionBean</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>The annotation @SessionScoped specifies that a bean is session scoped ie there will be only one instance of the class associated with a particular HTTPSession.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="highlight"><code class="language-java" data-lang="java">@SessionScoped +public class SessionBean implements Serializable { + + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +}</code></pre> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_inputservlet">InputServlet</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>InputServlet is a generic servlet which is mapped to the url pattern '/set-name'. +The session scoped bean 'SessionBean' has been injected into this servlet, and the incoming request parameter is set to the feild name of the bean.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="highlight"><code class="language-java" data-lang="java">@WebServlet(name = "input-servlet", urlPatterns = {"/set-name"}) +public class InputServlet extends HttpServlet { + + @Inject + private SessionBean bean; + + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp + throws ServletException, IOException { + final String name = req.getParameter("name"); + if (name == null || name.isEmpty()) { + resp.getWriter().write("please add a parameter name=xxx"); + } else { + bean.setName(name); + resp.getWriter().write("done, go to /name servlet"); + } + + } +}</code></pre> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_answerbean">AnswerBean</h2> +<div class="sectionbody"> +<div class="paragraph"> <p>AnswerBean is a request scoped bean with an injected 'SessionBean'. It has an postconstruct method wherein the value from the sessionBean is retrieved and set to a feild.</p> -<p>public class AnswerBean {</p> -<pre><code>@Inject -private SessionBean bean; - -private String value; - -@PostConstruct -public void init() { - value = '{' + bean.getName() + '}'; -} - -public String value() { - return value; -} -</code></pre> -<p>}</p> -<h2>OutputServlet</h2> -<p>OutputServlet is another servlet with 'AnswerBean' as an injected feild. When '/name' is called the value from 'Answerbean' is read and written to the response.</p> -<p>@WebServlet(name = "output-servlet", urlPatterns = {"/name"})<br/>public class OutputServlet extends HttpServlet {</p> -<pre><code>@Inject -private AnswerBean bean; - -@Override -protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - final String name = bean.value(); - if (name == null || name.isEmpty()) { - resp.getWriter().write("please go to servlet /set-name please"); - } else { - resp.getWriter().write("name = " + name); - } -} -</code></pre> -<p>}</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="highlight"><code class="language-java" data-lang="java">public class AnswerBean { + + @Inject + private SessionBean bean; + + private String value; + + @PostConstruct + public void init() { + value = '{' + bean.getName() + '}'; + } + + public String value() { + return value; + } +}</code></pre> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_outputservlet">OutputServlet</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>OutputServlet is another servlet with 'AnswerBean' as an injected feild. When '/name' is called the value from 'Answerbean' is read and written to the response.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="highlight"><code class="language-java" data-lang="java">@WebServlet(name = "output-servlet", urlPatterns = {"/name"}) +public class OutputServlet extends HttpServlet { + + @Inject + private AnswerBean bean; + + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + final String name = bean.value(); + if (name == null || name.isEmpty()) { + resp.getWriter().write("please go to servlet /set-name please"); + } else { + resp.getWriter().write("name = " + name); + } + } +}</code></pre> +</div> +</div> +</div> +</div> </div> </div> Modified: tomee/site/trunk/content/latest/examples/index.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/index.html?rev=1849998&r1=1849997&r2=1849998&view=diff ============================================================================== --- tomee/site/trunk/content/latest/examples/index.html (original) +++ tomee/site/trunk/content/latest/examples/index.html Sun Dec 30 19:02:51 2018 @@ -93,6 +93,20 @@ </div> <div class="row"> <div class="col-md-4"> + <div class="group-title">CDI</div> + <ul class="group"> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-application-scope.html">CDI @ApplicationScoped</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-basic.html">CDI @Inject</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-request-scope.html">CDI @RequestScoped</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-events.html">CDI Events - Loose Coupling and Extensibility</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-produces-field.html">CDI Field Producer</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-interceptors.html">CDI Interceptors</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-produces-disposes.html">CDI Produces Disposes</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="decorators.html">Decorators</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="simple-cdi-interceptor.html">Simple CDI Interceptor</a></li> + </ul> + </div> + <div class="col-md-4"> <div class="group-title">Web Services</div> <ul class="group"> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="webservice-handlerchain.html">@WebService handlers with @HandlerChain</a></li> @@ -106,18 +120,6 @@ </ul> </div> <div class="col-md-4"> - <div class="group-title">CDI</div> - <ul class="group"> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-application-scope.html">CDI @ApplicationScoped</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-basic.html">CDI @Inject</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-request-scope.html">CDI @RequestScoped</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-alternative-and-stereotypes.html">CDI Alternative and Stereotypes</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-produces-disposes.html">CDI Produces Disposes</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="decorators.html">Decorators</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="simple-cdi-interceptor.html">Simple CDI Interceptor</a></li> - </ul> - </div> - <div class="col-md-4"> <div class="group-title">EJB</div> <ul class="group"> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="access-timeout.html">@AccessTimeout Annotation</a></li> @@ -193,10 +195,10 @@ <div class="col-md-4"> <div class="group-title">Unknown</div> <ul class="group"> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-alternative-and-stereotypes.html">cdi-alternative-and-stereotypes</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-session-scope.html">cdi-session-scope</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="java-modules.html">Java modules example with a simple REST resource</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-custom-healthcheck.html">MicroProfile Custom Health Check</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-faulttolerance-fallback.html">Microprofile Fault Tolerance - Fallback</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-opentracing-traced.html">mp-opentracing-traced</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="projectstage-demo.html">projectstage-demo</a></li> </ul> </div> <div class="col-md-4"> @@ -277,29 +279,17 @@ </ul> </div> <div class="col-md-4"> - <div class="group-title">Histogram</div> - <ul class="group"> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-histogram.html">Microprofile Metrics Histogram</a></li> - </ul> - </div> - <div class="col-md-4"> <div class="group-title">Java EE Connectors</div> <ul class="group"> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="quartz-app.html">Quartz Resource Adapter usage</a></li> </ul> </div> - </div> - <div class="row"> <div class="col-md-4"> <div class="group-title">JPA Providers</div> <ul class="group"> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="multi-jpa-provider-testing.html">Multiple JPA providers test</a></li> </ul> </div> - <div class="col-md-4"> - </div> - <div class="col-md-4"> - </div> </div> <div class="row"> <div class="col-md-12"> @@ -332,6 +322,36 @@ </div> <div class="row"> <div class="col-md-12"> + <div class="group-title large">MicroProfile</div> + </div> + </div> + <div class="row"> + <div class="col-md-4"> + <ul class="group"> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-config-example.html">MicroProfile Config</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-custom-healthcheck.html">MicroProfile Custom Health Check</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-faulttolerance-fallback.html">MicroProfile Fault Tolerance - Fallback</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-faulttolerance-retry.html">MicroProfile Fault Tolerance - Retry Policy</a></li> + </ul> + </div> + <div class="col-md-4"> + <ul class="group"> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-rest-jwt.html">MicroProfile JWT</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-counted.html">MicroProfile Metrics Counted</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-histogram.html">MicroProfile Metrics Histogram</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-metered.html">MicroProfile Metrics Metered</a></li> + </ul> + </div> + <div class="col-md-4"> + <ul class="group"> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-timed.html">MicroProfile Metrics Timed</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-opentracing-traced.html">MicroProfile OpenTracing @Traced</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-rest-client.html">MicroProfile Rest Client</a></li> + </ul> + </div> + </div> + <div class="row"> + <div class="col-md-12"> <div class="group-title large">Unrevised</div> </div> </div> @@ -341,38 +361,27 @@ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="deltaspike-fullstack.html">Apache DeltaSpike Demo</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="arquillian-jpa.html">Arquillian Persistence Extension</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="bval-evaluation-redeployment.html">bval-evaluation-redeployment</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-session-scope.html">CDI @SessionScoped</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-events.html">CDI Events</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-produces-field.html">CDI field producer</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cdi-interceptors.html">CDI Interceptors</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="change-jaxws-url.html">Change JAXWS URL</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="resources-jmx-example.html">Custom resources in an EAR archive</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="datasource-versioning.html">DataSource Versioning</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="realm-in-tomee.html">DataSourceRealm and TomEE DataSource</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="javamail.html">Javamail API</a></li> </ul> </div> <div class="col-md-4"> <ul class="group"> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="javamail.html">Javamail API</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-config-example.html">Microprofile Config</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-faulttolerance-retry.html">Microprofile Fault Tolerance Retry</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-counted.html">Microprofile Metrics Counted</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-timed.html">Microprofile Metrics Timed</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-rest-client.html">Microprofile Rest Client</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-rest-jwt.html">Microprofile Rest JWT</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="connector-war.html">Movies Complete</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mp-metrics-metered.html">mp-metrics-metered</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="mtom.html">mtom</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="myfaces-codi-demo.html">MyFaces CODI Demo</a></li> - </ul> - </div> - <div class="col-md-4"> - <ul class="group"> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="persistence-fragment.html">Persistence Fragment</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="reload-persistence-unit-properties.html">Reload Persistence Unit Properties</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="schedule-events.html">Schedule CDI Events</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="simple-mdb-and-cdi.html">Simple MDB and CDI</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="rest-xml-json.html">Simple REST</a></li> + </ul> + </div> + <div class="col-md-4"> + <ul class="group"> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="rest-cdi.html">Simple REST with CDI</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="simple-stateful-callbacks.html">Simple Stateful with callback methods</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="simple-stateless-callbacks.html">Simple Stateless with callback methods</a></li> Modified: tomee/site/trunk/content/latest/examples/mp-config-example.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/mp-config-example.html?rev=1849998&r1=1849997&r2=1849998&view=diff ============================================================================== --- tomee/site/trunk/content/latest/examples/mp-config-example.html (original) +++ tomee/site/trunk/content/latest/examples/mp-config-example.html Sun Dec 30 19:02:51 2018 @@ -88,7 +88,7 @@ <div class="col-md-12"> <div class='page-header'> - <h1>Microprofile Config</h1> + <h1>MicroProfile Config</h1> </div> </div> </div> Modified: tomee/site/trunk/content/latest/examples/mp-custom-healthcheck.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/mp-custom-healthcheck.html?rev=1849998&r1=1849997&r2=1849998&view=diff ============================================================================== --- tomee/site/trunk/content/latest/examples/mp-custom-healthcheck.html (original) +++ tomee/site/trunk/content/latest/examples/mp-custom-healthcheck.html Sun Dec 30 19:02:51 2018 @@ -95,8 +95,10 @@ <div class="row"> <div class="col-md-12"> - <div class="sect3"> -<h4 id="_health_feature">Health Feature</h4> + <div class="paragraph"> +<p>This is an example of how to use MicroProfile Custom Health Check in TomEE.</p> +</div> +<h4 id="_health_feature" class="discrete">Health Feature</h4> <div class="paragraph"> <p>Health checks are used to probe the state of services and resources that an application might depend on or even to expose its state, e.g. in a cluster environment, where an unhealthy node needs to be discarded (terminated, shutdown) and eventually @@ -112,7 +114,7 @@ replaced by another healthy instance.</p </div> </div> <div class="paragraph"> -<p>To provide a customized output, Letâs say we have an application that uses a Weather API, and if the service becomes +<p>To provide a customized output, Let’s say we have an application that uses a Weather API, and if the service becomes unavailable, we should report the service as DOWN.</p> </div> <div class="paragraph"> @@ -148,26 +150,21 @@ public class WeatherServiceHealthCheck i <p>In the example above, the health probe name is <a href="https://openweathermap.org/appid">OpenWeatherMap</a> (<em>illustrative only</em>) which provides a subscription plan to access its services and if the limit of calls is exceeded the API becomes unavailable until it’s renewed.</p> </div> -</div> -<div class="sect2"> -<h3 id="_examples">Examples</h3> -<div class="sect4"> -<h5 id="_running_the_application">Running the application</h5> +<h3 id="_examples" class="discrete">Examples</h3> <div class="listingblock"> +<div class="title">Running the application</div> <div class="content"> -<pre class="highlight"><code> mvn clean install tomee:run</code></pre> -</div> +<pre> mvn clean install tomee:run</pre> </div> </div> -<div class="sect3"> -<h4 id="_example_1">Example 1</h4> +<h4 id="_example_1" class="discrete">Example 1</h4> <div class="paragraph"> <p>When hitting /health endpoint, OpenWeatherMap tell us that our remaining calls are running out and we should take an action before it gets unavailable.</p> </div> <div class="listingblock"> <div class="content"> -<pre class="highlight"><code>curl http://localhost:8080/mp-custom-healthcheck/health</code></pre> +<pre>curl http://localhost:8080/mp-custom-healthcheck/health</pre> </div> </div> <div class="listingblock"> @@ -190,15 +187,13 @@ an action before it gets unavailable.</p }</code></pre> </div> </div> -</div> -<div class="sect3"> -<h4 id="_example_2">Example 2</h4> +<h4 id="_example_2" class="discrete">Example 2</h4> <div class="paragraph"> <p>Weather API still working fine.</p> </div> <div class="listingblock"> <div class="content"> -<pre class="highlight"><code>curl http://localhost:8080/mp-custom-healthcheck/weather/day/status</code></pre> +<pre>curl http://localhost:8080/mp-custom-healthcheck/weather/day/status</pre> </div> </div> <div class="listingblock"> @@ -206,16 +201,14 @@ an action before it gets unavailable.</p <pre class="highlight"><code class="language-text" data-lang="text">Hi, today is a sunny day!</code></pre> </div> </div> -</div> -<div class="sect3"> -<h4 id="_example_3">Example 3</h4> +<h4 id="_example_3" class="discrete">Example 3</h4> <div class="paragraph"> <p>When hitting one more time /health endpoint, OpenWeatherMap tell us that our account is temporary blocked and this service is being reported as DOWN.</p> </div> <div class="listingblock"> <div class="content"> -<pre class="highlight"><code>curl http://localhost:8080/mp-custom-healthcheck/health</code></pre> +<pre>curl http://localhost:8080/mp-custom-healthcheck/health</pre> </div> </div> <div class="listingblock"> @@ -237,15 +230,13 @@ service is being reported as DOWN.</p> }</code></pre> </div> </div> -</div> -<div class="sect3"> -<h4 id="_example_4">Example 4</h4> +<h4 id="_example_4" class="discrete">Example 4</h4> <div class="paragraph"> <p>Weather API has stopped.</p> </div> <div class="listingblock"> <div class="content"> -<pre class="highlight"><code>curl http://localhost:8080/mp-custom-healthcheck/weather/day/status</code></pre> +<pre>curl http://localhost:8080/mp-custom-healthcheck/weather/day/status</pre> </div> </div> <div class="listingblock"> @@ -253,24 +244,20 @@ service is being reported as DOWN.</p> <pre class="highlight"><code class="language-text" data-lang="text">Weather Service is unavailable at moment, retry later.</code></pre> </div> </div> -<div class="sect4"> -<h5 id="_running_the_tests">Running the tests</h5> +<h5 id="_running_the_tests" class="discrete">Running the tests</h5> <div class="paragraph"> <p>You can also try it out using the <a href="src/test/java/org/superbiz/rest/WeatherServiceTest.java">WeatherServiceTest.java</a> available in the project.</p> </div> -<div class="literalblock"> +<div class="listingblock"> <div class="content"> <pre>mvn clean test</pre> </div> </div> <div class="listingblock"> <div class="content"> -<pre class="highlight"><code>[INFO] Results: +<pre>[INFO] Results: [INFO] -[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped:</code></pre> -</div> -</div> -</div> +[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped:</pre> </div> </div> </div> Modified: tomee/site/trunk/content/latest/examples/mp-faulttolerance-fallback.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/mp-faulttolerance-fallback.html?rev=1849998&r1=1849997&r2=1849998&view=diff ============================================================================== --- tomee/site/trunk/content/latest/examples/mp-faulttolerance-fallback.html (original) +++ tomee/site/trunk/content/latest/examples/mp-faulttolerance-fallback.html Sun Dec 30 19:02:51 2018 @@ -88,14 +88,21 @@ <div class="col-md-12"> <div class='page-header'> - <h1>Microprofile Fault Tolerance - Fallback</h1> + <h1>MicroProfile Fault Tolerance - Fallback</h1> </div> </div> </div> <div class="row"> <div class="col-md-12"> - <div class="sect1"> + <div id="preamble"> +<div class="sectionbody"> +<div class="paragraph"> +<p>This is an example of how to use Microprofile @Fallback in TomEE.</p> +</div> +</div> +</div> +<div class="sect1"> <h2 id="_fallback_feature">Fallback Feature</h2> <div class="sectionbody"> <div class="paragraph"> Modified: tomee/site/trunk/content/latest/examples/mp-faulttolerance-retry.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/mp-faulttolerance-retry.html?rev=1849998&r1=1849997&r2=1849998&view=diff ============================================================================== --- tomee/site/trunk/content/latest/examples/mp-faulttolerance-retry.html (original) +++ tomee/site/trunk/content/latest/examples/mp-faulttolerance-retry.html Sun Dec 30 19:02:51 2018 @@ -88,38 +88,95 @@ <div class="col-md-12"> <div class='page-header'> - <h1>Microprofile Fault Tolerance Retry</h1> + <h1>MicroProfile Fault Tolerance - Retry Policy</h1> </div> </div> </div> <div class="row"> <div class="col-md-12"> - <h1>Microprofile Fault Tolerance - Retry policy</h1> -<p>This is an example of how to use Microprofile @Retry in TomEE.</p> -<h4>Retry Feature</h4> -<p>Microprofile Fault Tolerance has a feature called Retry that can be used to recover an operation from failure, invoking the same operation again until it reaches its stopping criteria.</p> + <div id="preamble"> +<div class="sectionbody"> +<div class="paragraph"> +<p>This is an example of how to use +Microprofile @Retry in TomEE.</p> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_retry_feature">Retry Feature</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>Microprofile Fault Tolerance has a feature called Retry that can be used +to recover an operation from failure, invoking the same operation again +until it reaches its stopping criteria.</p> +</div> +<div class="paragraph"> <p>The Retry policy allows to configure :</p> +</div> +<div class="ulist"> <ul> - <li><strong>maxRetries</strong>: the maximum retries</li> - <li><strong>delay</strong>: delays between each retry</li> - <li><strong>delayUnit</strong>: the delay unit</li> - <li><strong>maxDuration</strong>: maximum duration to perform the retry for.</li> - <li><strong>durationUnit</strong>: duration unit</li> - <li><strong>jitter:</strong> the random vary of retry delays</li> - <li><strong>jitterDelayUnit:</strong> the jitter unit</li> - <li><strong>retryOn:</strong> specify the failures to retry on</li> - <li><strong>abortOn:</strong> specify the failures to abort on</li> +<li> +<p><strong>maxRetries</strong>: the maximum retries</p> +</li> +<li> +<p><strong>delay</strong>: delays between each retry</p> +</li> +<li> +<p><strong>delayUnit</strong>: the delay unit</p> +</li> +<li> +<p><strong>maxDuration</strong>: maximum duration to perform the retry for.</p> +</li> +<li> +<p><strong>durationUnit</strong>: duration unit</p> +</li> +<li> +<p><strong>jitter:</strong> the random vary of retry delays</p> +</li> +<li> +<p><strong>jitterDelayUnit:</strong> the jitter unit</p> +</li> +<li> +<p><strong>retryOn:</strong> specify the failures to retry on</p> +</li> +<li> +<p><strong>abortOn:</strong> specify the failures to abort on</p> +</li> </ul> -<p>To use this feature you can annotate a class and/or a method with the @Retry annotation. Check the <a href="http://download.eclipse.org/microprofile/microprofile-fault-tolerance-1.1/microprofile-fault-tolerance-spec.html">specification</a> for more details.</p> -<h3>Examples</h3> -<h5>Run the application</h5> -<pre><code>mvn clean install tomee:run -</code></pre> -<h5>Example 1</h5> -<p>The method statusOfDay will fail three times, each time, throwing a <code>WeatherGatewayTimeoutException</code> and as the<br/>@Retry annotation is configured to <code>retryOn</code> in case of failure, the FailSafe library will take the <code>maxRetry</code> value and<br/>retry the same operation until it reaches the number maximum of attempts, which is 3 (default value). </p> -<pre><code class="java">@RequestScoped -public class WeatherGateway{ +</div> +<div class="paragraph"> +<p>To use this feature you can annotate a class and/or a method with the +@Retry annotation. Check the +<a href="http://download.eclipse.org/microprofile/microprofile-fault-tolerance-1.1/microprofile-fault-tolerance-spec.html">specification</a> +for more details.</p> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_examples">Examples</h2> +<div class="sectionbody"> +<div class="sect2"> +<h3 id="_run_the_application">Run the application</h3> +<div class="literalblock"> +<div class="content"> +<pre>mvn clean install tomee:run</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_example_1">Example 1</h3> +<div class="paragraph"> +<p>The method statusOfDay will fail three times, each time, throwing a +<code>WeatherGatewayTimeoutException</code> and as the @Retry annotation is +configured to <code>retryOn</code> in case of failure, the FailSafe library will +take the <code>maxRetry</code> value and retry the same operation until it reaches +the number maximum of attempts, which is 3 (default value).</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="highlight"><code class="language-java" data-lang="java">@RequestScoped +public class WeatherGateway{ ... @Retry(maxRetry=3, retryOn = WeatherGatewayTimeoutException.class) public String statusOfDay(){ @@ -127,23 +184,53 @@ public class WeatherGateway{ LOGGER.warning(String.format(FORECAST_TIMEOUT_MESSAGE, DEFAULT_MAX_RETRY, counterStatusOfDay.get())); throw new WeatherGatewayTimeoutException(); } - return "Today is a sunny day!"; + return "Today is a sunny day!"; } ... - } -</code></pre> + }</code></pre> +</div> +</div> +<div class="paragraph"> <p>Day status call</p> -<pre><code>GET http://localhost:8080/mp-faulttolerance-retry/weather/day/status -</code></pre> +</div> +<div class="literalblock"> +<div class="content"> +<pre>GET http://localhost:8080/mp-faulttolerance-retry/weather/day/status</pre> +</div> +</div> +<div class="paragraph"> <p>Server log</p> -<pre><code>WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (1) WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (2) WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (3) -</code></pre> +</div> +<div class="literalblock"> +<div class="content"> +<pre>WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (1) +WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (2) +WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (3)</pre> +</div> +</div> +<div class="paragraph"> <p>Response</p> -<pre><code>Today is a sunny day! -</code></pre> -<h5>Example 2</h5> -<p>The method weekStatus will fail two times, each time, throwing a <code>WeatherGatewayTimeoutException</code> because <code>retryOn</code> is configured and instead of returning a response to the caller, the logic states that at the third attempt, a <code>WeatherGatewayBusyServiceException</code> will be thrown.<br/> As the <code>@Retry</code> annotation is configured to <code>abortOn</code> in case of <code>WeatherGatewayTimeoutException</code> happens, the remaining attempt won't be<br/> executed and the caller must handle the exception.</p> -<pre><code class="java">@Retry(maxRetries = 3, retryOn = WeatherGatewayTimeoutException.class, abortOn = WeatherGatewayBusyServiceException.class) +</div> +<div class="literalblock"> +<div class="content"> +<pre>Today is a sunny day!</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_example_2">Example 2</h3> +<div class="paragraph"> +<p>The method weekStatus will fail two times, each time, throwing a +<code>WeatherGatewayTimeoutException</code> because <code>retryOn</code> is configured and +instead of returning a response to the caller, the logic states that at +the third attempt, a <code>WeatherGatewayBusyServiceException</code> will be +thrown. As the <code>@Retry</code> annotation is configured to <code>abortOn</code> in case of +<code>WeatherGatewayTimeoutException</code> happens, the remaining attempt wonât be +executed and the caller must handle the exception.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="highlight"><code class="language-java" data-lang="java">@Retry(maxRetries = 3, retryOn = WeatherGatewayTimeoutException.class, abortOn = WeatherGatewayBusyServiceException.class) public String statusOfWeek(){ if(counterStatusOfWeek.addAndGet(1) <= DEFAULT_MAX_RETRY){ LOGGER.warning(String.format(FORECAST_TIMEOUT_MESSAGE_ATTEMPTS, DEFAULT_MAX_RETRY, counterStatusOfWeek.get())); @@ -151,81 +238,191 @@ public String statusOfWeek(){ } LOGGER.log(Level.SEVERE, String.format(FORECAST_BUSY_MESSAGE, counterStatusOfWeek.get())); throw new WeatherGatewayBusyServiceException(); -} -</code></pre> +}</code></pre> +</div> +</div> +<div class="paragraph"> <p>Week status call</p> -<pre><code>GET http://localhost:8080/mp-faulttolerance-retry/weather/week/status -</code></pre> +</div> +<div class="literalblock"> +<div class="content"> +<pre>GET http://localhost:8080/mp-faulttolerance-retry/weather/week/status</pre> +</div> +</div> +<div class="paragraph"> <p>Server log</p> -<pre><code>WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (1) WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (2) WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (3) SEVERE - Error AccuWeather Forecast Service is busy. Number of Attempts: (4) -</code></pre> +</div> +<div class="literalblock"> +<div class="content"> +<pre>WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (1) +WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (2) +WARNING - Timeout when accessing AccuWeather Forecast Service. Max of Attempts: (3), Attempts: (3) +SEVERE - Error AccuWeather Forecast Service is busy. Number of Attempts: (4)</pre> +</div> +</div> +<div class="paragraph"> <p>Response</p> -<pre><code>WeatherGateway Service is Busy. Retry later -</code></pre> -<h5>Example 3</h5> -<p>The <code>@Retry</code> annotation allows to configure a delay for each new attempt be executed giving a chance to service requested to recover itself and answerer the request properly. For each new retry follow the delay configure, is needed to set <code>jitter</code> to zero (0). Otherwise the delay of each new attempt will be randomized.</p> -<p>Analysing the logged messages, is possible to see that all attempts took the pretty much the same time to execute.</p> -<pre><code class="java ">@Retry(retryOn = WeatherGatewayTimeoutException.class, maxRetries = 5, delay = 500, jitter = 0) +</div> +<div class="literalblock"> +<div class="content"> +<pre>WeatherGateway Service is Busy. Retry later</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_example_3">Example 3</h3> +<div class="paragraph"> +<p>The <code>@Retry</code> annotation allows to configure a delay for each new attempt +be executed giving a chance to service requested to recover itself and +answerer the request properly. For each new retry follow the delay +configure, is needed to set <code>jitter</code> to zero (0). Otherwise the delay of +each new attempt will be randomized.</p> +</div> +<div class="paragraph"> +<p>Analysing the logged messages, is possible to see that all attempts took +the pretty much the same time to execute.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="highlight"><code class="language-java" data-lang="java">@Retry(retryOn = WeatherGatewayTimeoutException.class, maxRetries = 5, delay = 500, jitter = 0) public String statusOfWeekend() { if (counterStatusOfWeekend.addAndGet(1) <= 5) { logTimeoutMessage(statusOfWeekendInstant); statusOfWeekendInstant = Instant.now(); throw new WeatherGatewayTimeoutException(); } - return "The Forecast for the Weekend is Scattered Showers."; -} -</code></pre> + return "The Forecast for the Weekend is Scattered Showers."; +}</code></pre> +</div> +</div> +<div class="paragraph"> <p>Weekend status call</p> -<pre><code>GET http://localhost:8080/mp-faulttolerance-retry/weather/weekend/status -</code></pre> +</div> +<div class="literalblock"> +<div class="content"> +<pre>GET http://localhost:8080/mp-faulttolerance-retry/weather/weekend/status</pre> +</div> +</div> +<div class="paragraph"> <p>Server log</p> -<pre><code>WARNING - Timeout when accessing AccuWeather Forecast Service. WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (501) millis WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (501) millis WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (501) millis WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (500) millis -</code></pre> -<h5>Example 4</h5> -<p>Basically with the same behaviour of the <code>Example 3</code>, this example sets the <code>delay</code> and <code>jitter</code> with 500 millis to randomly create a new delay for each new attempt after the first failure. <a href="https://github.com/jhalterman/failsafe/blob/master/src/main/java/net/jodah/failsafe/AbstractExecution.java">AbstractExecution#randomDelay(delay,jitter,random)</a> can give a hit of how the new delay is calculated.</p> -<p>Analysing the logged messages, is possible to see how long each attempt had to wait until its execution.</p> -<pre><code class="java ">@Retry(retryOn = WeatherGatewayTimeoutException.class, delay = 500, jitter = 500) +</div> +<div class="literalblock"> +<div class="content"> +<pre>WARNING - Timeout when accessing AccuWeather Forecast Service. +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (501) millis +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (501) millis +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (501) millis +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (500) millis</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_example_4">Example 4</h3> +<div class="paragraph"> +<p>Basically with the same behaviour of the <code>Example 3</code>, this example sets +the <code>delay</code> and <code>jitter</code> with 500 millis to randomly create a new delay +for each new attempt after the first failure. +<a href="https://github.com/jhalterman/failsafe/blob/master/src/main/java/net/jodah/failsafe/AbstractExecution.java">AbstractExecution#randomDelay(delay,jitter,random)</a> +can give a hit of how the new delay is calculated.</p> +</div> +<div class="paragraph"> +<p>Analysing the logged messages, is possible to see how long each attempt +had to wait until its execution.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="highlight"><code class="language-java" data-lang="java">@Retry(retryOn = WeatherGatewayTimeoutException.class, delay = 500, jitter = 500) public String statusOfMonth() { if (counterStatusOfWeekend.addAndGet(1) <= DEFAULT_MAX_RETRY) { logTimeoutMessage(statusOfMonthInstant); statusOfMonthInstant = Instant.now(); throw new WeatherGatewayTimeoutException(); } - return "The Forecast for the Weekend is Scattered Showers."; -} -</code></pre> + return "The Forecast for the Weekend is Scattered Showers."; +}</code></pre> +</div> +</div> +<div class="paragraph"> <p>Month status call</p> -<pre><code>GET http://localhost:8080/mp-faulttolerance-retry/weather/month/status -</code></pre> +</div> +<div class="literalblock"> +<div class="content"> +<pre>GET http://localhost:8080/mp-faulttolerance-retry/weather/month/status</pre> +</div> +</div> +<div class="paragraph"> <p>Server log</p> -<pre><code>WARNING - Timeout when accessing AccuWeather Forecast Service. WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (417) millis WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (90) millis -</code></pre> -<h5>Example 5</h5> -<p>If a condition for an operation be re-executed is not set as in the previous examples using the parameter <code>retryOn</code>, the operation is executed again for <em>any</em> exception that is thrown.</p> -<pre><code class="java ">@Retry(maxDuration = 1000) +</div> +<div class="literalblock"> +<div class="content"> +<pre>WARNING - Timeout when accessing AccuWeather Forecast Service. +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (417) millis +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (90) millis</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_example_5">Example 5</h3> +<div class="paragraph"> +<p>If a condition for an operation be re-executed is not set as in the +previous examples using the parameter <code>retryOn</code>, the operation is +executed again for <em>any</em> exception that is thrown.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="highlight"><code class="language-java" data-lang="java">@Retry(maxDuration = 1000) public String statusOfYear(){ if (counterStatusOfWeekend.addAndGet(1) <= 5) { logTimeoutMessage(statusOfYearInstant); statusOfYearInstant = Instant.now(); throw new RuntimeException(); } - return "WeatherGateway Service Error"; -} -</code></pre> + return "WeatherGateway Service Error"; +}</code></pre> +</div> +</div> +<div class="paragraph"> <p>Year status call</p> -<pre><code>GET http://localhost:8080/mp-faulttolerance-retry/weather/year/statusk -</code></pre> +</div> +<div class="literalblock"> +<div class="content"> +<pre>GET http://localhost:8080/mp-faulttolerance-retry/weather/year/statusk</pre> +</div> +</div> +<div class="paragraph"> <p>Server log</p> -<pre><code>WARNING - Timeout when accessing AccuWeather Forecast Service. WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (666) millis WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (266) millis WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (66) millis -</code></pre> -<h5>Run the tests</h5> -<p>You can also try it out using the <a href="src/test/java/org/superbiz/rest/WeatherServiceTest.java">WeatherServiceTest.java</a> available in the project.</p> -<pre><code>mvn clean test -</code></pre> -<pre><code>[INFO] Results: -[INFO] -[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0 -</code></pre> +</div> +<div class="literalblock"> +<div class="content"> +<pre>WARNING - Timeout when accessing AccuWeather Forecast Service. +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (666) millis +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (266) millis +WARNING - Timeout when accessing AccuWeather Forecast Service. Delay before this attempt: (66) millis</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_run_the_tests">Run the tests</h3> +<div class="paragraph"> +<p>You can also try it out using the +<a href="src/test/java/org/superbiz/rest/WeatherServiceTest.java">WeatherServiceTest.java</a> +available in the project.</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>mvn clean test</pre> +</div> +</div> +<div class="literalblock"> +<div class="content"> +<pre>[INFO] Results: +[INFO] +[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0</pre> +</div> +</div> +</div> +</div> +</div> </div> </div> Modified: tomee/site/trunk/content/latest/examples/mp-metrics-counted.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/mp-metrics-counted.html?rev=1849998&r1=1849997&r2=1849998&view=diff ============================================================================== --- tomee/site/trunk/content/latest/examples/mp-metrics-counted.html (original) +++ tomee/site/trunk/content/latest/examples/mp-metrics-counted.html Sun Dec 30 19:02:51 2018 @@ -88,102 +88,210 @@ <div class="col-md-12"> <div class='page-header'> - <h1>Microprofile Metrics Counted</h1> + <h1>MicroProfile Metrics Counted</h1> </div> </div> </div> <div class="row"> <div class="col-md-12"> - <h1>Microprofile Metrics</h1> + <div id="preamble"> +<div class="sectionbody"> +<div class="paragraph"> <p>This is an example on how to use microprofile metrics in TomEE.</p> -<h5>Run the application:</h5> -<pre><code>mvn clean install tomee:run -</code></pre> -<p>Within the application there is an endpoint that will give you weather status for the day and week.</p> -<h5>For the day status call:</h5> -<pre><code>GET http://localhost:8080/rest-mp-metrics/weather/day/status -</code></pre> -<h5>Response:</h5> -<pre><code>Hi, today is a sunny day! -</code></pre> -<h4>Counted Feature</h4> -<p>MicroProfile metrics has a feature that can be used to count requests to a service.</p> -<p>To use this feature you need to annotate the JAX-RS resource method with @Counted.</p> -<pre><code>@Path("/weather") +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_run_the_application">Run the application:</h2> +<div class="sectionbody"> +<div class="literalblock"> +<div class="content"> +<pre>mvn clean install tomee:run</pre> +</div> +</div> +<div class="paragraph"> +<p>Within the application there is an endpoint that will give you weather +status for the day and week.</p> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_for_the_day_status_call">For the day status call:</h2> +<div class="sectionbody"> +<div class="literalblock"> +<div class="content"> +<pre>GET http://localhost:8080/rest-mp-metrics/weather/day/status</pre> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_response">Response:</h2> +<div class="sectionbody"> +<div class="literalblock"> +<div class="content"> +<pre>Hi, today is a sunny day!</pre> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_counted_feature">Counted Feature</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>MicroProfile metrics has a feature that can be used to count requests to +a service.</p> +</div> +<div class="paragraph"> +<p>To use this feature you need to annotate the JAX-RS resource method with +@Counted.</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@Path("/weather") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @ApplicationScoped public class WeatherService { - @Path("/day/status") - @Counted(monotonic = true, name = "weather_day_status", absolute = true) + @Path("/day/status") + @Counted(monotonic = true, name = "weather_day_status", absolute = true) @GET @Produces(MediaType.TEXT_PLAIN) public String dayStatus() { - return "Hi, today is a sunny day!"; + return "Hi, today is a sunny day!"; } ... -} -</code></pre> -<p>There are some configurations, as part of @Counted, that you need to know:</p> -<p><strong>String name</strong><br/>Optional. Sets the name of the metric. If not explicitly given the name of the annotated object is used.</p> -<p><strong>boolean absolute</strong><br/>If true, uses the given name as the absolute name of the metric. If false, prepends the package name and class name before the given name. Default value is false.</p> -<p><strong>String displayName</strong><br/>Optional. A human-readable display name for metadata.</p> -<p><strong>String description</strong><br/>Optional. A description of the metric.</p> -<p><strong>String[] tags</strong><br/>Optional. Array of Strings in the <key>=<value> format to supply special tags to a metric.</p> -<p><strong>boolean reusable</strong><br/>Denotes if a metric with a certain name can be registered in more than one place. Does not apply to gauges.</p> -<h4>Metric data</h4> +}</pre> +</div> +</div> +<div class="paragraph"> +<p>There are some configurations, as part of @Counted, that you need to +know:</p> +</div> +<div class="paragraph"> +<p><strong>String name</strong> Optional. Sets the name of the metric. If not explicitly +given the name of the annotated object is used.</p> +</div> +<div class="paragraph"> +<p><strong>boolean absolute</strong> If true, uses the given name as the absolute name of +the metric. If false, prepends the package name and class name before +the given name. Default value is false.</p> +</div> +<div class="paragraph"> +<p><strong>String displayName</strong> Optional. A human-readable display name for +metadata.</p> +</div> +<div class="paragraph"> +<p><strong>String description</strong> Optional. A description of the metric.</p> +</div> +<div class="paragraph"> +<p><strong>String[] tags</strong> Optional. Array of Strings in the = format to supply +special tags to a metric.</p> +</div> +<div class="paragraph"> +<p><strong>boolean reusable</strong> Denotes if a metric with a certain name can be +registered in more than one place. Does not apply to gauges.</p> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_metric_data">Metric data</h2> +<div class="sectionbody"> +<div class="paragraph"> <p>Check the counter metric doing a <em>GET</em> request:</p> -<h5>Prometheus format:</h5> -<pre><code>GET http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status -</code></pre> -<h5>Response:</h5> -<pre><code># TYPE application:weather_day_status counter -application:weather_day_status 1.0 -</code></pre> -<h5>JSON Format:</h5> -<p>For json format add the header <em>Accept=application/json</em> to the request. </p> -<pre><code>{ - "weather_day_status": { - "delegate": {}, - "unit": "none", - "count": 1 +</div> +<div class="sect2"> +<h3 id="_prometheus_format">Prometheus format:</h3> +<div class="literalblock"> +<div class="content"> +<pre>GET http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_response_2">Response:</h3> +<div class="literalblock"> +<div class="content"> +<pre># TYPE application:weather_day_status counter +application:weather_day_status 1.0</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_json_format">JSON Format:</h3> +<div class="paragraph"> +<p>For json format add the header <em>Accept=application/json</em> to the request.</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>{ + "weather_day_status": { + "delegate": {}, + "unit": "none", + "count": 1 } -} -</code></pre> -<h4>Metric metadata</h4> -<p>A metric will have a metadata so you can know more information about it, like displayName, description, tags e etc.</p> +}</pre> +</div> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_metric_metadata">Metric metadata</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>A metric will have a metadata so you can know more information about it, +like displayName, description, tags e etc.</p> +</div> +<div class="paragraph"> <p>Check the metric metadata doing a <em>OPTIONS</em> request:</p> -<h5>Request</h5> -<pre><code>OPTIONS http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status -</code></pre> -<h5>Response:</h5> -<pre><code>{ - "weather_day_status": { - "unit": "none", - "displayName": "Weather Day Status", - "name": "weather_day_status", - "typeRaw": "COUNTER", - "description": "This metric shows the weather status of the day.", - "type": "counter", - "value": { - "unit": "none", - "displayName": "Weather Day Status", - "name": "weather_day_status", - "tagsAsString": "", - "typeRaw": "COUNTER", - "description": "This metric shows the weather status of the day.", - "type": "counter", - "reusable": false, - "tags": {} +</div> +<div class="sect2"> +<h3 id="_request">Request</h3> +<div class="literalblock"> +<div class="content"> +<pre>OPTIONS http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_response_3">Response:</h3> +<div class="literalblock"> +<div class="content"> +<pre>{ + "weather_day_status": { + "unit": "none", + "displayName": "Weather Day Status", + "name": "weather_day_status", + "typeRaw": "COUNTER", + "description": "This metric shows the weather status of the day.", + "type": "counter", + "value": { + "unit": "none", + "displayName": "Weather Day Status", + "name": "weather_day_status", + "tagsAsString": "", + "typeRaw": "COUNTER", + "description": "This metric shows the weather status of the day.", + "type": "counter", + "reusable": false, + "tags": {} }, - "reusable": false, - "tags": "" + "reusable": false, + "tags": "" } -} -</code></pre> -<p>You can also try it out using the WeatherServiceTest.java available in the project.</p> +}</pre> +</div> +</div> +<div class="paragraph"> +<p>You can also try it out using the WeatherServiceTest.java available in +the project.</p> +</div> +</div> +</div> +</div> </div> </div> Modified: tomee/site/trunk/content/latest/examples/mp-metrics-histogram.html URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/latest/examples/mp-metrics-histogram.html?rev=1849998&r1=1849997&r2=1849998&view=diff ============================================================================== --- tomee/site/trunk/content/latest/examples/mp-metrics-histogram.html (original) +++ tomee/site/trunk/content/latest/examples/mp-metrics-histogram.html Sun Dec 30 19:02:51 2018 @@ -88,77 +88,147 @@ <div class="col-md-12"> <div class='page-header'> - <h1>Microprofile Metrics Histogram</h1> + <h1>MicroProfile Metrics Histogram</h1> </div> </div> </div> <div class="row"> <div class="col-md-12"> - <h1>Microprofile Metrics</h1> + <div id="preamble"> +<div class="sectionbody"> +<div class="paragraph"> <p>This is an example on how to use microprofile metrics in TomEE.</p> -<h5>Run the application:</h5> -<pre><code>mvn clean install tomee:run -</code></pre> -<p>Within the application, there is an enpoint that will give you a weather histogram of the most recent New York City temperatures.</p> -<h5>Request:</h5> -<pre><code>curl -X GET http://localhost:8080/mp-metrics-histogram/weather/histogram -</code></pre> -<h5>Response:</h5> -<pre><code>{ - "count":15, - "max":55, - "mean":44.4, - "min":27, - "p50":45.0, - "p75":46.0, - "p95":54.0, - "p98":54.0, - "p99":54.0, - "p999":54.0, - "stddev":7.0710678118654755, - "unit":"degrees F" -} -</code></pre> -<h4>Histogram Feature</h4> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_run_the_application">Run the application:</h2> +<div class="sectionbody"> +<div class="literalblock"> +<div class="content"> +<pre>mvn clean install tomee:run</pre> +</div> +</div> +<div class="paragraph"> +<p>Within the application, there is an enpoint that will give you a weather +histogram of the most recent New York City temperatures.</p> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_request">Request:</h2> +<div class="sectionbody"> +<div class="literalblock"> +<div class="content"> +<pre>curl -X GET http://localhost:8080/mp-metrics-histogram/weather/histogram</pre> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_response">Response:</h2> +<div class="sectionbody"> +<div class="literalblock"> +<div class="content"> +<pre>{ + "count":15, + "max":55, + "mean":44.4, + "min":27, + "p50":45.0, + "p75":46.0, + "p95":54.0, + "p98":54.0, + "p99":54.0, + "p999":54.0, + "stddev":7.0710678118654755, + "unit":"degrees F" +}</pre> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_histogram_feature">Histogram Feature</h2> +<div class="sectionbody"> +<div class="paragraph"> <p>Microprofile metrics has a feature create a histogram of data.</p> -<p>To use this feature, inject a MetricRegistry, register the Histogram, and add data to the histogram as shown below.</p> -<pre><code>@Inject +</div> +<div class="paragraph"> +<p>To use this feature, inject a MetricRegistry, register the Histogram, +and add data to the histogram as shown below.</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@Inject private MetricRegistry registry; @Inject -@Metric(name = "temperatures", description = "A histogram metrics example.", - displayName = "Histogram of Recent New York Temperatures") +@Metric(name = "temperatures", description = "A histogram metrics example.", + displayName = "Histogram of Recent New York Temperatures") private Histogram histogram; -@Path("/histogram") +@Path("/histogram") @GET @Produces(MediaType.APPLICATION_JSON) public Histogram getTemperatures() { - Metadata metadata = new Metadata("temperatures", MetricType.HISTOGRAM, "degrees F"); - metadata.setDescription("A histogram of recent New York temperatures."); + Metadata metadata = new Metadata("temperatures", MetricType.HISTOGRAM, "degrees F"); + metadata.setDescription("A histogram of recent New York temperatures."); final int[] RECENT_NEW_YORK_TEMPS = { 46, 45, 50, 46, 45, 27, 30, 48, 55, 54, 45, 41, 45, 43, 46 }; histogram = registry.histogram(metadata); for(int temp : RECENT_NEW_YORK_TEMPS) { histogram.update(temp); } return histogram; -} -</code></pre> -<p>There are some Histogram configurations defined in the @Metric annotation:</p> -<p><strong>String name</strong><br/>Optional. The name of the metric. If not explicitly given the name of the annotated object is used.</p> -<p><strong>String displayName</strong><br/>Optional. A human readable display name for metadata.</p> -<p><strong>String description</strong><br/>Optional. A description of the metric.</p> -<p><strong>String[] tags</strong><br/>Optional. An array of Strings in the <key>=<value> format to supply special tags to a metric.</p> -<p><strong>boolean reusable</strong><br/>Denotes if a metric with a certain name can be registered in more than one place. Does not apply to gauges or histograms.</p> -<h5>For the histogram status:</h5> -<pre><code>GET http://localhost:8080/mp-metrics-histogram/weather/histogram/status -</code></pre> -<h5>Reponse:</h5> -<pre><code> Here are the most recent New York City temperatures. -</code></pre> -<h5>Expected Prometheus format:</h5> -<pre><code> # TYPE application:temperatures_degrees F summary histogram +}</pre> +</div> +</div> +<div class="paragraph"> +<p>There are some Histogram configurations defined in the @Metric +annotation:</p> +</div> +<div class="paragraph"> +<p><strong>String name</strong> Optional. The name of the metric. If not explicitly given +the name of the annotated object is used.</p> +</div> +<div class="paragraph"> +<p><strong>String displayName</strong> Optional. A human readable display name for +metadata.</p> +</div> +<div class="paragraph"> +<p><strong>String description</strong> Optional. A description of the metric.</p> +</div> +<div class="paragraph"> +<p><strong>String[] tags</strong> Optional. An array of Strings in the = format to supply +special tags to a metric.</p> +</div> +<div class="paragraph"> +<p><strong>boolean reusable</strong> Denotes if a metric with a certain name can be +registered in more than one place. Does not apply to gauges or +histograms.</p> +</div> +<div class="sect2"> +<h3 id="_for_the_histogram_status">For the histogram status:</h3> +<div class="literalblock"> +<div class="content"> +<pre>GET http://localhost:8080/mp-metrics-histogram/weather/histogram/status</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_reponse">Reponse:</h3> +<div class="literalblock"> +<div class="content"> +<pre> Here are the most recent New York City temperatures.</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_expected_prometheus_format">Expected Prometheus format:</h3> +<div class="literalblock"> +<div class="content"> +<pre> # TYPE application:temperatures_degrees F summary histogram # TYPE application:temperatures_degrees F_count histogram application:temperatures_degrees F_count 15.0 # TYPE application:temperatures_min_degrees F histogram @@ -170,17 +240,17 @@ public Histogram getTemperatures() { # TYPE application:temperatures_stddev_degrees F histogram application:temperatures_stddev_degrees F 7.0710678118654755 # TYPE application:temperatures_degrees F histogram - application:temperatures_degrees F{quantile="0.5"} 45.0 + application:temperatures_degrees F{quantile="0.5"} 45.0 # TYPE application:temperatures_degrees F histogram - application:temperatures_degrees F{quantile="0.75"} 46.0 + application:temperatures_degrees F{quantile="0.75"} 46.0 # TYPE application:temperatures_degrees F histogram - application:temperatures_degrees F{quantile="0.95"} 54.0 + application:temperatures_degrees F{quantile="0.95"} 54.0 # TYPE application:temperatures_degrees F histogram - application:temperatures_degrees F{quantile="0.98"} 54.0 + application:temperatures_degrees F{quantile="0.98"} 54.0 # TYPE application:temperatures_degrees F histogram - application:temperatures_degrees F{quantile="0.99"} 54.0 + application:temperatures_degrees F{quantile="0.99"} 54.0 # TYPE application:temperatures_degrees F histogram - application:temperatures_degrees F{quantile="0.999"} 54.0 + application:temperatures_degrees F{quantile="0.999"} 54.0 # TYPE application:org_superbiz_histogram_weather_service_temperatures summary histogram # TYPE application:org_superbiz_histogram_weather_service_temperatures_count histogram application:org_superbiz_histogram_weather_service_temperatures_count 0.0 @@ -193,60 +263,96 @@ public Histogram getTemperatures() { # TYPE application:org_superbiz_histogram_weather_service_temperatures_stddev histogram application:org_superbiz_histogram_weather_service_temperatures_stddev 0.0 # TYPE application:org_superbiz_histogram_weather_service_temperatures histogram - application:org_superbiz_histogram_weather_service_temperatures{quantile="0.5"} 0.0 + application:org_superbiz_histogram_weather_service_temperatures{quantile="0.5"} 0.0 # TYPE application:org_superbiz_histogram_weather_service_temperatures histogram - application:org_superbiz_histogram_weather_service_temperatures{quantile="0.75"} 0.0 + application:org_superbiz_histogram_weather_service_temperatures{quantile="0.75"} 0.0 # TYPE application:org_superbiz_histogram_weather_service_temperatures histogram - application:org_superbiz_histogram_weather_service_temperatures{quantile="0.95"} 0.0 + application:org_superbiz_histogram_weather_service_temperatures{quantile="0.95"} 0.0 # TYPE application:org_superbiz_histogram_weather_service_temperatures histogram - application:org_superbiz_histogram_weather_service_temperatures{quantile="0.98"} 0.0 + application:org_superbiz_histogram_weather_service_temperatures{quantile="0.98"} 0.0 # TYPE application:org_superbiz_histogram_weather_service_temperatures histogram - application:org_superbiz_histogram_weather_service_temperatures{quantile="0.99"} 0.0 - # TYPE application:org_superbiz_histogram_weather_service_temperatures histogram - application:org_superbiz_histogram_weather_service_temperatures{quantile="0.999"} 0.0 -</code></pre> -<h5>Request:</h5> -<pre><code>curl -X GET http://localhost:8080/mp-metrics-histogram/metrics/application -</code></pre> -<h5>Response:</h5> -<pre><code>{ - "org.superbiz.histogram.WeatherService.temperatures": { - "count":0, - "max":0, - "min":0, - "p50":0.0, - "p75":0.0, - "p95":0.0, - "p98":0.0, - "p99":0.0, - "p999":0.0, - "stddev":0.0, - "unit":"none" + application:org_superbiz_histogram_weather_service_temperatures{quantile="0.99"} 0.0 + # TYPE application:org_superbiz_histogram_weather_service_temperatures histogram + application:org_superbiz_histogram_weather_service_temperatures{quantile="0.999"} 0.0</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_request_2">Request:</h3> +<div class="literalblock"> +<div class="content"> +<pre>curl -X GET http://localhost:8080/mp-metrics-histogram/metrics/application</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_response_2">Response:</h3> +<div class="literalblock"> +<div class="content"> +<pre>{ + "org.superbiz.histogram.WeatherService.temperatures": { + "count":0, + "max":0, + "min":0, + "p50":0.0, + "p75":0.0, + "p95":0.0, + "p98":0.0, + "p99":0.0, + "p999":0.0, + "stddev":0.0, + "unit":"none" } -} -</code></pre> -<h4>Metric Metadata:</h4> -<p>A metric will have a metadata to provide information about it such as displayName, description, tags, etc.</p> -<h5>Request:</h5> -<pre><code>curl -X OPTIONS http://localhost:8080/mp-metrics-histogram/metrics/application -</code></pre> -<h5>Response:</h5> -<pre><code>{ - "org.superbiz.histogram.WeatherService.temperatures": { - "description": "A histogram metrics example.", - "displayName":"Histogram of Recent New York Temperatures", - "name":"org.superbiz.histogram.WeatherService.temperatures", - "reusable":false, - "tags":"", - "type":"histogram", - "typeRaw":"HISTOGRAM", - "unit":"none" +}</pre> +</div> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_metric_metadata">Metric Metadata:</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>A metric will have a metadata to provide information about it such as +displayName, description, tags, etc.</p> +</div> +<div class="sect2"> +<h3 id="_request_3">Request:</h3> +<div class="literalblock"> +<div class="content"> +<pre>curl -X OPTIONS http://localhost:8080/mp-metrics-histogram/metrics/application</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_response_3">Response:</h3> +<div class="literalblock"> +<div class="content"> +<pre>{ + "org.superbiz.histogram.WeatherService.temperatures": { + "description": "A histogram metrics example.", + "displayName":"Histogram of Recent New York Temperatures", + "name":"org.superbiz.histogram.WeatherService.temperatures", + "reusable":false, + "tags":"", + "type":"histogram", + "typeRaw":"HISTOGRAM", + "unit":"none" } -} -</code></pre> -<h5>Test the application:</h5> -<pre><code>mvn test -</code></pre> +}</pre> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_test_the_application">Test the application:</h3> +<div class="literalblock"> +<div class="content"> +<pre>mvn test</pre> +</div> +</div> +</div> +</div> +</div> </div> </div>
