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:31:26 UTC
[1/9] tomee git commit: TOMEE-2405 - created
examples/mp-faulttolerance-retry/README.adoc and added index-group
MicroProfile
Repository: tomee
Updated Branches:
refs/heads/master 3d5e07bc7 -> 272fed31f
TOMEE-2405 - created examples/mp-faulttolerance-retry/README.adoc and added index-group MicroProfile
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/0fe27129
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/0fe27129
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/0fe27129
Branch: refs/heads/master
Commit: 0fe27129cb8ad64d406cabe184af7113392f7c4f
Parents: 761c283
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Wed Dec 19 20:45:17 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Wed Dec 19 20:45:17 2018 -0600
----------------------------------------------------------------------
examples/mp-faulttolerance-retry/README.adoc | 256 ++++++++++++++++++++++
examples/mp-faulttolerance-retry/README.md | 215 ------------------
2 files changed, 256 insertions(+), 215 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/0fe27129/examples/mp-faulttolerance-retry/README.adoc
----------------------------------------------------------------------
diff --git a/examples/mp-faulttolerance-retry/README.adoc b/examples/mp-faulttolerance-retry/README.adoc
new file mode 100644
index 0000000..8f40268
--- /dev/null
+++ b/examples/mp-faulttolerance-retry/README.adoc
@@ -0,0 +1,256 @@
+:index-group: MicroProfile
+:jbake-type: page
+:jbake-status: published
+
+# Microprofile Fault Tolerance - Retry policy
+
+This is an example of how to use
+Microprofile @Retry in TomEE.
+
+== Retry Feature
+
+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.
+
+The Retry policy allows to configure :
+
+* *maxRetries*: the maximum retries
+* *delay*: delays between each retry
+* *delayUnit*: the delay unit
+* *maxDuration*: maximum duration to perform the retry for.
+* *durationUnit*: duration unit
+* *jitter:* the random vary of retry delays
+* *jitterDelayUnit:* the jitter unit
+* *retryOn:* specify the failures to retry on
+* *abortOn:* specify the failures to abort on
+
+To use this feature you can annotate a class and/or a method with the
+@Retry annotation. Check the
+http://download.eclipse.org/microprofile/microprofile-fault-tolerance-1.1/microprofile-fault-tolerance-spec.html[specification]
+for more details.
+
+== Examples
+
+=== Run the application
+
+....
+mvn clean install tomee:run
+....
+
+=== Example 1
+
+The method statusOfDay will fail three times, each time, throwing a
+`WeatherGatewayTimeoutException` and as the @Retry annotation is
+configured to `retryOn` in case of failure, the FailSafe library will
+take the `maxRetry` value and retry the same operation until it reaches
+the number maximum of attempts, which is 3 (default value).
+
+[source,java]
+----
+@RequestScoped
+public class WeatherGateway{
+ ...
+ @Retry(maxRetry=3, retryOn = WeatherGatewayTimeoutException.class)
+ public String statusOfDay(){
+ if(counterStatusOfDay.addAndGet(1) <= DEFAULT_MAX_RETRY){
+ LOGGER.warning(String.format(FORECAST_TIMEOUT_MESSAGE, DEFAULT_MAX_RETRY, counterStatusOfDay.get()));
+ throw new WeatherGatewayTimeoutException();
+ }
+ return "Today is a sunny day!";
+ }
+ ...
+ }
+----
+
+Day status call
+
+....
+GET http://localhost:8080/mp-faulttolerance-retry/weather/day/status
+....
+
+Server log
+
+....
+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)
+....
+
+Response
+
+....
+Today is a sunny day!
+....
+
+=== Example 2
+
+The method weekStatus will fail two times, each time, throwing a
+`WeatherGatewayTimeoutException` because `retryOn` is configured and
+instead of returning a response to the caller, the logic states that at
+the third attempt, a `WeatherGatewayBusyServiceException` will be
+thrown. As the `@Retry` annotation is configured to `abortOn` in case of
+`WeatherGatewayTimeoutException` happens, the remaining attempt won’t be
+executed and the caller must handle the exception.
+
+[source,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()));
+ throw new WeatherGatewayTimeoutException();
+ }
+ LOGGER.log(Level.SEVERE, String.format(FORECAST_BUSY_MESSAGE, counterStatusOfWeek.get()));
+ throw new WeatherGatewayBusyServiceException();
+}
+----
+
+Week status call
+
+....
+GET http://localhost:8080/mp-faulttolerance-retry/weather/week/status
+....
+
+Server log
+
+....
+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)
+....
+
+Response
+
+....
+WeatherGateway Service is Busy. Retry later
+....
+
+=== Example 3
+
+The `@Retry` 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 `jitter` to zero (0). Otherwise the delay of
+each new attempt will be randomized.
+
+Analysing the logged messages, is possible to see that all attempts took
+the pretty much the same time to execute.
+
+[source,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.";
+}
+----
+
+Weekend status call
+
+....
+GET http://localhost:8080/mp-faulttolerance-retry/weather/weekend/status
+....
+
+Server log
+
+....
+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
+....
+
+=== Example 4
+
+Basically with the same behaviour of the `Example 3`, this example sets
+the `delay` and `jitter` with 500 millis to randomly create a new delay
+for each new attempt after the first failure.
+https://github.com/jhalterman/failsafe/blob/master/src/main/java/net/jodah/failsafe/AbstractExecution.java[AbstractExecution#randomDelay(delay,jitter,random)]
+can give a hit of how the new delay is calculated.
+
+Analysing the logged messages, is possible to see how long each attempt
+had to wait until its execution.
+
+[source,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.";
+}
+----
+
+Month status call
+
+....
+GET http://localhost:8080/mp-faulttolerance-retry/weather/month/status
+....
+
+Server log
+
+....
+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
+....
+
+=== Example 5
+
+If a condition for an operation be re-executed is not set as in the
+previous examples using the parameter `retryOn`, the operation is
+executed again for _any_ exception that is thrown.
+
+[source,java]
+----
+@Retry(maxDuration = 1000)
+public String statusOfYear(){
+ if (counterStatusOfWeekend.addAndGet(1) <= 5) {
+ logTimeoutMessage(statusOfYearInstant);
+ statusOfYearInstant = Instant.now();
+ throw new RuntimeException();
+ }
+ return "WeatherGateway Service Error";
+}
+----
+
+Year status call
+
+....
+GET http://localhost:8080/mp-faulttolerance-retry/weather/year/statusk
+....
+
+Server log
+
+....
+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
+....
+
+=== Run the tests
+
+You can also try it out using the
+link:src/test/java/org/superbiz/rest/WeatherServiceTest.java[WeatherServiceTest.java]
+available in the project.
+
+....
+mvn clean test
+....
+
+....
+[INFO] Results:
+[INFO]
+[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
+....
http://git-wip-us.apache.org/repos/asf/tomee/blob/0fe27129/examples/mp-faulttolerance-retry/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-faulttolerance-retry/README.md b/examples/mp-faulttolerance-retry/README.md
deleted file mode 100644
index 8955655..0000000
--- a/examples/mp-faulttolerance-retry/README.md
+++ /dev/null
@@ -1,215 +0,0 @@
-index-group=Unrevised
-type=page
-status=published
-~~~~~~
-# Microprofile Fault Tolerance - Retry policy
-This is an example of how to use Microprofile @Retry in TomEE.
-
-#### Retry Feature
-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.
-
-The Retry policy allows to configure :
-
-* **maxRetries**: the maximum retries
-* **delay**: delays between each retry
-* **delayUnit**: the delay unit
-* **maxDuration**: maximum duration to perform the retry for.
-* **durationUnit**: duration unit
-* **jitter:** the random vary of retry delays
-* **jitterDelayUnit:** the jitter unit
-* **retryOn:** specify the failures to retry on
-* **abortOn:** specify the failures to abort on
-
-To use this feature you can annotate a class and/or a method with the @Retry annotation.
-Check the [specification](http://download.eclipse.org/microprofile/microprofile-fault-tolerance-1.1/microprofile-fault-tolerance-spec.html) for more details.
-
-### Examples
-
-##### Run the application
-
- mvn clean install tomee:run
-
-##### Example 1
-
-The method statusOfDay will fail three times, each time, throwing a `WeatherGatewayTimeoutException` and as the
-@Retry annotation is configured to `retryOn` in case of failure, the FailSafe library will take the `maxRetry` value and
-retry the same operation until it reaches the number maximum of attempts, which is 3 (default value).
-
-```java
-@RequestScoped
-public class WeatherGateway{
- ...
- @Retry(maxRetry=3, retryOn = WeatherGatewayTimeoutException.class)
- public String statusOfDay(){
- if(counterStatusOfDay.addAndGet(1) <= DEFAULT_MAX_RETRY){
- LOGGER.warning(String.format(FORECAST_TIMEOUT_MESSAGE, DEFAULT_MAX_RETRY, counterStatusOfDay.get()));
- throw new WeatherGatewayTimeoutException();
- }
- return "Today is a sunny day!";
- }
- ...
- }
-```
-
-Day status call
-
- GET http://localhost:8080/mp-faulttolerance-retry/weather/day/status
-
-Server log
-```
-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)
-```
-
-Response
-```
-Today is a sunny day!
-```
-
-##### Example 2
-
-The method weekStatus will fail two times, each time, throwing a `WeatherGatewayTimeoutException` because `retryOn` is configured and instead of
-returning a response to the caller, the logic states that at the third attempt, a `WeatherGatewayBusyServiceException` will be thrown.
- As the `@Retry` annotation is configured to `abortOn` in case of `WeatherGatewayTimeoutException` happens, the remaining attempt won't be
- executed and the caller must handle the exception.
-
-```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()));
- throw new WeatherGatewayTimeoutException();
- }
- LOGGER.log(Level.SEVERE, String.format(FORECAST_BUSY_MESSAGE, counterStatusOfWeek.get()));
- throw new WeatherGatewayBusyServiceException();
-}
-```
-
-Week status call
-
- GET http://localhost:8080/mp-faulttolerance-retry/weather/week/status
-
-Server log
-
-```
-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)
-```
-
-Response
-```
-WeatherGateway Service is Busy. Retry later
-```
-
-##### Example 3
-
-The `@Retry` 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 `jitter` to zero (0). Otherwise the delay of each new attempt will be randomized.
-
-Analysing the logged messages, is possible to see that all attempts took the pretty much the same time to execute.
-
-```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.";
-}
-```
-
-Weekend status call
-
- GET http://localhost:8080/mp-faulttolerance-retry/weather/weekend/status
-
-Server log
-
-```
-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
-```
-
-##### Example 4
-
-Basically with the same behaviour of the `Example 3`, this example sets the `delay` and `jitter` with 500 millis to randomly
-create a new delay for each new attempt after the first failure. [AbstractExecution#randomDelay(delay,jitter,random)](https://github.com/jhalterman/failsafe/blob/master/src/main/java/net/jodah/failsafe/AbstractExecution.java)
-can give a hit of how the new delay is calculated.
-
-Analysing the logged messages, is possible to see how long each attempt had to wait until its execution.
-
-```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.";
-}
-```
-
-Month status call
-
- GET http://localhost:8080/mp-faulttolerance-retry/weather/month/status
-
-Server log
-
-```
-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
-```
-
-##### Example 5
-
-If a condition for an operation be re-executed is not set as in the previous examples using the parameter `retryOn`,
-the operation is executed again for _any_ exception that is thrown.
-
-```java
-@Retry(maxDuration = 1000)
-public String statusOfYear(){
- if (counterStatusOfWeekend.addAndGet(1) <= 5) {
- logTimeoutMessage(statusOfYearInstant);
- statusOfYearInstant = Instant.now();
- throw new RuntimeException();
- }
- return "WeatherGateway Service Error";
-}
-```
-
-Year status call
-
- GET http://localhost:8080/mp-faulttolerance-retry/weather/year/statusk
-
-Server log
-
-```
-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
-```
-
-##### Run the tests
-
-You can also try it out using the [WeatherServiceTest.java](src/test/java/org/superbiz/rest/WeatherServiceTest.java) available in the project.
-
- mvn clean test
-
-```
-[INFO] Results:
-[INFO]
-[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
-```
-
[8/9] tomee git commit: resolving conflicts
Posted by jl...@apache.org.
resolving conflicts
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/0d82e5ee
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/0d82e5ee
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/0d82e5ee
Branch: refs/heads/master
Commit: 0d82e5ee422fd1280e402008dd809e87a211d083
Parents: fcdaefe 0866dbe
Author: ivanjunckes <ij...@tomitribe.com>
Authored: Thu Dec 27 12:06:13 2018 -0200
Committer: ivanjunckes <ij...@tomitribe.com>
Committed: Thu Dec 27 12:06:13 2018 -0200
----------------------------------------------------------------------
.../arquillian/tests/filter/AllFilterTest.java | 1 -
.../tests/realm/CdiLazyRealmTOMEE1490Test.java | 4 +-
arquillian/arquillian-tomee-tests/pom.xml | 39 ++
.../org/apache/openejb/ClassLoaderUtil.java | 12 +-
.../java/org/apache/openejb/MethodSpec.java | 4 +-
.../main/java/org/apache/openejb/OpenEJB.java | 12 +-
.../org/apache/openejb/OpenEjbContainer.java | 7 +-
.../openejb/assembler/classic/Assembler.java | 18 +-
.../openejb/assembler/classic/EjbResolver.java | 6 +-
.../classic/InterceptorBindingBuilder.java | 6 +-
.../classic/MethodConcurrencyBuilder.java | 4 +-
.../assembler/classic/MethodInfoUtil.java | 10 +-
.../classic/MethodTransactionBuilder.java | 2 +-
.../java/org/apache/openejb/cdi/CdiScanner.java | 12 +-
.../openejb/cdi/OptimizedLoaderService.java | 2 +-
.../classloader/ClassLoaderConfigurer.java | 7 +-
.../openejb/config/AnnotationDeployer.java | 18 +-
.../org/apache/openejb/config/AppValidator.java | 40 +-
.../org/apache/openejb/config/AutoConfig.java | 30 +-
.../apache/openejb/config/DeploymentLoader.java | 9 +-
.../apache/openejb/config/NewLoaderLogic.java | 22 +-
.../config/OpenEJBDeploymentManager.java | 3 +-
.../config/PersistenceUnitLinkResolver.java | 7 +-
.../apache/openejb/config/ReadDescriptors.java | 4 +-
.../apache/openejb/config/SunConversion.java | 4 +-
.../openejb/config/WebappAggregatedArchive.java | 6 +-
.../openejb/config/rules/CheckClassLoading.java | 2 +-
.../rules/CheckIncorrectPropertyNames.java | 5 +-
.../openejb/config/rules/CheckMethods.java | 40 +-
.../config/rules/CheckRestMethodArePublic.java | 8 +-
.../openejb/config/sys/WikiGenerator.java | 2 +-
.../openejb/core/CoreContainerSystem.java | 6 +-
.../openejb/core/NoSuchObjectException.java | 8 +-
.../apache/openejb/core/TempClassLoader.java | 2 +-
.../apache/openejb/core/cmp/cmp2/CmrSet.java | 3 +-
.../openejb/core/cmp/cmp2/SetValuedCmr.java | 4 +-
.../core/entity/EntityEjbHomeHandler.java | 4 +-
.../openejb/core/ivm/naming/NameNode.java | 6 +-
.../openejb/core/mdb/MdbInstanceManager.java | 7 +-
.../core/security/AbstractSecurityService.java | 7 +-
.../security/jaas/PropertiesLoginModule.java | 4 +-
.../jaas/UsernamePasswordCallbackHandler.java | 3 +-
.../openejb/core/stateful/SimpleCache.java | 6 +-
.../TransactionRolledbackException.java | 8 +-
.../core/webservices/HandlerResolverImpl.java | 5 +-
.../webservices/PortAddressRegistryImpl.java | 18 +-
.../math/stat/descriptive/moment/Variance.java | 4 +-
.../apache/openejb/monitoring/ManagedMBean.java | 4 +-
.../openejb/resource/AutoConnectionTracker.java | 12 +-
.../jdbc/pool/PoolDataSourceCreator.java | 8 +-
.../apache/openejb/threads/task/CUCallable.java | 7 +-
.../org/apache/openejb/threads/task/CUTask.java | 7 +-
.../java/org/apache/openejb/util/Base64.java | 16 +-
.../java/org/apache/openejb/util/ConfUtils.java | 2 +-
.../openejb/util/IntrospectionSupport.java | 23 +-
.../openejb/util/JavaSecurityManagers.java | 7 +-
.../org/apache/openejb/util/LinkResolver.java | 6 +-
.../java/org/apache/openejb/util/Logger.java | 7 +-
.../org/apache/openejb/util/URISupport.java | 14 +-
.../java/org/apache/openejb/util/UrlCache.java | 6 +-
.../openejb/web/LightweightWebAppBuilder.java | 12 +-
.../org/apache/openejb/DependencyVisitor.java | 10 +-
.../InterceptorBindingInfoComparatorTest.java | 4 +-
.../MethodTransactionInfoComparatorTest.java | 2 +-
.../openejb/core/ivm/naming/IvmContextTest.java | 6 +-
.../openejb/core/timer/GetAllTimersTest.java | 2 +-
.../MultiThreadedManagedDataSourceTest.java | 7 +-
.../threads/ManagedExecutorServiceTest.java | 7 +-
.../apache/openejb/util/UrlComparatorTest.java | 4 +-
.../apache/openejb/jee/AssemblyDescriptor.java | 6 +-
.../main/java/org/apache/openejb/jee/Beans.java | 6 +-
.../apache/openejb/jee/oejb3/EjbDeployment.java | 7 +-
.../openejb/jee/oejb3/PropertiesAdapter.java | 2 +-
.../openejb/loader/BasicURLClassPath.java | 6 +
.../apache/openejb/loader/ClassPathFactory.java | 1 +
.../org/apache/openejb/loader/Embedder.java | 2 +-
.../org/apache/openejb/loader/FileUtils.java | 5 +-
.../java/org/apache/openejb/loader/Files.java | 26 +-
.../main/java/org/apache/openejb/loader/IO.java | 13 +-
.../org/apache/openejb/loader/JarLocation.java | 1 -
.../openejb/loader/LoaderRuntimeException.java | 1 +
.../apache/openejb/loader/OpenEJBInstance.java | 2 +-
.../java/org/apache/openejb/loader/Options.java | 7 +-
.../apache/openejb/loader/SystemInstance.java | 30 +-
.../apache/openejb/loader/TomcatClassPath.java | 2 +-
.../apache/openejb/loader/WebAppClassPath.java | 1 +
.../java/org/apache/openejb/loader/Zips.java | 1 +
.../provisining/ProvisioningResolverAware.java | 1 +
.../openejb/observer/ObserverManager.java | 46 +--
.../org/apache/openejb/loader/FilesTest.java | 23 +-
.../apache/openejb/observer/EventSpeedTest.java | 6 +-
.../openejb/observer/ObserverFeaturesTest.java | 4 +-
.../openejb/observer/ObserverListTest.java | 2 +-
docs/admin/cluster/index.adoc | 11 -
docs/docs.adoc | 2 +-
.../README.md | 1 +
.../cdi-alternative-and-stereotypes/README.md | 1 +
examples/cdi-events/README.md | 1 +
examples/cdi-session-scope/README.md | 122 ++++++
.../executor/ManagedScheduledService.java | 53 ++-
.../superbiz/executor/ThreadFactoryService.java | 84 +++-
.../executor/ManagedScheduledServiceTest.java | 11 +-
.../executor/ThreadFactoryServiceTest.java | 59 ++-
.../dynamic-proxy-to-access-mbean/README.md | 2 +-
examples/jpa-hibernate/README.md | 15 +-
examples/moviefun-rest/README.md | 404 +++++++++++++++++++
examples/mp-custom-healthcheck/README.adoc | 146 +++++++
examples/mp-custom-healthcheck/pom.xml | 94 +++++
.../java/org/superbiz/WeatherApiStatus.java | 52 +++
.../main/java/org/superbiz/WeatherEndpoint.java | 45 +++
.../java/org/superbiz/WeatherException.java | 27 ++
.../main/java/org/superbiz/WeatherGateway.java | 63 +++
.../org/superbiz/WeatherServiceHealthCheck.java | 48 +++
.../src/main/resources/beans.xml | 7 +
.../org/superbiz/test/WeatherServiceTest.java | 124 ++++++
.../src/test/resources/arquillian.xml | 29 ++
examples/mp-faulttolerance-fallback/README.adoc | 121 ++++++
examples/mp-faulttolerance-fallback/pom.xml | 107 +++++
.../rest/WeatherDayStatusFallbackHandler.java | 34 ++
.../org/superbiz/rest/WeatherException.java | 20 +
.../java/org/superbiz/rest/WeatherService.java | 60 +++
.../org/superbiz/rest/WeatherServiceTest.java | 74 ++++
.../src/test/resources/arquillian.xml | 30 ++
.../src/test/resources/beans.xml | 7 +
examples/mp-faulttolerance-retry/README.adoc | 4 +-
examples/mp-metrics-counted/README.md | 0
examples/mp-metrics-metered/README.md | 130 ++++++
examples/mp-opentracing-traced/README.adoc | 64 +++
examples/multi-jpa-provider-testing/README.md | 281 +++++++++++++
examples/mvc-cxf/README.adoc | 24 ++
examples/mvc-cxf/README.md | 23 --
examples/mvc-resteasy/README.adoc | 23 ++
examples/mvc-resteasy/pom.xml | 143 +++++++
.../java/org/superbiz/mvc/MVCApplication.java | 22 +
.../java/org/superbiz/mvc/TomeeController.java | 38 ++
.../src/main/resources/META-INF/beans.xml | 23 ++
.../src/main/webapp/WEB-INF/views/hello.jsp | 28 ++
.../src/main/webapp/WEB-INF/web.xml | 28 ++
examples/mvc-resteasy/src/main/webapp/index.jsp | 28 ++
.../src/test/java/org/superbiz/mvc/MVCTest.java | 74 ++++
.../src/test/resources/arquillian.xml | 31 ++
examples/persistence-fragment/README.md | 6 +-
examples/pojo-webservice/README.md | 273 +++++++++++++
examples/polling-parent/README.md | 1 +
examples/pom.xml | 3 +
examples/simple-cdi-interceptor/README.md | 1 +
examples/websocket-tls-basic-auth/README.md | 1 +
.../META-INF/org.apache.openejb.extension | 1 -
owasp-dc-suppression.xml | 80 ++++
pom.xml | 61 ++-
.../apache/openejb/server/rest/RESTService.java | 7 +-
.../apache-tomee/src/main/resources/service.bat | 2 +-
tomee/tomee-plume-webapp/pom.xml | 3 +-
tomee/tomee-plus-webapp/pom.xml | 3 +-
154 files changed, 3454 insertions(+), 621 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/0d82e5ee/examples/mp-faulttolerance-retry/README.adoc
----------------------------------------------------------------------
diff --cc examples/mp-faulttolerance-retry/README.adoc
index 8f40268,0000000..f43d06a
mode 100644,000000..100644
--- a/examples/mp-faulttolerance-retry/README.adoc
+++ b/examples/mp-faulttolerance-retry/README.adoc
@@@ -1,256 -1,0 +1,256 @@@
+:index-group: MicroProfile
+:jbake-type: page
+:jbake-status: published
-
++~~~~~~
+# Microprofile Fault Tolerance - Retry policy
+
+This is an example of how to use
+Microprofile @Retry in TomEE.
+
+== Retry Feature
+
+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.
+
+The Retry policy allows to configure :
+
+* *maxRetries*: the maximum retries
+* *delay*: delays between each retry
+* *delayUnit*: the delay unit
+* *maxDuration*: maximum duration to perform the retry for.
+* *durationUnit*: duration unit
+* *jitter:* the random vary of retry delays
+* *jitterDelayUnit:* the jitter unit
+* *retryOn:* specify the failures to retry on
+* *abortOn:* specify the failures to abort on
+
+To use this feature you can annotate a class and/or a method with the
+@Retry annotation. Check the
+http://download.eclipse.org/microprofile/microprofile-fault-tolerance-1.1/microprofile-fault-tolerance-spec.html[specification]
+for more details.
+
+== Examples
+
+=== Run the application
+
+....
- mvn clean install tomee:run
++mvn clean install tomee:run
+....
+
+=== Example 1
+
+The method statusOfDay will fail three times, each time, throwing a
+`WeatherGatewayTimeoutException` and as the @Retry annotation is
+configured to `retryOn` in case of failure, the FailSafe library will
+take the `maxRetry` value and retry the same operation until it reaches
+the number maximum of attempts, which is 3 (default value).
+
+[source,java]
+----
+@RequestScoped
+public class WeatherGateway{
+ ...
+ @Retry(maxRetry=3, retryOn = WeatherGatewayTimeoutException.class)
+ public String statusOfDay(){
+ if(counterStatusOfDay.addAndGet(1) <= DEFAULT_MAX_RETRY){
+ LOGGER.warning(String.format(FORECAST_TIMEOUT_MESSAGE, DEFAULT_MAX_RETRY, counterStatusOfDay.get()));
+ throw new WeatherGatewayTimeoutException();
+ }
+ return "Today is a sunny day!";
+ }
+ ...
+ }
+----
+
+Day status call
+
+....
+GET http://localhost:8080/mp-faulttolerance-retry/weather/day/status
+....
+
+Server log
+
+....
+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)
+....
+
+Response
+
+....
+Today is a sunny day!
+....
+
+=== Example 2
+
+The method weekStatus will fail two times, each time, throwing a
+`WeatherGatewayTimeoutException` because `retryOn` is configured and
+instead of returning a response to the caller, the logic states that at
+the third attempt, a `WeatherGatewayBusyServiceException` will be
+thrown. As the `@Retry` annotation is configured to `abortOn` in case of
+`WeatherGatewayTimeoutException` happens, the remaining attempt won’t be
+executed and the caller must handle the exception.
+
+[source,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()));
+ throw new WeatherGatewayTimeoutException();
+ }
+ LOGGER.log(Level.SEVERE, String.format(FORECAST_BUSY_MESSAGE, counterStatusOfWeek.get()));
+ throw new WeatherGatewayBusyServiceException();
+}
+----
+
+Week status call
+
+....
+GET http://localhost:8080/mp-faulttolerance-retry/weather/week/status
+....
+
+Server log
+
+....
+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)
+....
+
+Response
+
+....
+WeatherGateway Service is Busy. Retry later
+....
+
+=== Example 3
+
+The `@Retry` 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 `jitter` to zero (0). Otherwise the delay of
+each new attempt will be randomized.
+
+Analysing the logged messages, is possible to see that all attempts took
+the pretty much the same time to execute.
+
+[source,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.";
+}
+----
+
+Weekend status call
+
+....
+GET http://localhost:8080/mp-faulttolerance-retry/weather/weekend/status
+....
+
+Server log
+
+....
+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
+....
+
+=== Example 4
+
+Basically with the same behaviour of the `Example 3`, this example sets
+the `delay` and `jitter` with 500 millis to randomly create a new delay
+for each new attempt after the first failure.
+https://github.com/jhalterman/failsafe/blob/master/src/main/java/net/jodah/failsafe/AbstractExecution.java[AbstractExecution#randomDelay(delay,jitter,random)]
+can give a hit of how the new delay is calculated.
+
+Analysing the logged messages, is possible to see how long each attempt
+had to wait until its execution.
+
+[source,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.";
+}
+----
+
+Month status call
+
+....
+GET http://localhost:8080/mp-faulttolerance-retry/weather/month/status
+....
+
+Server log
+
+....
+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
+....
+
+=== Example 5
+
+If a condition for an operation be re-executed is not set as in the
+previous examples using the parameter `retryOn`, the operation is
+executed again for _any_ exception that is thrown.
+
+[source,java]
+----
+@Retry(maxDuration = 1000)
+public String statusOfYear(){
+ if (counterStatusOfWeekend.addAndGet(1) <= 5) {
+ logTimeoutMessage(statusOfYearInstant);
+ statusOfYearInstant = Instant.now();
+ throw new RuntimeException();
+ }
+ return "WeatherGateway Service Error";
+}
+----
+
+Year status call
+
+....
+GET http://localhost:8080/mp-faulttolerance-retry/weather/year/statusk
+....
+
+Server log
+
+....
+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
+....
+
+=== Run the tests
+
+You can also try it out using the
+link:src/test/java/org/superbiz/rest/WeatherServiceTest.java[WeatherServiceTest.java]
+available in the project.
+
+....
+mvn clean test
+....
+
+....
+[INFO] Results:
+[INFO]
+[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
+....
http://git-wip-us.apache.org/repos/asf/tomee/blob/0d82e5ee/examples/mp-metrics-counted/README.md
----------------------------------------------------------------------
diff --cc examples/mp-metrics-counted/README.md
index 0000000,cb91ef0..e69de29
mode 000000,100644..100644
--- a/examples/mp-metrics-counted/README.md
+++ b/examples/mp-metrics-counted/README.md
[4/9] tomee git commit: TOMEE-2405 - created
examples/mp-metrics-histogram/README.adoc and added index-group MicroProfile
Posted by jl...@apache.org.
TOMEE-2405 - created examples/mp-metrics-histogram/README.adoc and added index-group MicroProfile
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/4d07c10f
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/4d07c10f
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/4d07c10f
Branch: refs/heads/master
Commit: 4d07c10fc431317acf6de25345a51d683524ce7a
Parents: 81f7062
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Wed Dec 19 20:57:24 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Wed Dec 19 20:57:24 2018 -0600
----------------------------------------------------------------------
examples/mp-metrics-histogram/README.adoc | 212 +++++++++++++++++++++++++
examples/mp-metrics-histogram/README.md | 182 ---------------------
2 files changed, 212 insertions(+), 182 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/4d07c10f/examples/mp-metrics-histogram/README.adoc
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-histogram/README.adoc b/examples/mp-metrics-histogram/README.adoc
new file mode 100644
index 0000000..f8b1ee3
--- /dev/null
+++ b/examples/mp-metrics-histogram/README.adoc
@@ -0,0 +1,212 @@
+:index-group: MicroProfile
+:jbake-type: page
+:jbake-status: published
+
+# Microprofile Metrics Histogram
+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
+histogram of the most recent New York City temperatures.
+
+== Request:
+
+....
+curl -X GET http://localhost:8080/mp-metrics-histogram/weather/histogram
+....
+
+== Response:
+
+....
+{
+ "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"
+}
+....
+
+== Histogram Feature
+
+Microprofile metrics has a feature create a histogram of data.
+
+To use this feature, inject a MetricRegistry, register the Histogram,
+and add data to the histogram as shown below.
+
+....
+@Inject
+private MetricRegistry registry;
+
+@Inject
+@Metric(name = "temperatures", description = "A histogram metrics example.",
+ displayName = "Histogram of Recent New York Temperatures")
+private Histogram 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.");
+ 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;
+}
+....
+
+There are some Histogram configurations defined in the @Metric
+annotation:
+
+*String name* Optional. The name of the metric. If not explicitly given
+the name of the annotated object is used.
+
+*String displayName* Optional. A human readable display name for
+metadata.
+
+*String description* Optional. A description of the metric.
+
+*String[] tags* Optional. An array of Strings in the = 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 or
+histograms.
+
+=== For the histogram status:
+
+....
+GET http://localhost:8080/mp-metrics-histogram/weather/histogram/status
+....
+
+=== Reponse:
+
+....
+ Here are the most recent New York City temperatures.
+....
+
+=== Expected Prometheus format:
+
+....
+ # 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
+ application:temperatures_min_degrees F 27.0
+ # TYPE application:temperatures_max_degrees F histogram
+ application:temperatures_max_degrees F 55.0
+ # TYPE application:temperatures_mean_degrees F histogram
+ application:temperatures_mean_degrees F 44.4
+ # 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
+ # TYPE application:temperatures_degrees F histogram
+ application:temperatures_degrees F{quantile="0.75"} 46.0
+ # TYPE application:temperatures_degrees F histogram
+ application:temperatures_degrees F{quantile="0.95"} 54.0
+ # TYPE application:temperatures_degrees F histogram
+ application:temperatures_degrees F{quantile="0.98"} 54.0
+ # TYPE application:temperatures_degrees F histogram
+ application:temperatures_degrees F{quantile="0.99"} 54.0
+ # TYPE application:temperatures_degrees F histogram
+ 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
+ # TYPE application:org_superbiz_histogram_weather_service_temperatures_min histogram
+ application:org_superbiz_histogram_weather_service_temperatures_min 0.0
+ # TYPE application:org_superbiz_histogram_weather_service_temperatures_max histogram
+ application:org_superbiz_histogram_weather_service_temperatures_max 0.0
+ # TYPE application:org_superbiz_histogram_weather_service_temperatures_mean histogram
+ application:org_superbiz_histogram_weather_service_temperatures_mean NaN
+ # 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
+ # TYPE application:org_superbiz_histogram_weather_service_temperatures histogram
+ 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
+ # TYPE application:org_superbiz_histogram_weather_service_temperatures histogram
+ 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
+....
+
+=== Request:
+
+....
+curl -X GET http://localhost:8080/mp-metrics-histogram/metrics/application
+....
+
+=== Response:
+
+....
+{
+ "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"
+ }
+}
+....
+
+== Metric Metadata:
+
+A metric will have a metadata to provide information about it such as
+displayName, description, tags, etc.
+
+=== Request:
+
+....
+curl -X OPTIONS http://localhost:8080/mp-metrics-histogram/metrics/application
+....
+
+=== Response:
+
+....
+{
+ "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"
+ }
+}
+....
+
+=== Test the application:
+
+....
+mvn test
+....
http://git-wip-us.apache.org/repos/asf/tomee/blob/4d07c10f/examples/mp-metrics-histogram/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-histogram/README.md b/examples/mp-metrics-histogram/README.md
deleted file mode 100644
index c948cd5..0000000
--- a/examples/mp-metrics-histogram/README.md
+++ /dev/null
@@ -1,182 +0,0 @@
-index-group=Histogram
-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 histogram of the most recent New York City temperatures.
-
-##### Request:
-
- curl -X GET http://localhost:8080/mp-metrics-histogram/weather/histogram
-
-##### Response:
-
- {
- "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"
- }
-
-#### Histogram Feature
-Microprofile metrics has a feature create a histogram of data.
-
-To use this feature, inject a MetricRegistry, register the Histogram, and add data to the histogram as shown below.
-
- @Inject
- private MetricRegistry registry;
-
- @Inject
- @Metric(name = "temperatures", description = "A histogram metrics example.",
- displayName = "Histogram of Recent New York Temperatures")
- private Histogram 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.");
- 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;
- }
-
-There are some Histogram configurations defined in the @Metric annotation:
-
-**String name**
-Optional. The name of the metric. If not explicitly given the name of the annotated object is used.
-
-**String displayName**
-Optional. A human readable display name for metadata.
-
-**String description**
-Optional. A description of the metric.
-
-**String[] tags**
-Optional. An 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 or histograms.
-
-##### For the histogram status:
-
- GET http://localhost:8080/mp-metrics-histogram/weather/histogram/status
-
-##### Reponse:
-
- Here are the most recent New York City temperatures.
-
-##### Expected Prometheus format:
-
- # 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
- application:temperatures_min_degrees F 27.0
- # TYPE application:temperatures_max_degrees F histogram
- application:temperatures_max_degrees F 55.0
- # TYPE application:temperatures_mean_degrees F histogram
- application:temperatures_mean_degrees F 44.4
- # 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
- # TYPE application:temperatures_degrees F histogram
- application:temperatures_degrees F{quantile="0.75"} 46.0
- # TYPE application:temperatures_degrees F histogram
- application:temperatures_degrees F{quantile="0.95"} 54.0
- # TYPE application:temperatures_degrees F histogram
- application:temperatures_degrees F{quantile="0.98"} 54.0
- # TYPE application:temperatures_degrees F histogram
- application:temperatures_degrees F{quantile="0.99"} 54.0
- # TYPE application:temperatures_degrees F histogram
- 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
- # TYPE application:org_superbiz_histogram_weather_service_temperatures_min histogram
- application:org_superbiz_histogram_weather_service_temperatures_min 0.0
- # TYPE application:org_superbiz_histogram_weather_service_temperatures_max histogram
- application:org_superbiz_histogram_weather_service_temperatures_max 0.0
- # TYPE application:org_superbiz_histogram_weather_service_temperatures_mean histogram
- application:org_superbiz_histogram_weather_service_temperatures_mean NaN
- # 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
- # TYPE application:org_superbiz_histogram_weather_service_temperatures histogram
- 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
- # TYPE application:org_superbiz_histogram_weather_service_temperatures histogram
- 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
-
-##### Request:
-
- curl -X GET http://localhost:8080/mp-metrics-histogram/metrics/application
-
-##### Response:
-
- {
- "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"
- }
- }
-
-#### Metric Metadata:
-A metric will have a metadata to provide information about it such as displayName, description, tags, etc.
-
-##### Request:
-
- curl -X OPTIONS http://localhost:8080/mp-metrics-histogram/metrics/application
-
-##### Response:
-
- {
- "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"
- }
- }
-
-##### Test the application:
-
- mvn test
[2/9] tomee git commit: TOMEE-2405 - added MicroProfile index group
to examples/mp-config-example/README.adoc
Posted by jl...@apache.org.
TOMEE-2405 - added MicroProfile index group to examples/mp-config-example/README.adoc
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/dcccfc3e
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/dcccfc3e
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/dcccfc3e
Branch: refs/heads/master
Commit: dcccfc3e9bf442cd891f91d4a4f7d90cd5e63ddc
Parents: 0fe2712
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Wed Dec 19 20:47:04 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Wed Dec 19 20:47:04 2018 -0600
----------------------------------------------------------------------
examples/mp-config-example/README.adoc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/dcccfc3e/examples/mp-config-example/README.adoc
----------------------------------------------------------------------
diff --git a/examples/mp-config-example/README.adoc b/examples/mp-config-example/README.adoc
index 2a5d569..07af20c 100644
--- a/examples/mp-config-example/README.adoc
+++ b/examples/mp-config-example/README.adoc
@@ -1,5 +1,5 @@
= Microprofile Config
-:index-group: Unrevised
+:index-group: MicroProfile
:jbake-type: page
:jbake-status: published
[9/9] tomee git commit: This closes #317. Thanks ivanjunckes.
Posted by jl...@apache.org.
This closes #317. Thanks ivanjunckes.
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/272fed31
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/272fed31
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/272fed31
Branch: refs/heads/master
Commit: 272fed31ffdd69b42161d0c251eeebce5f23f4d2
Parents: 3d5e07b 0d82e5e
Author: Jean-Louis Monteiro <je...@gmail.com>
Authored: Fri Dec 28 10:31:16 2018 +0100
Committer: Jean-Louis Monteiro <je...@gmail.com>
Committed: Fri Dec 28 10:31:16 2018 +0100
----------------------------------------------------------------------
examples/mp-config-example/README.adoc | 2 +-
examples/mp-faulttolerance-retry/README.adoc | 256 +++++++++++++++++
examples/mp-faulttolerance-retry/README.md | 216 ---------------
examples/mp-metrics-counted/README.adoc | 149 ++++++++++
examples/mp-metrics-counted/README.md | 128 ---------
examples/mp-metrics-histogram/README.adoc | 212 ++++++++++++++
examples/mp-metrics-histogram/README.md | 183 ------------
examples/mp-metrics-timed/README.adoc | 177 ++++++++++++
examples/mp-metrics-timed/README.md | 156 -----------
examples/mp-rest-client/README.adoc | 154 ++++++++++
examples/mp-rest-client/README.md | 144 ----------
examples/mp-rest-jwt/README.adoc | 324 ++++++++++++++++++++++
examples/mp-rest-jwt/README.md | 308 --------------------
13 files changed, 1273 insertions(+), 1136 deletions(-)
----------------------------------------------------------------------
[6/9] tomee git commit: TOMEE-2405 - created
examples/mp-rest-client/README.adoc and added index-group MicroProfile
Posted by jl...@apache.org.
TOMEE-2405 - created examples/mp-rest-client/README.adoc and added index-group MicroProfile
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/159417c2
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/159417c2
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/159417c2
Branch: refs/heads/master
Commit: 159417c214893af4cbdf5deee0aa6f651883059b
Parents: 65ce73b
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Wed Dec 19 21:14:29 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Wed Dec 19 21:15:17 2018 -0600
----------------------------------------------------------------------
examples/mp-rest-client/README.adoc | 154 +++++++++++++++++++++++++++++++
examples/mp-rest-client/README.md | 138 ---------------------------
2 files changed, 154 insertions(+), 138 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/159417c2/examples/mp-rest-client/README.adoc
----------------------------------------------------------------------
diff --git a/examples/mp-rest-client/README.adoc b/examples/mp-rest-client/README.adoc
new file mode 100644
index 0000000..4be04b1
--- /dev/null
+++ b/examples/mp-rest-client/README.adoc
@@ -0,0 +1,154 @@
+:index-group: MicroProfile
+:jbake-type: page
+:jbake-status: published
+
+== Microprofile Rest client
+
+This is a basic example on how to configure and use MicroProfile Rest
+Client in TomEE.
+
+=== Run the tests for different scenarios related with JWT validation
+
+....
+mvn clean test
+....
+
+=== Requirementes and configuration
+
+To use MicroProfile Rest Client you need 3 changes in your project:
+
+[arabic]
+. Add the to the `pom.xml` the dependency:
++
+....
+ <dependency>
+ <groupId>org.eclipse.microprofile.rest.client</groupId>
+ <artifactId>microprofile-rest-client-api</artifactId>
+ <version>${microprofile.rest-client.version}</version>
+ <scope>provided</scope>
+ </dependency>
+....
+. Provide configuration files: `microprofile-config.properties`
++
+....
+ org.superbiz.rest.BookResourceClient/mp-rest/url=http://localhost:4444
+....
+. Provide an interface that you can build from the JAX-RS resource you
+want to consume: `BookResourceClient.java`
++
+....
+ package org.superbiz.rest;
+
+ import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
+ import javax.enterprise.context.Dependent;
+ import javax.ws.rs.*;
+ import javax.ws.rs.core.MediaType;
+ import java.util.List;
+
+ @Dependent
+ @RegisterRestClient
+ @Path("/test/api/library")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public interface BookResourceClient {
+
+ @GET
+ String status();
+
+ @POST
+ @Path("/books")
+ void addBook(Book newBook);
+
+ @DELETE
+ @Path("/books/{id}")
+ void deleteBook(@PathParam("id") int id);
+
+ @PUT
+ @Path("/books")
+ void updateBook(Book updatedBook);
+
+ @GET
+ @Path("/books/{id}")
+ Book getBook(@PathParam("id") int id);
+
+ @GET
+ @Path("/books")
+ List<Book> getListOfBooks();
+
+ }
+....
+
+=== Use of MicroProfile Rest Client in TomEE
+
+The class `BookResourceTest.java` shows how easy is to use the type-safe
+approach provided by MicroProfile Rest Client to consume an existing
+JAX-RS resource.
+
+....
+package org.superbiz.rest;
+
+import org.eclipse.microprofile.rest.client.inject.RestClient;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class BookResourceTest {
+
+ @Deployment()
+ public static WebArchive createDeployment() {
+ final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClass(BookResource.class)
+ .addClass(Book.class)
+ .addClass(BookBean.class)
+ .addClass(BookResourceClient.class)
+ .addClass(ApplicationConfig.class)
+ .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml")
+ .addAsResource("META-INF/microprofile-config.properties");
+ return webArchive;
+ }
+
+
+ @Inject
+ @RestClient
+ private BookResourceClient bookResourceClient;
+
+ @Test()
+ public void testServerStatus(){
+ bookResourceClient.addBook(new Book(1,"TomEE Book"));
+ }
+
+ @Test
+ public void testBookResource(){
+ bookResourceClient.addBook(new Book(1, "TomEE and MicroProfile Adventures"));
+ bookResourceClient.addBook(new Book(2, "Top 10 Tomee Configuraiton Tips"));
+
+
+ assertTrue(bookResourceClient.getListOfBooks().size() == 2);
+ assertTrue(bookResourceClient.getBook(1).getName().equalsIgnoreCase("TomEE and MicroProfile Adventures"));
+
+ bookResourceClient.deleteBook(1);
+ assertTrue(bookResourceClient.getListOfBooks().size() == 1);
+ assertTrue(bookResourceClient.getBook(2).getName().equalsIgnoreCase("Top 10 Tomee Configuraiton Tips"));
+
+ bookResourceClient.updateBook(new Book(2, "Top 3 Tomee Configuraiton Tips"));
+ assertTrue(bookResourceClient.getListOfBooks().size() == 1);
+ assertTrue(bookResourceClient.getBook(2).getName().equalsIgnoreCase("Top 3 Tomee Configuraiton Tips"));
+ }
+
+}
+....
+
+=== About the Test architecture
+
+The test cases from this project are built using Arquillian and TomEE
+Remote. The arquillian configuration can be found in
+`src/test/resources/arquillian.xml`
http://git-wip-us.apache.org/repos/asf/tomee/blob/159417c2/examples/mp-rest-client/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-rest-client/README.md b/examples/mp-rest-client/README.md
deleted file mode 100755
index 0f0fcc5..0000000
--- a/examples/mp-rest-client/README.md
+++ /dev/null
@@ -1,138 +0,0 @@
-# Microprofile Rest client
-This is a basic example on how to configure and use MicroProfile Rest Client in TomEE.
-
-## Run the tests for different scenarios related with JWT validation
-
- mvn clean test
-
-## Requirementes and configuration
-
-To use MicroProfile Rest Client you need 3 changes in your project:
-
-1) Add the to the `pom.xml` the dependency:
-
- <dependency>
- <groupId>org.eclipse.microprofile.rest.client</groupId>
- <artifactId>microprofile-rest-client-api</artifactId>
- <version>${microprofile.rest-client.version}</version>
- <scope>provided</scope>
- </dependency>
-
-2) Provide configuration files: `microprofile-config.properties`
-
- org.superbiz.rest.BookResourceClient/mp-rest/url=http://localhost:4444
-
-3) Provide an interface that you can build from the JAX-RS resource you want to consume: `BookResourceClient.java`
-
- package org.superbiz.rest;
-
- import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
- import javax.enterprise.context.Dependent;
- import javax.ws.rs.*;
- import javax.ws.rs.core.MediaType;
- import java.util.List;
-
- @Dependent
- @RegisterRestClient
- @Path("/test/api/library")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public interface BookResourceClient {
-
- @GET
- String status();
-
- @POST
- @Path("/books")
- void addBook(Book newBook);
-
- @DELETE
- @Path("/books/{id}")
- void deleteBook(@PathParam("id") int id);
-
- @PUT
- @Path("/books")
- void updateBook(Book updatedBook);
-
- @GET
- @Path("/books/{id}")
- Book getBook(@PathParam("id") int id);
-
- @GET
- @Path("/books")
- List<Book> getListOfBooks();
-
- }
-
-
-## Use of MicroProfile Rest Client in TomEE
-
-The class `BookResourceTest.java` shows how easy is to use the type-safe approach provided by MicroProfile Rest Client to consume an existing JAX-RS resource.
-
- package org.superbiz.rest;
-
- import org.eclipse.microprofile.rest.client.inject.RestClient;
- import org.jboss.arquillian.container.test.api.Deployment;
- import org.jboss.arquillian.junit.Arquillian;
- import org.jboss.shrinkwrap.api.ShrinkWrap;
- import org.jboss.shrinkwrap.api.asset.StringAsset;
- import org.jboss.shrinkwrap.api.spec.WebArchive;
- import org.junit.Test;
- import org.junit.runner.RunWith;
-
- import javax.inject.Inject;
-
- import static org.junit.Assert.assertTrue;
-
- @RunWith(Arquillian.class)
- public class BookResourceTest {
-
- @Deployment()
- public static WebArchive createDeployment() {
- final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
- .addClass(BookResource.class)
- .addClass(Book.class)
- .addClass(BookBean.class)
- .addClass(BookResourceClient.class)
- .addClass(ApplicationConfig.class)
- .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml")
- .addAsResource("META-INF/microprofile-config.properties");
- return webArchive;
- }
-
-
- @Inject
- @RestClient
- private BookResourceClient bookResourceClient;
-
- @Test()
- public void testServerStatus(){
- bookResourceClient.addBook(new Book(1,"TomEE Book"));
- }
-
- @Test
- public void testBookResource(){
- bookResourceClient.addBook(new Book(1, "TomEE and MicroProfile Adventures"));
- bookResourceClient.addBook(new Book(2, "Top 10 Tomee Configuraiton Tips"));
-
-
- assertTrue(bookResourceClient.getListOfBooks().size() == 2);
- assertTrue(bookResourceClient.getBook(1).getName().equalsIgnoreCase("TomEE and MicroProfile Adventures"));
-
- bookResourceClient.deleteBook(1);
- assertTrue(bookResourceClient.getListOfBooks().size() == 1);
- assertTrue(bookResourceClient.getBook(2).getName().equalsIgnoreCase("Top 10 Tomee Configuraiton Tips"));
-
- bookResourceClient.updateBook(new Book(2, "Top 3 Tomee Configuraiton Tips"));
- assertTrue(bookResourceClient.getListOfBooks().size() == 1);
- assertTrue(bookResourceClient.getBook(2).getName().equalsIgnoreCase("Top 3 Tomee Configuraiton Tips"));
- }
-
- }
-
-## About the Test architecture
-
-The test cases from this project are built using Arquillian and TomEE Remote.
-The arquillian configuration can be found in
-`src/test/resources/arquillian.xml`
-
[3/9] tomee git commit: TOMEE-2405 - created
examples/mp-metrics-counted /README.adoc and added index-group MicroProfile
Posted by jl...@apache.org.
TOMEE-2405 - created examples/mp-metrics-counted /README.adoc and added index-group MicroProfile
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/81f70620
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/81f70620
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/81f70620
Branch: refs/heads/master
Commit: 81f70620628f576ada9718afa31fe382a90e8330
Parents: dcccfc3
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Wed Dec 19 20:51:24 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Wed Dec 19 20:53:37 2018 -0600
----------------------------------------------------------------------
examples/mp-metrics-counted/README.adoc | 149 +++++++++++++++++++++++++++
examples/mp-metrics-counted/README.md | 127 -----------------------
2 files changed, 149 insertions(+), 127 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/81f70620/examples/mp-metrics-counted/README.adoc
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/README.adoc b/examples/mp-metrics-counted/README.adoc
new file mode 100644
index 0000000..f5d8c95
--- /dev/null
+++ b/examples/mp-metrics-counted/README.adoc
@@ -0,0 +1,149 @@
+:index-group: MicroProfile
+:jbake-type: page
+:jbake-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 endpoint that will give you weather
+status for the day and week.
+
+== For the day status call:
+
+....
+GET http://localhost:8080/rest-mp-metrics/weather/day/status
+....
+
+== Response:
+
+....
+Hi, today is a sunny day!
+....
+
+== Counted Feature
+
+MicroProfile metrics has a feature that can be used to count requests to
+a service.
+
+To use this feature you need to annotate the JAX-RS resource method with
+@Counted.
+
+....
+@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)
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String dayStatus() {
+ return "Hi, today is a sunny day!";
+ }
+...
+}
+....
+
+There are some configurations, as part of @Counted, 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 = 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.
+
+== Metric data
+
+Check the counter metric doing a _GET_ request:
+
+=== Prometheus format:
+
+....
+GET http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status
+....
+
+=== Response:
+
+....
+# TYPE application:weather_day_status counter
+application:weather_day_status 1.0
+....
+
+=== JSON Format:
+
+For json format add the header _Accept=application/json_ to the request.
+
+....
+{
+ "weather_day_status": {
+ "delegate": {},
+ "unit": "none",
+ "count": 1
+ }
+}
+....
+
+== Metric metadata
+
+A metric will have a metadata so you can know more information about it,
+like displayName, description, tags e etc.
+
+Check the metric metadata doing a _OPTIONS_ request:
+
+=== Request
+
+....
+OPTIONS http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status
+....
+
+=== Response:
+
+....
+{
+ "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": ""
+ }
+}
+....
+
+You can also try it out using the WeatherServiceTest.java available in
+the project.
http://git-wip-us.apache.org/repos/asf/tomee/blob/81f70620/examples/mp-metrics-counted/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-counted/README.md b/examples/mp-metrics-counted/README.md
deleted file mode 100644
index eb6c2fd..0000000
--- a/examples/mp-metrics-counted/README.md
+++ /dev/null
@@ -1,127 +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 endpoint that will give you weather status for the day and week.
-
-##### For the day status call:
-
- GET http://localhost:8080/rest-mp-metrics/weather/day/status
-
-##### Response:
-
- Hi, today is a sunny day!
-
-
-#### Counted Feature
-MicroProfile metrics has a feature that can be used to count requests to a service.
-
-To use this feature you need to annotate the JAX-RS resource method with @Counted.
-
- @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)
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String dayStatus() {
- return "Hi, today is a sunny day!";
- }
- ...
- }
-
-There are some configurations, as part of @Counted, 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.
-
-#### Metric data
-
-Check the counter metric doing a _GET_ request:
-
-##### Prometheus format:
-
- GET http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status
-
-##### Response:
-
- # TYPE application:weather_day_status counter
- application:weather_day_status 1.0
-
-
-##### JSON Format:
-
-For json format add the header _Accept=application/json_ to the request.
-
- {
- "weather_day_status": {
- "delegate": {},
- "unit": "none",
- "count": 1
- }
- }
-
-#### Metric metadata
-A metric will have a metadata so you can know more information about it, like displayName, description, tags e etc.
-
-Check the metric metadata doing a _OPTIONS_ request:
-
-##### Request
-
- OPTIONS http://localhost:8080/mp-metrics-counted/metrics/application/weather_day_status
-
-##### Response:
-
- {
- "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": ""
- }
- }
-
-You can also try it out using the WeatherServiceTest.java available in the project.
-
[5/9] tomee git commit: TOMEE-2405 - created
examples/mp-metrics-timed/README.adoc and added index-group MicroProfile
Posted by jl...@apache.org.
TOMEE-2405 - created examples/mp-metrics-timed/README.adoc and added index-group MicroProfile
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/65ce73b9
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/65ce73b9
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/65ce73b9
Branch: refs/heads/master
Commit: 65ce73b9ce1875fa6df880b7d45d56acc50f5a6e
Parents: 4d07c10
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Wed Dec 19 21:06:41 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Wed Dec 19 21:06:41 2018 -0600
----------------------------------------------------------------------
examples/mp-metrics-timed/README.adoc | 177 +++++++++++++++++++++++++++++
examples/mp-metrics-timed/README.md | 155 -------------------------
2 files changed, 177 insertions(+), 155 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/65ce73b9/examples/mp-metrics-timed/README.adoc
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/README.adoc b/examples/mp-metrics-timed/README.adoc
new file mode 100644
index 0000000..7aec937
--- /dev/null
+++ b/examples/mp-metrics-timed/README.adoc
@@ -0,0 +1,177 @@
+:index-group: MicroProfile
+:jbake-type: page
+:jbake-status: published
+
+# Microprofile Metrics Timed
+
+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 endpoint that will give you the
+weather status for the day.
+
+== For the day status call:
+
+....
+GET http://localhost:8080/mp-metrics-timed/weather/day/status
+....
+
+== Response:
+
+....
+Hi, today is a sunny day!
+....
+
+== Timed Feature
+
+MicroProfile Metrics has a feature that tracks the time of an event.
+
+To use this feature you need to annotate the JAX-RS resource method with
+@Timed.
+
+....
+@Path("/weather")
+@ApplicationScoped
+public class WeatherService {
+
+ @Path("/day/status")
+ @Timed(name = "weather_day_status", absolute = true,
+ displayName = "Weather Day Status",
+ description = "This metric shows the weather status of the day.")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String dayStatus() {
+ return "Hi, today is a sunny day!";
+ }
+...
+}
+....
+
+There are some configurations, as part of @Timed, 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 = format to supply
+special tags to a metric.
+
+*String unit* Unit of the metric. Default for @Timed is nanoseconds.
+
+== Metric data
+
+Check the timed metric doing a _GET_ request:
+
+=== Prometheus format:
+
+....
+GET http://localhost:8080/mp-metrics-timed/metrics/application/weather_day_status
+....
+
+=== Response:
+
+....
+# TYPE application:weather_day_status_seconds summary timer
+# TYPE application:weather_day_status_seconds_count timer
+application:weather_day_status_seconds_count 1.0
+# TYPE application:weather_day_status_rate_per_second timer
+application:weather_day_status_rate_per_second 0.0
+# TYPE application:weather_day_status_one_min_rate_per_second timer
+application:weather_day_status_one_min_rate_per_second 0.0
+# TYPE application:weather_day_status_five_min_rate_per_second timer
+application:weather_day_status_five_min_rate_per_second 0.0
+# TYPE application:weather_day_status_fifteen_min_rate_per_second timer
+application:weather_day_status_fifteen_min_rate_per_second 0.0
+# TYPE application:weather_day_status_min_seconds timer
+application:weather_day_status_min_seconds 48352.0
+# TYPE application:weather_day_status_max_seconds timer
+application:weather_day_status_max_seconds 48352.0
+# TYPE application:weather_day_status_mean_seconds timer
+application:weather_day_status_mean_seconds 48352.0
+# TYPE application:weather_day_status_stddev_seconds timer
+application:weather_day_status_stddev_seconds 0.0
+# TYPE application:weather_day_status_seconds timer
+application:weather_day_status_seconds{quantile="0.5"} 48352.0
+# TYPE application:weather_day_status_seconds timer
+application:weather_day_status_seconds{quantile="0.75"} 48352.0
+# TYPE application:weather_day_status_seconds timer
+application:weather_day_status_seconds{quantile="0.95"} 48352.0
+# TYPE application:weather_day_status_seconds timer
+application:weather_day_status_seconds{quantile="0.98"} 48352.0
+# TYPE application:weather_day_status_seconds timer
+application:weather_day_status_seconds{quantile="0.99"} 48352.0
+# TYPE application:weather_day_status_seconds timer
+application:weather_day_status_seconds{quantile="0.999"} 48352.0
+....
+
+=== JSON Format:
+
+For json format add the header _Accept=application/json_ to the request.
+
+....
+{
+ "weather_day_status": {
+ "count": 1,
+ "fifteenMinRate": 0,
+ "fiveMinRate": 0,
+ "max": 48352,
+ "mean": 48352,
+ "meanRate": 0,
+ "min": 48352,
+ "oneMinRate": 0,
+ "p50": 48352,
+ "p75": 48352,
+ "p95": 48352,
+ "p98": 48352,
+ "p99": 48352,
+ "p999": 48352,
+ "stddev": 0
+ }
+}
+....
+
+== Metric metadata
+
+A metric will have metadata so you can know more about it, like
+displayName, description, tags e etc.
+
+Check the metric metadata doing a _OPTIONS_ request:
+
+=== Request
+
+....
+OPTIONS http://localhost:8080/mp-metrics-timed/metrics/application/weather_day_status
+....
+
+=== Response:
+
+....
+{
+ "weather_day_status": {
+ "description": "This metric shows the weather status of the day.",
+ "displayName": "Weather Day Status",
+ "name": "weather_day_status",
+ "reusable": false,
+ "tags": "",
+ "type": "timer",
+ "typeRaw": "TIMER",
+ "unit": "nanoseconds"
+ }
+}
+....
+
+You can also try it out using the WeatherServiceTest.java available in
+the project.
http://git-wip-us.apache.org/repos/asf/tomee/blob/65ce73b9/examples/mp-metrics-timed/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-metrics-timed/README.md b/examples/mp-metrics-timed/README.md
deleted file mode 100644
index cd15659..0000000
--- a/examples/mp-metrics-timed/README.md
+++ /dev/null
@@ -1,155 +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 endpoint that will give you the weather status for the day.
-
-##### For the day status call:
-
- GET http://localhost:8080/mp-metrics-timed/weather/day/status
-
-##### Response:
-
- Hi, today is a sunny day!
-
-
-#### Timed Feature
-MicroProfile Metrics has a feature that tracks the time of an event.
-
-To use this feature you need to annotate the JAX-RS resource method with @Timed.
-
- @Path("/weather")
- @ApplicationScoped
- public class WeatherService {
-
- @Path("/day/status")
- @Timed(name = "weather_day_status", absolute = true,
- displayName = "Weather Day Status",
- description = "This metric shows the weather status of the day.")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String dayStatus() {
- return "Hi, today is a sunny day!";
- }
- ...
- }
-
-There are some configurations, as part of @Timed, 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.
-
-**String unit**
-Unit of the metric. Default for @Timed is nanoseconds.
-
-#### Metric data
-
-Check the timed metric doing a _GET_ request:
-
-##### Prometheus format:
-
- GET http://localhost:8080/mp-metrics-timed/metrics/application/weather_day_status
-
-##### Response:
-
- # TYPE application:weather_day_status_seconds summary timer
- # TYPE application:weather_day_status_seconds_count timer
- application:weather_day_status_seconds_count 1.0
- # TYPE application:weather_day_status_rate_per_second timer
- application:weather_day_status_rate_per_second 0.0
- # TYPE application:weather_day_status_one_min_rate_per_second timer
- application:weather_day_status_one_min_rate_per_second 0.0
- # TYPE application:weather_day_status_five_min_rate_per_second timer
- application:weather_day_status_five_min_rate_per_second 0.0
- # TYPE application:weather_day_status_fifteen_min_rate_per_second timer
- application:weather_day_status_fifteen_min_rate_per_second 0.0
- # TYPE application:weather_day_status_min_seconds timer
- application:weather_day_status_min_seconds 48352.0
- # TYPE application:weather_day_status_max_seconds timer
- application:weather_day_status_max_seconds 48352.0
- # TYPE application:weather_day_status_mean_seconds timer
- application:weather_day_status_mean_seconds 48352.0
- # TYPE application:weather_day_status_stddev_seconds timer
- application:weather_day_status_stddev_seconds 0.0
- # TYPE application:weather_day_status_seconds timer
- application:weather_day_status_seconds{quantile="0.5"} 48352.0
- # TYPE application:weather_day_status_seconds timer
- application:weather_day_status_seconds{quantile="0.75"} 48352.0
- # TYPE application:weather_day_status_seconds timer
- application:weather_day_status_seconds{quantile="0.95"} 48352.0
- # TYPE application:weather_day_status_seconds timer
- application:weather_day_status_seconds{quantile="0.98"} 48352.0
- # TYPE application:weather_day_status_seconds timer
- application:weather_day_status_seconds{quantile="0.99"} 48352.0
- # TYPE application:weather_day_status_seconds timer
- application:weather_day_status_seconds{quantile="0.999"} 48352.0
-
-##### JSON Format:
-
-For json format add the header _Accept=application/json_ to the request.
-
- {
- "weather_day_status": {
- "count": 1,
- "fifteenMinRate": 0,
- "fiveMinRate": 0,
- "max": 48352,
- "mean": 48352,
- "meanRate": 0,
- "min": 48352,
- "oneMinRate": 0,
- "p50": 48352,
- "p75": 48352,
- "p95": 48352,
- "p98": 48352,
- "p99": 48352,
- "p999": 48352,
- "stddev": 0
- }
- }
-
-#### Metric metadata
-A metric will have metadata so you can know more about it, like displayName, description, tags e etc.
-
-Check the metric metadata doing a _OPTIONS_ request:
-
-##### Request
-
- OPTIONS http://localhost:8080/mp-metrics-timed/metrics/application/weather_day_status
-
-##### Response:
-
- {
- "weather_day_status": {
- "description": "This metric shows the weather status of the day.",
- "displayName": "Weather Day Status",
- "name": "weather_day_status",
- "reusable": false,
- "tags": "",
- "type": "timer",
- "typeRaw": "TIMER",
- "unit": "nanoseconds"
- }
- }
-
-You can also try it out using the WeatherServiceTest.java available in the project.
-
[7/9] tomee git commit: TOMEE-2405 - created
examples/mp-rest-jwt/README.adoc and added index-group MicroProfile
Posted by jl...@apache.org.
TOMEE-2405 - created examples/mp-rest-jwt/README.adoc and added index-group MicroProfile
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/fcdaefeb
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/fcdaefeb
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/fcdaefeb
Branch: refs/heads/master
Commit: fcdaefeb796d2890e284c0ae1eb08f62f3247ddb
Parents: 159417c
Author: CesarHernandezGt <cf...@gmail.com>
Authored: Wed Dec 19 21:17:16 2018 -0600
Committer: CesarHernandezGt <cf...@gmail.com>
Committed: Wed Dec 19 21:18:00 2018 -0600
----------------------------------------------------------------------
examples/mp-rest-jwt/README.adoc | 324 ++++++++++++++++++++++++++++++++++
examples/mp-rest-jwt/README.md | 307 --------------------------------
2 files changed, 324 insertions(+), 307 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/fcdaefeb/examples/mp-rest-jwt/README.adoc
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/README.adoc b/examples/mp-rest-jwt/README.adoc
new file mode 100644
index 0000000..71149e3
--- /dev/null
+++ b/examples/mp-rest-jwt/README.adoc
@@ -0,0 +1,324 @@
+:index-group: MicroProfile
+:jbake-type: page
+:jbake-status: published
+
+# MP REST JWT
+
+This is a basic example on how to configure and use MicroProfile JWT in
+TomEE.
+
+== Run the tests for different scenarios related with JWT validation
+
+....
+mvn clean test
+....
+
+== Configuration in TomEE
+
+The class `MoviesMPJWTConfigurationProvider.java` provides to TomEE the
+figuration need it for JWT validation.
+
+....
+package org.superbiz.moviefun.rest;
+
+import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfo;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.Produces;
+import java.security.KeyFactory;
+import java.security.NoSuchAlgorithmException;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.X509EncodedKeySpec;
+import java.util.Base64;
+import java.util.Optional;
+
+@Dependent
+public class MoviesMPJWTConfigurationProvider {
+
+ @Produces
+ Optional<JWTAuthContextInfo> getOptionalContextInfo() throws NoSuchAlgorithmException, InvalidKeySpecException {
+ JWTAuthContextInfo contextInfo = new JWTAuthContextInfo();
+
+ // todo use MP Config to load the configuration
+ contextInfo.setIssuedBy("https://server.example.com");
+
+ final String pemEncoded = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlivFI8qB4D0y2jy0CfEq" +
+ "Fyy46R0o7S8TKpsx5xbHKoU1VWg6QkQm+ntyIv1p4kE1sPEQO73+HY8+Bzs75XwR" +
+ "TYL1BmR1w8J5hmjVWjc6R2BTBGAYRPFRhor3kpM6ni2SPmNNhurEAHw7TaqszP5e" +
+ "UF/F9+KEBWkwVta+PZ37bwqSE4sCb1soZFrVz/UT/LF4tYpuVYt3YbqToZ3pZOZ9" +
+ "AX2o1GCG3xwOjkc4x0W7ezbQZdC9iftPxVHR8irOijJRRjcPDtA6vPKpzLl6CyYn" +
+ "sIYPd99ltwxTHjr3npfv/3Lw50bAkbT4HeLFxTx4flEoZLKO/g0bAoV2uqBhkA9x" +
+ "nQIDAQAB";
+ byte[] encodedBytes = Base64.getDecoder().decode(pemEncoded);
+
+ final X509EncodedKeySpec spec = new X509EncodedKeySpec(encodedBytes);
+ final KeyFactory kf = KeyFactory.getInstance("RSA");
+ final RSAPublicKey pk = (RSAPublicKey) kf.generatePublic(spec);
+
+ contextInfo.setSignerKey(pk);
+
+ return Optional.of(contextInfo);
+ }
+
+ @Produces
+ JWTAuthContextInfo getContextInfo() throws InvalidKeySpecException, NoSuchAlgorithmException {
+ return getOptionalContextInfo().get();
+ }
+}
+....
+
+== Use MicroProfile JWT in TomEE
+
+The JAX-RS resource `MoviesRest.java` contains several endpoint that are
+secured using the standard annotation `@RolesAllowed`. MicroProfile JWT
+takes care of performing the validation for incoming requests with
+`Authorization` header providing a signed `Access Token`
+
+....
+ package org.superbiz.moviefun.rest;
+
+ import org.superbiz.moviefun.Movie;
+ import org.superbiz.moviefun.MoviesBean;
+
+ import javax.annotation.security.RolesAllowed;
+ import javax.inject.Inject;
+ import javax.ws.rs.*;
+ import javax.ws.rs.core.MediaType;
+ import java.util.List;
+
+ @Path("cinema")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public class MoviesRest {
+
+ @Inject
+ private MoviesBean moviesBean;
+
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String status() {
+ return "ok";
+ }
+
+ @GET
+ @Path("/movies")
+ @RolesAllowed({"crud", "read-only"})
+ public List<Movie> getListOfMovies() {
+ return moviesBean.getMovies();
+ }
+
+ @GET
+ @Path("/movies/{id}")
+ @RolesAllowed({"crud", "read-only"})
+ public Movie getMovie(@PathParam("id") int id) {
+ return moviesBean.getMovie(id);
+ }
+
+ @POST
+ @Path("/movies")
+ @RolesAllowed("crud")
+ public void addMovie(Movie newMovie) {
+ moviesBean.addMovie(newMovie);
+ }
+
+ @DELETE
+ @Path("/movies/{id}")
+ @RolesAllowed("crud")
+ public void deleteMovie(@PathParam("id") int id) {
+ moviesBean.deleteMovie(id);
+ }
+
+ @PUT
+ @Path("/movies")
+ @RolesAllowed("crud")
+ public void updateMovie(Movie updatedMovie) {
+ moviesBean.updateMovie(updatedMovie);
+ }
+
+ }
+
+ @Inject
+ @ConfigProperty(name = "java.runtime.version")
+ private String javaVersion;
+
+....
+
+== About the Test architecture
+
+The test cases from this project are builded using Arquillian. The
+arquillian configuration can be found in
+`src/test/resources/arquillian.xml`
+
+The class `TokenUtils.java` is used during the test to act as an
+Authorization server who generates `Access Tokens` based on the
+configuration files `privateKey.pem`,`publicKey.pem`,`Token1.json`, and
+`Token2.json`. +
+`nimbus-jose-jwt` is the library used for JWT generation during the
+tests.
+
+`Token1.json`
+
+....
+{
+ "iss": "https://server.example.com",
+ "jti": "a-123",
+ "sub": "24400320",
+ "upn": "jdoe@example.com",
+ "preferred_username": "jdoe",
+ "aud": "s6BhdRkqt3",
+ "exp": 1311281970,
+ "iat": 1311280970,
+ "auth_time": 1311280969,
+ "groups": [
+ "group1",
+ "group2",
+ "crud",
+ "read-only"
+ ]
+}
+....
+
+`Token2.json`
+
+....
+{
+ "iss": "https://server.example.com",
+ "jti": "a-123",
+ "sub": "24400320",
+ "upn": "alice@example.com",
+ "preferred_username": "alice",
+ "aud": "s6BhdRkqt3",
+ "exp": 1311281970,
+ "iat": 1311280970,
+ "auth_time": 1311280969,
+ "groups": [
+ "read-only"
+ ]
+}
+....
+
+== Test Scenarios
+
+`MovieTest.java` contains 4 OAuth2 scenarios for different JWT
+combinations.
+
+....
+package org.superbiz.moviefun;
+
+import org.apache.cxf.feature.LoggingFeature;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.johnzon.jaxrs.JohnzonProvider;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.superbiz.moviefun.rest.ApplicationConfig;
+import org.superbiz.moviefun.rest.MoviesMPJWTConfigurationProvider;
+import org.superbiz.moviefun.rest.MoviesRest;
+
+import javax.ws.rs.core.Response;
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.logging.Logger;
+
+import static java.util.Collections.singletonList;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class MoviesTest {
+
+ @Deployment(testable = false)
+ public static WebArchive createDeployment() {
+ final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
+ .addClasses(Movie.class, MoviesBean.class, MoviesTest.class)
+ .addClasses(MoviesRest.class, ApplicationConfig.class)
+ .addClass(MoviesMPJWTConfigurationProvider.class)
+ .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
+
+ System.out.println(webArchive.toString(true));
+
+ return webArchive;
+ }
+
+ @ArquillianResource
+ private URL base;
+
+
+ private final static Logger LOGGER = Logger.getLogger(MoviesTest.class.getName());
+
+ @Test
+ public void movieRestTest() throws Exception {
+
+ final WebClient webClient = WebClient
+ .create(base.toExternalForm(), singletonList(new JohnzonProvider<>()),
+ singletonList(new LoggingFeature()), null);
+
+
+ //Testing rest endpoint deployment (GET without security header)
+ String responsePayload = webClient.reset().path("/rest/cinema/").get(String.class);
+ LOGGER.info("responsePayload = " + responsePayload);
+ assertTrue(responsePayload.equalsIgnoreCase("ok"));
+
+
+ //POST (Using token1.json with group of claims: [CRUD])
+ Movie newMovie = new Movie(1, "David Dobkin", "Wedding Crashers");
+ Response response = webClient.reset()
+ .path("/rest/cinema/movies")
+ .header("Content-Type", "application/json")
+ .header("Authorization", "Bearer " + token(1))
+ .post(newMovie);
+ LOGGER.info("responseCode = " + response.getStatus());
+ assertTrue(response.getStatus() == 204);
+
+
+ //GET movies (Using token1.json with group of claims: [read-only])
+ //This test should be updated to use token2.json once TOMEE- gets resolved.
+ Collection<? extends Movie> movies = webClient
+ .reset()
+ .path("/rest/cinema/movies")
+ .header("Content-Type", "application/json")
+ .header("Authorization", "Bearer " + token(1))
+ .getCollection(Movie.class);
+ LOGGER.info(movies.toString());
+ assertTrue(movies.size() == 1);
+
+
+ //Should return a 403 since POST require group of claims: [crud] but Token 2 has only [read-only].
+ Movie secondNewMovie = new Movie(2, "Todd Phillips", "Starsky & Hutch");
+ Response responseWithError = webClient.reset()
+ .path("/rest/cinema/movies")
+ .header("Content-Type", "application/json")
+ .header("Authorization", "Bearer " + token(2))
+ .post(secondNewMovie);
+ LOGGER.info("responseCode = " + responseWithError.getStatus());
+ assertTrue(responseWithError.getStatus() == 403);
+
+
+ //Should return a 401 since the header Authorization is not part of the POST request.
+ Response responseWith401Error = webClient.reset()
+ .path("/rest/cinema/movies")
+ .header("Content-Type", "application/json")
+ .post(new Movie());
+ LOGGER.info("responseCode = " + responseWith401Error.getStatus());
+ assertTrue(responseWith401Error.getStatus() == 401);
+
+ }
+
+
+ private String token(int token_type) throws Exception {
+ HashMap<String, Long> timeClaims = new HashMap<>();
+ if (token_type == 1) {
+ return TokenUtils.generateTokenString("/Token1.json", null, timeClaims);
+ } else {
+ return TokenUtils.generateTokenString("/Token2.json", null, timeClaims);
+ }
+ }
+
+}
+....
http://git-wip-us.apache.org/repos/asf/tomee/blob/fcdaefeb/examples/mp-rest-jwt/README.md
----------------------------------------------------------------------
diff --git a/examples/mp-rest-jwt/README.md b/examples/mp-rest-jwt/README.md
deleted file mode 100644
index fdd20da..0000000
--- a/examples/mp-rest-jwt/README.md
+++ /dev/null
@@ -1,307 +0,0 @@
-index-group=Unrevised
-type=page
-status=published
-~~~~~~
-# MP REST JWT
-This is a basic example on how to configure and use MicroProfile JWT in TomEE.
-
-## Run the tests for different scenarios related with JWT validation
-
- mvn clean test
-
-## Configuration in TomEE
-
-The class `MoviesMPJWTConfigurationProvider.java` provides to TomEE the figuration need it for JWT validation.
-
- package org.superbiz.moviefun.rest;
-
- import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfo;
-
- import javax.enterprise.context.Dependent;
- import javax.enterprise.inject.Produces;
- import java.security.KeyFactory;
- import java.security.NoSuchAlgorithmException;
- import java.security.interfaces.RSAPublicKey;
- import java.security.spec.InvalidKeySpecException;
- import java.security.spec.X509EncodedKeySpec;
- import java.util.Base64;
- import java.util.Optional;
-
- @Dependent
- public class MoviesMPJWTConfigurationProvider {
-
- @Produces
- Optional<JWTAuthContextInfo> getOptionalContextInfo() throws NoSuchAlgorithmException, InvalidKeySpecException {
- JWTAuthContextInfo contextInfo = new JWTAuthContextInfo();
-
- // todo use MP Config to load the configuration
- contextInfo.setIssuedBy("https://server.example.com");
-
- final String pemEncoded = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlivFI8qB4D0y2jy0CfEq" +
- "Fyy46R0o7S8TKpsx5xbHKoU1VWg6QkQm+ntyIv1p4kE1sPEQO73+HY8+Bzs75XwR" +
- "TYL1BmR1w8J5hmjVWjc6R2BTBGAYRPFRhor3kpM6ni2SPmNNhurEAHw7TaqszP5e" +
- "UF/F9+KEBWkwVta+PZ37bwqSE4sCb1soZFrVz/UT/LF4tYpuVYt3YbqToZ3pZOZ9" +
- "AX2o1GCG3xwOjkc4x0W7ezbQZdC9iftPxVHR8irOijJRRjcPDtA6vPKpzLl6CyYn" +
- "sIYPd99ltwxTHjr3npfv/3Lw50bAkbT4HeLFxTx4flEoZLKO/g0bAoV2uqBhkA9x" +
- "nQIDAQAB";
- byte[] encodedBytes = Base64.getDecoder().decode(pemEncoded);
-
- final X509EncodedKeySpec spec = new X509EncodedKeySpec(encodedBytes);
- final KeyFactory kf = KeyFactory.getInstance("RSA");
- final RSAPublicKey pk = (RSAPublicKey) kf.generatePublic(spec);
-
- contextInfo.setSignerKey(pk);
-
- return Optional.of(contextInfo);
- }
-
- @Produces
- JWTAuthContextInfo getContextInfo() throws InvalidKeySpecException, NoSuchAlgorithmException {
- return getOptionalContextInfo().get();
- }
- }
-
-## Use MicroProfile JWT in TomEE
-
-The JAX-RS resource `MoviesRest.java` contains several endpoint that are secured using the standard
-annotation `@RolesAllowed`. MicroProfile JWT takes care of performing the validation for incoming
-requests with `Authorization` header providing a signed `Access Token`
-
-
- package org.superbiz.moviefun.rest;
-
- import org.superbiz.moviefun.Movie;
- import org.superbiz.moviefun.MoviesBean;
-
- import javax.annotation.security.RolesAllowed;
- import javax.inject.Inject;
- import javax.ws.rs.*;
- import javax.ws.rs.core.MediaType;
- import java.util.List;
-
- @Path("cinema")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public class MoviesRest {
-
- @Inject
- private MoviesBean moviesBean;
-
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public String status() {
- return "ok";
- }
-
- @GET
- @Path("/movies")
- @RolesAllowed({"crud", "read-only"})
- public List<Movie> getListOfMovies() {
- return moviesBean.getMovies();
- }
-
- @GET
- @Path("/movies/{id}")
- @RolesAllowed({"crud", "read-only"})
- public Movie getMovie(@PathParam("id") int id) {
- return moviesBean.getMovie(id);
- }
-
- @POST
- @Path("/movies")
- @RolesAllowed("crud")
- public void addMovie(Movie newMovie) {
- moviesBean.addMovie(newMovie);
- }
-
- @DELETE
- @Path("/movies/{id}")
- @RolesAllowed("crud")
- public void deleteMovie(@PathParam("id") int id) {
- moviesBean.deleteMovie(id);
- }
-
- @PUT
- @Path("/movies")
- @RolesAllowed("crud")
- public void updateMovie(Movie updatedMovie) {
- moviesBean.updateMovie(updatedMovie);
- }
-
- }
-
- @Inject
- @ConfigProperty(name = "java.runtime.version")
- private String javaVersion;
-
-## About the Test architecture
-
-The test cases from this project are builded using Arquillian. The arquillian configuration can be found in
-`src/test/resources/arquillian.xml`
-
-The class `TokenUtils.java` is used during the test to act as an Authorization server who generates `Access Tokens` based
-on the configuration files `privateKey.pem`,`publicKey.pem`,`Token1.json`, and `Token2.json`.
-`nimbus-jose-jwt` is the library used for JWT generation during the tests.
-
-`Token1.json`
-
- {
- "iss": "https://server.example.com",
- "jti": "a-123",
- "sub": "24400320",
- "upn": "jdoe@example.com",
- "preferred_username": "jdoe",
- "aud": "s6BhdRkqt3",
- "exp": 1311281970,
- "iat": 1311280970,
- "auth_time": 1311280969,
- "groups": [
- "group1",
- "group2",
- "crud",
- "read-only"
- ]
- }
-
-
-`Token2.json`
-
- {
- "iss": "https://server.example.com",
- "jti": "a-123",
- "sub": "24400320",
- "upn": "alice@example.com",
- "preferred_username": "alice",
- "aud": "s6BhdRkqt3",
- "exp": 1311281970,
- "iat": 1311280970,
- "auth_time": 1311280969,
- "groups": [
- "read-only"
- ]
- }
-
-
-
-
-## Test Scenarios
-
-`MovieTest.java` contains 4 OAuth2 scenarios for different JWT combinations.
-
- package org.superbiz.moviefun;
-
- import org.apache.cxf.feature.LoggingFeature;
- import org.apache.cxf.jaxrs.client.WebClient;
- import org.apache.johnzon.jaxrs.JohnzonProvider;
- import org.jboss.arquillian.container.test.api.Deployment;
- import org.jboss.arquillian.junit.Arquillian;
- import org.jboss.arquillian.test.api.ArquillianResource;
- import org.jboss.shrinkwrap.api.ShrinkWrap;
- import org.jboss.shrinkwrap.api.asset.StringAsset;
- import org.jboss.shrinkwrap.api.spec.WebArchive;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.superbiz.moviefun.rest.ApplicationConfig;
- import org.superbiz.moviefun.rest.MoviesMPJWTConfigurationProvider;
- import org.superbiz.moviefun.rest.MoviesRest;
-
- import javax.ws.rs.core.Response;
- import java.net.URL;
- import java.util.Collection;
- import java.util.HashMap;
- import java.util.logging.Logger;
-
- import static java.util.Collections.singletonList;
- import static org.junit.Assert.assertTrue;
-
- @RunWith(Arquillian.class)
- public class MoviesTest {
-
- @Deployment(testable = false)
- public static WebArchive createDeployment() {
- final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")
- .addClasses(Movie.class, MoviesBean.class, MoviesTest.class)
- .addClasses(MoviesRest.class, ApplicationConfig.class)
- .addClass(MoviesMPJWTConfigurationProvider.class)
- .addAsWebInfResource(new StringAsset("<beans/>"), "beans.xml");
-
- System.out.println(webArchive.toString(true));
-
- return webArchive;
- }
-
- @ArquillianResource
- private URL base;
-
-
- private final static Logger LOGGER = Logger.getLogger(MoviesTest.class.getName());
-
- @Test
- public void movieRestTest() throws Exception {
-
- final WebClient webClient = WebClient
- .create(base.toExternalForm(), singletonList(new JohnzonProvider<>()),
- singletonList(new LoggingFeature()), null);
-
-
- //Testing rest endpoint deployment (GET without security header)
- String responsePayload = webClient.reset().path("/rest/cinema/").get(String.class);
- LOGGER.info("responsePayload = " + responsePayload);
- assertTrue(responsePayload.equalsIgnoreCase("ok"));
-
-
- //POST (Using token1.json with group of claims: [CRUD])
- Movie newMovie = new Movie(1, "David Dobkin", "Wedding Crashers");
- Response response = webClient.reset()
- .path("/rest/cinema/movies")
- .header("Content-Type", "application/json")
- .header("Authorization", "Bearer " + token(1))
- .post(newMovie);
- LOGGER.info("responseCode = " + response.getStatus());
- assertTrue(response.getStatus() == 204);
-
-
- //GET movies (Using token1.json with group of claims: [read-only])
- //This test should be updated to use token2.json once TOMEE- gets resolved.
- Collection<? extends Movie> movies = webClient
- .reset()
- .path("/rest/cinema/movies")
- .header("Content-Type", "application/json")
- .header("Authorization", "Bearer " + token(1))
- .getCollection(Movie.class);
- LOGGER.info(movies.toString());
- assertTrue(movies.size() == 1);
-
-
- //Should return a 403 since POST require group of claims: [crud] but Token 2 has only [read-only].
- Movie secondNewMovie = new Movie(2, "Todd Phillips", "Starsky & Hutch");
- Response responseWithError = webClient.reset()
- .path("/rest/cinema/movies")
- .header("Content-Type", "application/json")
- .header("Authorization", "Bearer " + token(2))
- .post(secondNewMovie);
- LOGGER.info("responseCode = " + responseWithError.getStatus());
- assertTrue(responseWithError.getStatus() == 403);
-
-
- //Should return a 401 since the header Authorization is not part of the POST request.
- Response responseWith401Error = webClient.reset()
- .path("/rest/cinema/movies")
- .header("Content-Type", "application/json")
- .post(new Movie());
- LOGGER.info("responseCode = " + responseWith401Error.getStatus());
- assertTrue(responseWith401Error.getStatus() == 401);
-
- }
-
-
- private String token(int token_type) throws Exception {
- HashMap<String, Long> timeClaims = new HashMap<>();
- if (token_type == 1) {
- return TokenUtils.generateTokenString("/Token1.json", null, timeClaims);
- } else {
- return TokenUtils.generateTokenString("/Token2.json", null, timeClaims);
- }
- }
-
- }
\ No newline at end of file