You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2018/12/28 09:30:17 UTC
tomee git commit: This closes #319. Thanks puneethps.
Repository: tomee
Updated Branches:
refs/heads/master 67e745be3 -> 3d5e07bc7
This closes #319. Thanks puneethps.
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/3d5e07bc
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/3d5e07bc
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/3d5e07bc
Branch: refs/heads/master
Commit: 3d5e07bc7e875ef08de85b53caf991f56d661a5c
Parents: 67e745b
Author: Jean-Louis Monteiro <je...@gmail.com>
Authored: Fri Dec 28 10:30:07 2018 +0100
Committer: Jean-Louis Monteiro <je...@gmail.com>
Committed: Fri Dec 28 10:30:07 2018 +0100
----------------------------------------------------------------------
examples/cdi-session-scope/README.md | 122 ---------------------------
examples/cdi-session-scope/pom.xml | 3 +
examples/mp-metrics-metered/README.md | 130 -----------------------------
3 files changed, 3 insertions(+), 252 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/3d5e07bc/examples/cdi-session-scope/README.md
----------------------------------------------------------------------
diff --git a/examples/cdi-session-scope/README.md b/examples/cdi-session-scope/README.md
deleted file mode 100644
index 3ca2080..0000000
--- a/examples/cdi-session-scope/README.md
+++ /dev/null
@@ -1,122 +0,0 @@
-index-group=Unrevised
-type=page
-status=unpublished
-title=CDI @SessionScoped
-~~~~~~
-
-This example show the use of `@SessionScoped` annotation for injected objects. An object
-which is defined as `@SessionScoped` is created once for every HTTPSession and is shared by all the
-beans that inject it throughout the same HTTPSession.
-
-##### Run the application:
-
- mvn clean install tomee:run
-
-# Example
-
-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.
-
-#Request
-
-GET http://localhost:8080/cdi-session-scope-8.0.0-SNAPSHOT/set-name?name=Puneeth
-
-#Response
-
-done, go to /name servlet
-
-#Request
-
-GET http://localhost:8080/cdi-session-scope-8.0.0-SNAPSHOT/name
-
-#Response
-
-name = {Puneeth}
-
-##SessionBean
-
-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.
-
-@SessionScoped
-public class SessionBean implements Serializable {
-
- private String name;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
-
-##InputServlet
-
-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.
-
-@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");
- }
-
- }
-}
-
-##AnswerBean
-
-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.
-
-public class AnswerBean {
-
- @Inject
- private SessionBean bean;
-
- private String value;
-
- @PostConstruct
- public void init() {
- value = '{' + bean.getName() + '}';
- }
-
- public String value() {
- return value;
- }
-}
-
-##OutputServlet
-
-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.
-
-@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);
- }
- }
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/tomee/blob/3d5e07bc/examples/cdi-session-scope/pom.xml
----------------------------------------------------------------------
diff --git a/examples/cdi-session-scope/pom.xml b/examples/cdi-session-scope/pom.xml
index 49496bf..1dd90df 100644
--- a/examples/cdi-session-scope/pom.xml
+++ b/examples/cdi-session-scope/pom.xml
@@ -46,6 +46,9 @@
<groupId>org.apache.tomee.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>8.0.0-SNAPSHOT</version>
+ <configuration>
+ <context>${artifactId}</context>
+ </configuration>
</plugin>
</plugins>
</build>
http://git-wip-us.apache.org/repos/asf/tomee/blob/3d5e07bc/examples/mp-metrics-metered/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-metered/README.md b/examples/mp-metrics-metered/README.md
deleted file mode 100644
index fed2d52..0000000
--- a/examples/mp-metrics-metered/README.md
+++ /dev/null
@@ -1,130 +0,0 @@
-index-group=Unrevised
-type=page
-status=published
-~~~~~~
-# Microprofile Metrics
-This is an example on how to use microprofile metrics in TomEE.
-
-##### Run the application:
-
- mvn clean install tomee:run
-
-Within the application, there is an enpoint that will give you a weather weather status for the day and week.
-
-##### For the day status call:
-
- GET http://localhost:8080/mp-metrics-metered/weather/day/status
-
-##### Response:
-
- Hi, today is a sunny day!
-
-#### Metered Feature
-MicroProfile metrics has a feature that can be used to find the rate of requests to a service.
-
-To use this feature you need to annotate the JAX-RS resource method with @Metered.
-
- @Path("/weather")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- @ApplicationScoped
- public class WeatherService {
-
- @Path("/day/status")
- @Metered(name = "dailyStatus", unit = MetricUnits.MINUTES, description = "Metrics to daily weather status method", absolute = true)
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String dayStatus() {
- return "Hi, today is a sunny day!";
- }
- ...
- }
-
-There are some configurations, as part of @Metered, that you need to know:
-
-**String name**
-Optional. Sets the name of the metric. If not explicitly given the name of the annotated object is used.
-
-**boolean absolute**
-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.
-
-**String displayName**
-Optional. A human-readable display name for metadata.
-
-**String description**
-Optional. A description of the metric.
-
-**String[] tags**
-Optional. Array of Strings in the <key>=<value> format to supply special tags to a metric.
-
-**boolean reusable**
-Denotes if a metric with a certain name can be registered in more than one place. Does not apply to gauges.
-
-**String unit**
-Unit of the metric. Default for @Metered is nanoseconds.
-
-#### Metric data
-
-Check the Metered metric doing a _GET_ request:
-
-##### Prometheus format:
-
- GET http://localhost:8080/mp-metrics-metered/metrics/application/dailyStatus
-
-##### Response:
-
- # TYPE application:daily_status_seconds_count meter
- application:daily_status_seconds_count 1.2E-7
- # TYPE application:daily_status_rate_per_second meter
- application:daily_status_rate_per_second 0.0
- # TYPE application:daily_status_one_min_rate_per_second meter
- application:daily_status_one_min_rate_per_second 1.3376002644204984E-19
- # TYPE application:daily_status_five_min_rate_per_second meter
- application:daily_status_five_min_rate_per_second 3.5942838529305413E-20
- # TYPE application:daily_status_fifteen_min_rate_per_second meter
- application:daily_status_fifteen_min_rate_per_second 3.4665766454142955E-21
-
-
-##### JSON Format:
-
-For json format add the header _Accept=application/json_ to the request.
-
- {
- "dailyStatus": {
- "count": 2,
- "fifteenMinRate": 5.77762774235716e-14,
- "fiveMinRate": 5.990473088217569e-13,
- "meanRate": 0,
- "oneMinRate": 2.229333774034164e-12,
- "unit": "minutes"
- }
- }
-
-#### Metric metadata
-A metric will have a metadata so you can know more information about it, like displayName, description, tags etc.
-
-Check the metric metadata doing a _OPTIONS_ request:
-
-##### Request
-
- OPTIONS http://localhost:8080/mp-metrics-metered/metrics/application/dailyStatus
-
-##### Response:
-
- {
- "dailyStatus": {
- "description": "Metrics to daily weather status method",
- "displayName": "",
- "name": "dailyStatus",
- "reusable": false,
- "tags": "",
- "type": "meter",
- "typeRaw": "METERED",
- "unit": "minutes"
- }
- }
-
-
-##### Test the application:
-
- mvn test