Added: websites/staging/tomee/trunk/content/tomee-8.0/examples/cloud-tomee-azure.html ============================================================================== --- websites/staging/tomee/trunk/content/tomee-8.0/examples/cloud-tomee-azure.html (added) +++ websites/staging/tomee/trunk/content/tomee-8.0/examples/cloud-tomee-azure.html Sat Sep 7 20:39:03 2019 @@ -0,0 +1,339 @@ +<!DOCTYPE html> +<html lang="en"> + +<head> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Apache TomEE</title> + <meta name="description" + content="Apache TomEE is a lightweight, yet powerful, JavaEE Application server with feature rich tooling." /> + <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" /> + <meta name="author" content="Luka Cvetinovic for Codrops" /> + <link rel="icon" href="../../favicon.ico"> + <link rel="icon" type="image/png" href="../../favicon.png"> + <meta name="msapplication-TileColor" content="#80287a"> + <meta name="theme-color" content="#80287a"> + <link rel="stylesheet" type="text/css" href="../../css/normalize.css"> + <link rel="stylesheet" type="text/css" href="../../css/bootstrap.css"> + <link rel="stylesheet" type="text/css" href="../../css/owl.css"> + <link rel="stylesheet" type="text/css" href="../../css/animate.css"> + <link rel="stylesheet" type="text/css" href="../../fonts/font-awesome-4.1.0/css/font-awesome.min.css"> + <link rel="stylesheet" type="text/css" href="../../fonts/eleganticons/et-icons.css"> + <link rel="stylesheet" type="text/css" href="../../css/jqtree.css"> + <link rel="stylesheet" type="text/css" href="../../css/idea.css"> + <link rel="stylesheet" type="text/css" href="../../css/cardio.css"> + + <script type="text/javascript"> + + var _gaq = _gaq || []; + _gaq.push(['_setAccount', 'UA-2717626-1']); + _gaq.push(['_setDomainName', 'apache.org']); + _gaq.push(['_trackPageview']); + + (function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); + })(); + + </script> +</head> + +<body> + <div class="preloader"> + <img src="../../img/loader.gif" alt="Preloader image"> + </div> + <nav class="navbar"> + <div class="container"> + <div class="row"> <div class="col-md-12"> + + <!-- Brand and toggle get grouped for better mobile display --> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> + <span class="sr-only">Toggle navigation</span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="/"> + <span> + + + <img src="../../img/logo-active.png"> + + + </span> + Apache TomEE + </a> + </div> + <!-- Collect the nav links, forms, and other content for toggling --> + <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> + <ul class="nav navbar-nav navbar-right main-nav"> + <li><a href="../../docs.html">Documentation</a></li> + <li><a href="../../community/index.html">Community</a></li> + <li><a href="../../security/security.html">Security</a></li> + <li><a href="../../download-ng.html">Downloads</a></li> + </ul> + </div> + <!-- /.navbar-collapse --> + </div></div> + </div> + <!-- /.container-fluid --> + </nav> + + + <div id="main-block" class="container main-block"> + <div class="row title"> + <div class="col-md-12"> + <div class='page-header'> + + <h1>TomEE deployment on Azure</h1> + </div> + </div> + </div> + <div class="row"> + + <div class="col-md-12"> + <div id="preamble"> +<div class="sectionbody"> +<div class="paragraph"> +<p>This example uses a basic echo application, deployed with embedded TomEE on the Azure Cloud.</p> +</div> +<div class="paragraph"> +<p>We use the TomEE maven plugin to package the app with TomEE Embedded +in order to generate a fat jar. This jar is then picked up and deployed by the azure-webapp-maven-plugin.</p> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_azure_setup">Azure Setup</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>In order for the Azure plugin to work, you will need to have an Azure account and add a subscription to it. +Then, on your development machine, install the Azure command-line interface (CLI) and authenticate with the command +line, before you can deploy your application.</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>Create an Azure Account, if you don’t have one, at <a href="https://azure.microsoft.com/en-us" class="bare">https://azure.microsoft.com/en-us</a></p> +</li> +<li> +<p>Use the free option, if available or <a href="https://portal.azure.com/#blade/Microsoft_Azure_Billing/SubscriptionsBlade">add a subscription</a>.</p> +</li> +<li> +<p><a href="https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest">Install</a> the Azure (CLI) according +to operating system of the computer you are using to develop.</p> +</li> +<li> +<p>Finally you can setup your development computer.</p> +</li> +</ul> +</div> +<div class="sect2"> +<h3 id="_login_into_azure">Login into Azure</h3> +<div class="paragraph"> +<p><code>az login</code></p> +</div> +<div class="paragraph"> +<p>The result:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>[ + { + "cloudName": "AzureCloud", + "id": "aaaaaaaa-aaaa-aaaa-aaaaa-aaaaaaaaaa", + "isDefault": true, + "name": "Pay-As-You-Go", + "state": "Enabled", + "tenantId": "bbbbbbb-bbbbb-bbbb-bbbbb-bbbbbbbbbbb", + "user": { + "name": "<your azure account's email>", + "type": "user" + } + } + ]</pre> +</div> +</div> +<div class="paragraph"> +<p>The TenantId is someone that can register and manage apps, yourself. You will need that for later.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_create_a_service_principal">Create a service principal</h3> +<div class="paragraph"> +<p>An Azure service principal is a security identity used by user-created apps, services, +and automation tools to access specific Azure resources:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>az ad sp create-for-rbac --name http://<your-sub-domain> --password <password for this app> + +{ + "appId": "cccccccc-cccc-cccc-cccc-ccccccccccccccc", + "displayName": "cloud-tomee-azure", + "name": "http://cloud-tomee-azure", + "password": "<password for this app>", + "tenant": "bbbbbbb-bbbbb-bbbb-bbbbb-bbbbbbbbbbb" +}</pre> +</div> +</div> +<div class="paragraph"> +<p>The <your-sub-domain>, also called the service principal name in the Azure documentation. +In this example "http://cloud-tomee-azure". It has to be unique across Azure. +The appId is the identification of the app service.</p> +</div> +</div> +<div class="sect2"> +<h3 id="_configure_maven">Configure Maven</h3> +<div class="paragraph"> +<p>You could continue just using the Azure CLI for authentication but we can also do it permanently with Maven.</p> +</div> +<div class="paragraph"> +<p>In that case we need to edit Maven’s settings.xml so the azure-webapp-maven-plugin can authenticate against Azure:</p> +</div> +<div class="paragraph"> +<p>You can add a new server to <code>~/.m2/settings.xml</code> like this:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre><server> + <id>azure-auth</id> + <configuration> + <client>cccccccc-cccc-cccc-cccc-ccccccccccccccc</client> + <tenant>bbbbbbb-bbbbb-bbbb-bbbbb-bbbbbbbbbbb</tenant> + <key><password for this app></key> + <environment>AZURE</environment> + </configuration> +</server></pre> +</div> +</div> +<div class="paragraph"> +<p>That’s it. You can now build the example and deploy it to Azure just using Maven:</p> +</div> +<div class="paragraph"> +<p><code>mvn clean install -Pazure-single-jar azure-webapp:deploy</code></p> +</div> +<div class="paragraph"> +<p>The azure-webapp is explicitly invoked because it relies on you Azure account. The standard TomEE build will not use an Azure account.</p> +</div> +<div class="paragraph"> +<p>The end URL will look like:</p> +</div> +<div class="paragraph"> +<p><code><a href="https://<your-sub-domain>.azurewebsites.net/cloud-tomee-azure-8.0.0-SNAPSHOT/echo/send-this-back" class="bare">https://<your-sub-domain>.azurewebsites.net/cloud-tomee-azure-8.0.0-SNAPSHOT/echo/send-this-back</a></code></p> +</div> +<div class="sect3"> +<h4 id="_notes">Notes</h4> +<div class="paragraph"> +<p>At the moment of creation of this example there is a bug on azure with the JAVA_HOME that prevents the deployment. +Check: <a href="https://github.com/Azure-App-Service/java/issues/11" class="bare">https://github.com/Azure-App-Service/java/issues/11</a> +The workaround is to set the Env. variable on the Azure web console and restart the app.</p> +</div> +<div class="paragraph"> +<p>To deploy the echo app locally you can execute:</p> +</div> +<div class="paragraph"> +<p><code>mvn tomee:run</code></p> +</div> +<div class="paragraph"> +<p>You can test the app by calling <code><a href="http://localhost/cloud-tomee-azure-8.0.0-SNAPSHOT/echo/send-this-back" class="bare">http://localhost/cloud-tomee-azure-8.0.0-SNAPSHOT/echo/send-this-back</a></code></p> +</div> +<div class="paragraph"> +<p>It will return send-this-back.</p> +</div> +<div class="paragraph"> +<p>The echo app is also available with a simple war file that you can deploy on TomEE manually, for testing purposes.</p> +</div> +</div> +</div> +</div> +</div> + </div> + + </div> + </div> +<footer> + <div class="container"> + <div class="row"> + <div class="col-sm-6 text-center-mobile"> + <h3 class="white">Be simple. Be certified. Be Tomcat.</h3> + <h5 class="light regular light-white">"A good application in a good server"</h5> + <ul class="social-footer"> + <li><a href="https://www.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li> + <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li> + <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li> + </ul> + </div> + <div class="col-sm-6 text-center-mobile"> + <div class="row opening-hours"> + <div class="col-sm-3 text-center-mobile"> + <h5><a href="../../latest/docs/documentation.html" class="white">Documentation</a></h5> + <ul class="list-unstyled"> + <li><a href="../../latest/docs/admin/configuration/index.html" class="regular light-white">How to configure</a></li> + <li><a href="../../latest/docs/admin/file-layout.html" class="regular light-white">Dir. Structure</a></li> + <li><a href="../../latest/docs/developer/testing/index.html" class="regular light-white">Testing</a></li> + <li><a href="../../latest/docs/admin/cluster/index.html" class="regular light-white">Clustering</a></li> + </ul> + </div> + <div class="col-sm-3 text-center-mobile"> + <h5><a href="../../latest/examples/" class="white">Examples</a></h5> + <ul class="list-unstyled"> + <li><a href="../../latest/examples/simple-cdi-interceptor.html" class="regular light-white">CDI Interceptor</a></li> + <li><a href="../../latest/examples/rest-cdi.html" class="regular light-white">REST with CDI</a></li> + <li><a href="../../latest/examples/ejb-examples.html" class="regular light-white">EJB</a></li> + <li><a href="../../latest/examples/jsf-managedBean-and-ejb.html" class="regular light-white">JSF</a></li> + </ul> + </div> + <div class="col-sm-3 text-center-mobile"> + <h5><a href="../../community/index.html" class="white">Community</a></h5> + <ul class="list-unstyled"> + <li><a href="../../community/contributors.html" class="regular light-white">Contributors</a></li> + <li><a href="../../community/social.html" class="regular light-white">Social</a></li> + <li><a href="../../community/sources.html" class="regular light-white">Sources</a></li> + </ul> + </div> + <div class="col-sm-3 text-center-mobile"> + <h5><a href="../../security/index.html" class="white">Security</a></h5> + <ul class="list-unstyled"> + <li><a href="http://apache.org/security" target="_blank" class="regular light-white">Apache Security</a></li> + <li><a href="http://apache.org/security/projects.html" target="_blank" class="regular light-white">Security Projects</a></li> + <li><a href="http://cve.mitre.org" target="_blank" class="regular light-white">CVE</a></li> + </ul> + </div> + </div> + </div> + </div> + <div class="row bottom-footer text-center-mobile"> + <div class="col-sm-12 light-white"> + <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p> + </div> + </div> + </div> + </footer> + <!-- Holder for mobile navigation --> + <div class="mobile-nav"> + <ul> + <li><a hef="../../latest/docs/admin/index.html">Administrators</a> + <li><a hef="../../latest/docs/developer/index.html">Developers</a> + <li><a hef="../../latest/docs/advanced/index.html">Advanced</a> + <li><a hef="../../community/index.html">Community</a> + </ul> + <a href="#" class="close-link"><i class="arrow_up"></i></a> + </div> + <!-- Scripts --> + <script src="../../js/jquery-1.11.1.min.js"></script> + <script src="../../js/owl.carousel.min.js"></script> + <script src="../../js/bootstrap.min.js"></script> + <script src="../../js/wow.min.js"></script> + <script src="../../js/typewriter.js"></script> + <script src="../../js/jquery.onepagenav.js"></script> + <script src="../../js/tree.jquery.js"></script> + <script src="../../js/highlight.pack.js"></script> + <script src="../../js/main.js"></script> + </body> + +</html> +
Added: websites/staging/tomee/trunk/content/tomee-8.0/examples/concurrency-utils.html ============================================================================== --- websites/staging/tomee/trunk/content/tomee-8.0/examples/concurrency-utils.html (added) +++ websites/staging/tomee/trunk/content/tomee-8.0/examples/concurrency-utils.html Sat Sep 7 20:39:03 2019 @@ -0,0 +1,593 @@ +<!DOCTYPE html> +<html lang="en"> + +<head> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Apache TomEE</title> + <meta name="description" + content="Apache TomEE is a lightweight, yet powerful, JavaEE Application server with feature rich tooling." /> + <meta name="keywords" content="tomee,asf,apache,javaee,jee,shade,embedded,test,junit,applicationcomposer,maven,arquillian" /> + <meta name="author" content="Luka Cvetinovic for Codrops" /> + <link rel="icon" href="../../favicon.ico"> + <link rel="icon" type="image/png" href="../../favicon.png"> + <meta name="msapplication-TileColor" content="#80287a"> + <meta name="theme-color" content="#80287a"> + <link rel="stylesheet" type="text/css" href="../../css/normalize.css"> + <link rel="stylesheet" type="text/css" href="../../css/bootstrap.css"> + <link rel="stylesheet" type="text/css" href="../../css/owl.css"> + <link rel="stylesheet" type="text/css" href="../../css/animate.css"> + <link rel="stylesheet" type="text/css" href="../../fonts/font-awesome-4.1.0/css/font-awesome.min.css"> + <link rel="stylesheet" type="text/css" href="../../fonts/eleganticons/et-icons.css"> + <link rel="stylesheet" type="text/css" href="../../css/jqtree.css"> + <link rel="stylesheet" type="text/css" href="../../css/idea.css"> + <link rel="stylesheet" type="text/css" href="../../css/cardio.css"> + + <script type="text/javascript"> + + var _gaq = _gaq || []; + _gaq.push(['_setAccount', 'UA-2717626-1']); + _gaq.push(['_setDomainName', 'apache.org']); + _gaq.push(['_trackPageview']); + + (function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); + })(); + + </script> +</head> + +<body> + <div class="preloader"> + <img src="../../img/loader.gif" alt="Preloader image"> + </div> + <nav class="navbar"> + <div class="container"> + <div class="row"> <div class="col-md-12"> + + <!-- Brand and toggle get grouped for better mobile display --> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> + <span class="sr-only">Toggle navigation</span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="/"> + <span> + + + <img src="../../img/logo-active.png"> + + + </span> + Apache TomEE + </a> + </div> + <!-- Collect the nav links, forms, and other content for toggling --> + <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> + <ul class="nav navbar-nav navbar-right main-nav"> + <li><a href="../../docs.html">Documentation</a></li> + <li><a href="../../community/index.html">Community</a></li> + <li><a href="../../security/security.html">Security</a></li> + <li><a href="../../download-ng.html">Downloads</a></li> + </ul> + </div> + <!-- /.navbar-collapse --> + </div></div> + </div> + <!-- /.container-fluid --> + </nav> + + + <div id="main-block" class="container main-block"> + <div class="row title"> + <div class="col-md-12"> + <div class='page-header'> + + <h1>Concurrency Utilities for Java EE</h1> + </div> + </div> + </div> + <div class="row"> + + <div class="col-md-12"> + <div id="preamble"> +<div class="sectionbody"> +<div class="paragraph"> +<p>In this example will be used <a href="https://docs.oracle.com/javaee/7/tutorial/concurrency-utilities.htm">Concurrency Utilities for Java EE</a>, or JSR 236.</p> +</div> +<div class="paragraph"> +<p>This standard allows application developers to use concurrency utilities managed by the application server. +In this way, the developer no longer has the responsibility to manually manage thread polls or threads. +Also, in a non-managed Thread object, the container cannot guarantee that other Java EE platform services work correctly. For these reasons, it is recommended the usage of managed threads whenever the need arise. +More information can be found <a href="https://docs.oracle.com/javaee/7/tutorial/concurrency-utilities001.htm">here</a>.</p> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_main_components_of_the_concurrency_utilities">Main Components of the Concurrency Utilities</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>The standard specifies main components of the concurrency utilities. In short, these components are managed objects that offer concurrency facilities. These objects, since are managed by the application, can be injected either using CDI, either JNDI. More information can be found <a href="https://docs.oracle.com/javaee/7/tutorial/concurrency-utilities002.htm">here</a>.</p> +</div> +<div class="sect2"> +<h3 id="_managedexecutorservice">ManagedExecutorService</h3> +<div class="paragraph"> +<p>A <code>ManagedExecutorService</code> is an object that allows application developers to submit tasks asynchronously. Tasks are executed on threads that are managed by the container.</p> +</div> +<div class="sect3"> +<h4 id="_example">Example</h4> +<div class="paragraph"> +<p>Here is a class that uses a <code>ManagedExecutorService</code> (full code can be found <a href="https://github.com/apache/tomee/blob/master/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedService.java">here</a>):</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@RequestScoped +public class ManagedService { + + @Resource + private ManagedExecutorService executor; + + public CompletableFuture<Integer> asyncTask(final int value) { + return CompletableFuture + .supplyAsync(longTask(value, 100, null), executor) + .thenApply(i -> i + 1); + } + + public CompletableFuture<Integer> asyncTaskWithException(final int value) { + return CompletableFuture + .supplyAsync(longTask(value, 100, "Planned exception"), executor) + .thenApply(i -> i + 1); + } + + private Supplier<Integer> longTask(final int value, + final int taskDurationMs, + final String errorMessage) { + return () -> { + if (nonNull(errorMessage)) { + throw new RuntimeException(errorMessage); + } + + try { + TimeUnit.MILLISECONDS.sleep(taskDurationMs); + } catch (InterruptedException e) { + throw new RuntimeException("Problem while waiting"); + } + return value + 1; + }; + } + +}</pre> +</div> +</div> +<div class="paragraph"> +<p>The <code>ManagedExecutorService</code> object, being an managed object, is injected using the <code>@Resource</code> annotation.</p> +</div> +<div class="paragraph"> +<p>This example simulates a long running computation, defined in the <code>longTask</code> method.</p> +</div> +<div class="paragraph"> +<p>The capabilities of <code>ManagedExecutorService</code> are exemplified in the <code>asyncTask</code> and <code>asyncTaskWithException</code> methods. +Both methods invoke the <code>longTask</code> method defined above; each execution of <code>longTask</code> is performed in a thread managed by the application. +The method <code>asyncTask</code> simulates a successful execution, while the <code>asyncTaskWithException</code> simulates a execution that will throw an exception.</p> +</div> +<div class="paragraph"> +<p>The methods are used in the following test class (full example can be found <a href="https://github.com/apache/tomee/blob/master/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedServiceTest.java">here</a>):</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@RunWith(Arquillian.class) +public class ManagedServiceTest { + + @Inject + private ManagedService managedService; + + @Deployment() + public static final WebArchive app() { + return ShrinkWrap.create(WebArchive.class, "example.war") + .addClasses(ManagedService.class) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void managedInvocationTest() { + final CompletableFuture<Integer> future = managedService.asyncTask(1); + try { + assertEquals(3, future.get(200, TimeUnit.MILLISECONDS).intValue()); + } catch (Exception e) { + fail("Unexpected exception" + e); + } + } + + @Test(expected = TimeoutException.class) + public void managedInvocationTestWithTimeout() throws InterruptedException, ExecutionException, TimeoutException { + final CompletableFuture<Integer> future = managedService.asyncTask(1); + future.get(10, TimeUnit.MILLISECONDS); + } + + @Test + public void managedInvocationTestWithException() { + final CompletableFuture<Integer> future = managedService.asyncTaskWithException(1); + + try { + future.get(200, TimeUnit.MILLISECONDS); + } catch (ExecutionException e) { + assertEquals("Planned exception", e.getCause().getMessage()); + } catch (Exception e) { + fail("Unexpected exception" + e); + } + } +}</pre> +</div> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_managedscheduledexecutorservice">ManagedScheduledExecutorService</h3> +<div class="paragraph"> +<p>A <code>ManagedScheduledExecutorService</code> is an object that allows developers to execute tasks asynchronously at specific times. The tasks are executed on threads started by the container.</p> +</div> +<div class="sect3"> +<h4 id="_example_2">Example</h4> +<div class="paragraph"> +<p>Full example can be found <a href="https://github.com/apache/tomee/blob/master/examples/concurrency-utils/src/main/java/org/superbiz/executor/ManagedScheduledService.java">here</a>:</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@RequestScoped +public class ManagedScheduledService { + + @Resource + private ManagedScheduledExecutorService executor; + + public Future<Integer> singleFixedDelayTask(final int value, + final String errorMessage) { + return executor.schedule( + longCallableTask(value, 10, errorMessage), 100, TimeUnit.MILLISECONDS); + } + + public ScheduledFuture<?> periodicFixedDelayTask(final int value, + final String errorMessage, + final CountDownLatch countDownLatch) { + return executor.scheduleAtFixedRate( + longRunnableTask(value, 10, errorMessage, countDownLatch), 0, 100, TimeUnit.MILLISECONDS); + } + + private Runnable longRunnableTask(final int value, + final int taskDurationMs, + final String errorMessage, + final CountDownLatch countDownLatch) { + return () -> { + failOrWait(taskDurationMs, errorMessage); + Integer result = value + 1; + countDownLatch.countDown(); + }; + } + + private Callable<Integer> longCallableTask(final int value, + final int taskDurationMs, + final String errorMessage) { + return () -> { + failOrWait(taskDurationMs, errorMessage); + return value + 1; + }; + } + + private void failOrWait(final int taskDurationMs, + final String errorMessage) { + if (nonNull(errorMessage)) { + throw new RuntimeException(errorMessage); + } + try { + TimeUnit.MILLISECONDS.sleep(taskDurationMs); + } catch (InterruptedException e) { + throw new RuntimeException("Problem while waiting"); + } + } + +}</pre> +</div> +</div> +<div class="paragraph"> +<p>This example also defines a method, <code>longCallableTask</code>, simulating the execution of a long running computation.</p> +</div> +<div class="paragraph"> +<p>The method <code>singleFixedDelayTask</code> schedules a long running task (by calling <code>longCallableTask</code>), but the execution will start after 100 ms. +The method <code>periodicFixedDelayTask</code> schedules tasks to be run periodically, after each 100 ms, with an initial delay of 0.</p> +</div> +<div class="paragraph"> +<p>The methods are used in the following test class (full code can be found <a href="https://github.com/apache/tomee/blob/master/examples/concurrency-utils/src/test/java/org/superbiz/executor/ManagedScheduledServiceTest.java">here</a>):</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@RunWith(Arquillian.class) +public class ManagedScheduledServiceTest { + + @Inject + private ManagedScheduledService scheduledService; + + @Deployment() + public static final WebArchive app() { + return ShrinkWrap.create(WebArchive.class, "example.war") + .addClasses(ManagedScheduledService.class) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void singleFixedDelayTask() throws InterruptedException, ExecutionException, TimeoutException { + final Future<Integer> futureA = scheduledService.singleFixedDelayTask(1, null); + final Future<Integer> futureB = scheduledService.singleFixedDelayTask(50, null); + + assertEquals(2, futureA.get(200, TimeUnit.MILLISECONDS).intValue()); + assertEquals(51, futureB.get(200, TimeUnit.MILLISECONDS).intValue()); + + } + + @Test + public void periodicFixedDelayTask() throws InterruptedException { + final CountDownLatch countDownLatch = new CountDownLatch(4); // execute 4 times + final ScheduledFuture<?> scheduledFuture = scheduledService.periodicFixedDelayTask(1, null, countDownLatch); + countDownLatch.await(500, TimeUnit.MILLISECONDS); + if (!scheduledFuture.isCancelled()) { + scheduledFuture.cancel(true); + } + } + + @Test + public void singleFixedDelayTaskWithException() { + final Future<Integer> future = scheduledService.singleFixedDelayTask(1, "Planned exception"); + try { + future.get(200, TimeUnit.MILLISECONDS); + } catch (ExecutionException e) { + assertEquals("Planned exception", e.getCause().getMessage()); + } catch (Exception e) { + fail("Unexpected exception" + e); + } + } + + @Test + public void periodicFixedDelayTaskWithException() { + final CountDownLatch countDownLatch = new CountDownLatch(1); + final ScheduledFuture<?> scheduledFuture = scheduledService.periodicFixedDelayTask(1, "Planned exception", countDownLatch); + + try { + countDownLatch.await(200, TimeUnit.MILLISECONDS); + scheduledFuture.get(200, TimeUnit.MILLISECONDS); + } catch (ExecutionException e) { + assertEquals("Planned exception", e.getCause().getMessage()); + } catch (Exception e) { + fail("Unexpected exception" + e); + } + + if (!scheduledFuture.isCancelled()) { + scheduledFuture.cancel(true); + } + } + +}</pre> +</div> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_managedthreadfactory">ManagedThreadFactory</h3> +<div class="paragraph"> +<p>A <code>ManagedThreadFactory</code> is an object that allows developers to create container managed threads.</p> +</div> +<div class="sect3"> +<h4 id="_example_3">Example</h4> +<div class="paragraph"> +<p>Full example can be found <a href="https://github.com/apache/tomee/blob/master/examples/concurrency-utils/src/main/java/org/superbiz/executor/ThreadFactoryService.java">here</a>:</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@RequestScoped +public class ThreadFactoryService { + + @Resource + private ManagedThreadFactory factory; + + public void asyncTask(final LongTask longTask) throws InterruptedException { + final Thread thread = factory.newThread(longTask); + thread.setName("pretty asyncTask"); + thread.start(); + } + + public void asyncHangingTask(final Runnable longTask) { + final Thread thread = factory.newThread(longTask); + thread.setName("pretty asyncHangingTask"); + thread.start(); + + if (thread.isAlive()) { + thread.interrupt(); + } + } + + public static class LongTask implements Runnable { + private final int value; + private final long taskDurationMs; + private final CountDownLatch countDownLatch; + private int result; + private AtomicBoolean isTerminated = new AtomicBoolean(false); + + public LongTask(final int value, + final long taskDurationMs, + final CountDownLatch countDownLatch) { + this.value = value; + this.taskDurationMs = taskDurationMs; + this.countDownLatch = countDownLatch; + } + + public int getResult() { + return result; + } + + public boolean getIsTerminated() { + return isTerminated.get(); + } + + @Override + public void run() { + try { + TimeUnit.MILLISECONDS.sleep(taskDurationMs); + } catch (InterruptedException e) { + isTerminated.set(true); + countDownLatch.countDown(); + throw new RuntimeException("Problem while waiting"); + } + + result = value + 1; + countDownLatch.countDown(); + } + } +}</pre> +</div> +</div> +<div class="paragraph"> +<p>This example defines a class implementing <code>Runnable</code>, executing a long running task in the <code>run</code> method.</p> +</div> +<div class="paragraph"> +<p>The method <code>asyncTask</code> just creates a managed thread (using the injected <code>ManagedThreadFactory</code>) then starts it. +The method <code>asyncHangingTask</code> also creates a managed thread, starts it, but then stops it.</p> +</div> +<div class="paragraph"> +<p>The following class tests these methods (full code can be found <a href="https://github.com/apache/tomee/blob/master/examples/concurrency-utils/src/test/java/org/superbiz/executor/ThreadFactoryServiceTest.java">here</a>):</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@RunWith(Arquillian.class) +public class ThreadFactoryServiceTest { + + @Inject + private ThreadFactoryService factoryService; + + @Deployment() + public static final WebArchive app() { + return ShrinkWrap.create(WebArchive.class, "example.war") + .addClasses(ThreadFactoryService.class) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } + + @Test + public void asyncTask() throws InterruptedException { + final CountDownLatch countDownLatch = new CountDownLatch(1); + final LongTask longTask = new LongTask(1, 50, countDownLatch); + factoryService.asyncTask(longTask); + + countDownLatch.await(200, TimeUnit.MILLISECONDS); + + assertEquals(2, longTask.getResult()); + } + + @Test + public void asyncHangingTask() throws InterruptedException { + final CountDownLatch countDownLatch = new CountDownLatch(1); + final LongTask longTask = new LongTask(1, 1000000, countDownLatch); + + factoryService.asyncHangingTask(longTask); + + countDownLatch.await(200, TimeUnit.MILLISECONDS); + + assertTrue(longTask.getIsTerminated()); + } +}</pre> +</div> +</div> +<div class="paragraph"> +<p>Full project example can be found <a href="https://github.com/apache/tomee/tree/master/examples/concurrency-utils">here</a>. +It’s a Maven project, and all the tests can be executed by running <code>mvn clean install</code> command.</p> +</div> +</div> +</div> +</div> +</div> + </div> + + </div> + </div> +<footer> + <div class="container"> + <div class="row"> + <div class="col-sm-6 text-center-mobile"> + <h3 class="white">Be simple. Be certified. Be Tomcat.</h3> + <h5 class="light regular light-white">"A good application in a good server"</h5> + <ul class="social-footer"> + <li><a href="https://www.facebook.com/ApacheTomEE/"><i class="fa fa-facebook"></i></a></li> + <li><a href="https://twitter.com/apachetomee"><i class="fa fa-twitter"></i></a></li> + <li><a href="https://plus.google.com/communities/105208241852045684449"><i class="fa fa-google-plus"></i></a></li> + </ul> + </div> + <div class="col-sm-6 text-center-mobile"> + <div class="row opening-hours"> + <div class="col-sm-3 text-center-mobile"> + <h5><a href="../../latest/docs/documentation.html" class="white">Documentation</a></h5> + <ul class="list-unstyled"> + <li><a href="../../latest/docs/admin/configuration/index.html" class="regular light-white">How to configure</a></li> + <li><a href="../../latest/docs/admin/file-layout.html" class="regular light-white">Dir. Structure</a></li> + <li><a href="../../latest/docs/developer/testing/index.html" class="regular light-white">Testing</a></li> + <li><a href="../../latest/docs/admin/cluster/index.html" class="regular light-white">Clustering</a></li> + </ul> + </div> + <div class="col-sm-3 text-center-mobile"> + <h5><a href="../../latest/examples/" class="white">Examples</a></h5> + <ul class="list-unstyled"> + <li><a href="../../latest/examples/simple-cdi-interceptor.html" class="regular light-white">CDI Interceptor</a></li> + <li><a href="../../latest/examples/rest-cdi.html" class="regular light-white">REST with CDI</a></li> + <li><a href="../../latest/examples/ejb-examples.html" class="regular light-white">EJB</a></li> + <li><a href="../../latest/examples/jsf-managedBean-and-ejb.html" class="regular light-white">JSF</a></li> + </ul> + </div> + <div class="col-sm-3 text-center-mobile"> + <h5><a href="../../community/index.html" class="white">Community</a></h5> + <ul class="list-unstyled"> + <li><a href="../../community/contributors.html" class="regular light-white">Contributors</a></li> + <li><a href="../../community/social.html" class="regular light-white">Social</a></li> + <li><a href="../../community/sources.html" class="regular light-white">Sources</a></li> + </ul> + </div> + <div class="col-sm-3 text-center-mobile"> + <h5><a href="../../security/index.html" class="white">Security</a></h5> + <ul class="list-unstyled"> + <li><a href="http://apache.org/security" target="_blank" class="regular light-white">Apache Security</a></li> + <li><a href="http://apache.org/security/projects.html" target="_blank" class="regular light-white">Security Projects</a></li> + <li><a href="http://cve.mitre.org" target="_blank" class="regular light-white">CVE</a></li> + </ul> + </div> + </div> + </div> + </div> + <div class="row bottom-footer text-center-mobile"> + <div class="col-sm-12 light-white"> + <p>Copyright © 1999-2016 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache TomEE, TomEE, Apache, the Apache feather logo, and the Apache TomEE project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.</p> + </div> + </div> + </div> + </footer> + <!-- Holder for mobile navigation --> + <div class="mobile-nav"> + <ul> + <li><a hef="../../latest/docs/admin/index.html">Administrators</a> + <li><a hef="../../latest/docs/developer/index.html">Developers</a> + <li><a hef="../../latest/docs/advanced/index.html">Advanced</a> + <li><a hef="../../community/index.html">Community</a> + </ul> + <a href="#" class="close-link"><i class="arrow_up"></i></a> + </div> + <!-- Scripts --> + <script src="../../js/jquery-1.11.1.min.js"></script> + <script src="../../js/owl.carousel.min.js"></script> + <script src="../../js/bootstrap.min.js"></script> + <script src="../../js/wow.min.js"></script> + <script src="../../js/typewriter.js"></script> + <script src="../../js/jquery.onepagenav.js"></script> + <script src="../../js/tree.jquery.js"></script> + <script src="../../js/highlight.pack.js"></script> + <script src="../../js/main.js"></script> + </body> + +</html> + Modified: websites/staging/tomee/trunk/content/tomee-8.0/examples/deltaspike-fullstack.html ============================================================================== --- websites/staging/tomee/trunk/content/tomee-8.0/examples/deltaspike-fullstack.html (original) +++ websites/staging/tomee/trunk/content/tomee-8.0/examples/deltaspike-fullstack.html Sat Sep 7 20:39:03 2019 @@ -95,40 +95,118 @@ <div class="row"> <div class="col-md-12"> - <p>Notice: Licensed to the Apache Software Foundation (ASF) under one<br/> or more contributor license agreements. See the NOTICE file<br/> distributed with this work for additional information<br/> regarding copyright ownership. The ASF licenses this file<br/> to you under the Apache License, Version 2.0 (the<br/> "License"); you may not use this file except in compliance<br/> with the License. You may obtain a copy of the License at<br/> .<br/> <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a><br/> .<br/> Unless required by applicable law or agreed to in writing,<br/> software distributed under the License is distributed on an<br/> "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY<br/> KIND, either express or implied. See the License for the<br/> specific language governing permissions and limitations<br/> under the License.</p> -<h2>Steps to run the example</h2> + <div id="preamble"> +<div class="sectionbody"> +<div class="paragraph"> +<p>Notice: Licensed to the Apache Software Foundation (ASF) under one or +more contributor license agreements. See the NOTICE file distributed +with this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the <code>License''); you may not use this file except in compliance with +the License. You may obtain a copy of the License at . +<a href="http://www.apache.org/licenses/LICENSE-2.0" class="bare">http://www.apache.org/licenses/LICENSE-2.0</a> . Unless required by +applicable law or agreed to in writing, software distributed under the +License is distributed on an </code>AS IS'' BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for +the specific language governing permissions and limitations under the +License.</p> +</div> +<div class="paragraph"> +<p>Steps to run the example</p> +</div> +<div class="paragraph"> <p>Build and start the demo:</p> -<pre><code>mvn clean package tomee:run -</code></pre> +</div> +<div class="literalblock"> +<div class="content"> +<pre>mvn clean package tomee:run</pre> +</div> +</div> +<div class="paragraph"> <p>Open:</p> -<pre><code>http://localhost:8080/ -</code></pre> -<p>This example shows how to improve JSF2/CDI/BV/JPA applications with features provided by Apache DeltaSpike and MyFaces ExtVal.</p> -<h2>Intro of Apache DeltaSpike and MyFaces ExtVal</h2> -<p>The Apache DeltaSpike project hosts portable extensions for Contexts and Dependency Injection (CDI - JSR 299). DeltaSpike is a toolbox for your CDI application. Like CDI itself DeltaSpike is focused on type-safety. It is a modularized and extensible framework. So it's easy to choose the needed parts to facilitate the daily work in your project.</p> -<p>MyFaces Extensions Validator (aka ExtVal) is a JSF centric validation framework which is compatible with JSF 1.x and JSF 2.x. This example shows how it improves the default integration of Bean-Validation (JSR-303) with JSF2 as well as meta-data based cross-field validation.</p> -<h2>Illustrated Features</h2> -<h3>Apache DeltaSpike</h3> -<ul> - <li><a href="./src/main/java/org/superbiz/deltaspike/view/config/Pages.java" target="_blank">Type-safe view-config</a></li> - <li><a href="./src/main/java/org/superbiz/deltaspike/view/InfoPage.java" target="_blank">Type-safe (custom) view-meta-data</a></li> - <li><a href="./src/main/java/org/superbiz/deltaspike/view/MenuBean.java" target="_blank">Type-safe navigation</a></li> - <li><a href="./src/main/java/org/superbiz/deltaspike/CustomProjectStage.java" target="_blank">Type-safe custom project-stage</a></li> - <li><a href="./src/main/java/org/superbiz/deltaspike/view/UserHolder.java" target="_blank">@WindowScoped</a></li> - <li><a href="./src/main/java/org/superbiz/deltaspike/view/MenuBean.java" target="_blank">Controlling DeltaSpike grouped-conversations with GroupedConversationManager</a></li> - <li><a href="./src/main/java/org/superbiz/deltaspike/view/FeedbackPage.java" target="_blank">@GroupedConversationScoped</a></li> - <li><a href="./src/main/java/org/superbiz/deltaspike/view/FeedbackPage.java" target="_blank">Manual conversation handling</a></li> - <li><a href="./src/main/java/org/superbiz/deltaspike/view/security/LoginAccessDecisionVoter.java" target="_blank">Secured pages (AccessDecisionVoter)</a></li> - <li><a href="./src/main/java/org/superbiz/deltaspike/repository/Repository.java" target="_blank">@Transactional</a></li> - <li><a href="./src/main/java/org/superbiz/deltaspike/view/RegistrationPage.java" target="_blank">I18n (type-safe messages)</a></li> - <li><a href="./src/main/java/org/superbiz/deltaspike/domain/validation/UniqueUserNameValidator.java" target="_blank">Dependency-Injection for JSR303 (BV) constraint-validators</a></li> - <li><a href="./src/main/java/org/superbiz/deltaspike/DebugPhaseListener.java" target="_blank">Dependency-Injection for JSF phase-listeners</a></li> -</ul> -<h3>Apache MyFaces ExtVal</h3> -<ul> - <li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">Cross-Field validation (@Equals)</a></li> - <li><a href="./src/main/java/org/superbiz/myfaces/view/RegistrationPage.java" target="_blank">Type-safe group-validation (@BeanValidation) for JSF action-methods</a></li> -</ul> +</div> +<div class="literalblock"> +<div class="content"> +<pre>http://localhost:8080/</pre> +</div> +</div> +<div class="paragraph"> +<p>This example shows how to improve JSF2/CDI/BV/JPA applications with +features provided by Apache DeltaSpike and MyFaces ExtVal.</p> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_intro_of_apache_deltaspike_and_myfaces_extval">Intro of Apache DeltaSpike and MyFaces ExtVal</h3> +<div class="paragraph"> +<p>The Apache DeltaSpike project hosts portable extensions for Contexts and +Dependency Injection (CDI - JSR 299). DeltaSpike is a toolbox for your +CDI application. Like CDI itself DeltaSpike is focused on type-safety. +It is a modularized and extensible framework. So itâs easy to choose the +needed parts to facilitate the daily work in your project.</p> +</div> +<div class="paragraph"> +<p>MyFaces Extensions Validator (aka ExtVal) is a JSF centric validation +framework which is compatible with JSF 1.x and JSF 2.x. This example +shows how it improves the default integration of Bean-Validation +(JSR-303) with JSF2 as well as meta-data based cross-field validation.</p> +</div> +<div class="paragraph"> +<p>Illustrated Features</p> +</div> +<div class="paragraph"> +<p>Apache DeltaSpike</p> +</div> +<div class="paragraph"> +<p>Type-safe view-config</p> +</div> +<div class="paragraph"> +<p>Type-safe (custom) view-meta-data</p> +</div> +<div class="paragraph"> +<p>Type-safe navigation</p> +</div> +<div class="paragraph"> +<p>Type-safe custom project-stage</p> +</div> +<div class="paragraph"> +<p>@WindowScoped</p> +</div> +<div class="paragraph"> +<p>Controlling DeltaSpike grouped-conversations with +GroupedConversationManager</p> +</div> +<div class="paragraph"> +<p>@GroupedConversationScoped</p> +</div> +<div class="paragraph"> +<p>Manual conversation handling</p> +</div> +<div class="paragraph"> +<p>Secured pages (AccessDecisionVoter)</p> +</div> +<div class="paragraph"> +<p>@Transactional</p> +</div> +<div class="paragraph"> +<p>I18n (type-safe messages)</p> +</div> +<div class="paragraph"> +<p>Dependency-Injection for JSR303 (BV) constraint-validators</p> +</div> +<div class="paragraph"> +<p>Dependency-Injection for JSF phase-listeners</p> +</div> +<div class="paragraph"> +<p>Apache MyFaces ExtVal</p> +</div> +<div class="paragraph"> +<p>Cross-Field validation (@Equals)</p> +</div> +<div class="paragraph"> +<p>Type-safe group-validation (@BeanValidation) for JSF action-methods</p> +</div> +</div> </div> </div> Modified: websites/staging/tomee/trunk/content/tomee-8.0/examples/index.html ============================================================================== --- websites/staging/tomee/trunk/content/tomee-8.0/examples/index.html (original) +++ websites/staging/tomee/trunk/content/tomee-8.0/examples/index.html Sat Sep 7 20:39:03 2019 @@ -284,20 +284,24 @@ </ul> </div> <div class="col-md-4"> - <div class="group-title">Webservice</div> + <div class="group-title">Servlet</div> <ul class="group"> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="webservice-ws-with-resources-config.html">Webservice JAX-WS - Resources config</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="async-servlet.html">Async Servlet</a></li> </ul> </div> </div> <div class="row"> <div class="col-md-4"> - <div class="group-title">JMS</div> + <div class="group-title">Webservice</div> <ul class="group"> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="tomee-jms-portability.html">Portability between ActiveMQ and IBM MQ</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="webservice-ws-with-resources-config.html">Webservice JAX-WS - Resources config</a></li> </ul> </div> <div class="col-md-4"> + <div class="group-title">JMS</div> + <ul class="group"> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="tomee-jms-portability.html">Portability between ActiveMQ and IBM MQ</a></li> + </ul> </div> <div class="col-md-4"> </div> @@ -375,30 +379,30 @@ <div class="row"> <div class="col-md-4"> <ul class="group"> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="index.html">index</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="xa-datasource.html">Injection Of Entitymanager</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="java-modules.html">java-modules</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="examples/mp-metrics-gauge.html">mp-metrics-gauge</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="examples/schedule-methods-meta.html">schedule-methods-meta</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="examples/testing-security-meta.html">testing-security-meta</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="vaadin-lts-v08-simple.html">vaadin-lts-v08-simple</a></li> </ul> </div> <div class="col-md-4"> <ul class="group"> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cloud-tomee-azure.html">TomEE deployment on Azure</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="vaadin-lts-v08-simple.html">vaadin-lts-v08-simple</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="vaadin-lts-v10-simple.html">vaadin-lts-v10-simple</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="vaadin-vxx-simple.html">vaadin-vxx-simple</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="examples/webservice-holder.html">webservice-holder</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="examples/webservice-inheritance.html">webservice-inheritance</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="examples/webservice-security.html">webservice-security</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="examples/webservice-ssl-client-cert.html">webservice-ssl-client-cert</a></li> </ul> </div> <div class="col-md-4"> <ul class="group"> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="examples/webservice-security.html">webservice-security</a></li> - <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="examples/webservice-ssl-client-cert.html">webservice-ssl-client-cert</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="pt/examples/webservice-ssl-client-cert.html">webservice-ssl-client-cert</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="examples/webservice-ws-security.html">webservice-ws-security</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="examples/websocket-tls-basic-auth.html">websocket-tls-basic-auth</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="pt/examples/websocket-tls-basic-auth.html">websocket-tls-basic-auth</a></li> </ul> </div> </div> @@ -474,6 +478,7 @@ <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="simple-stateless-callbacks.html">Simple Stateless with callback methods</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="simple-webservice-without-interface.html">Simple Webservice Without Interface</a></li> <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="testing-transactions-bmt.html">Testing Transactions BMT</a></li> + <li class="group-item"><span class="group-item-i" ><i class="fa fa-angle-right"></i></span><a href="cloud-tomee-azure.html">TomEE deployment on Azure</a></li> </ul> </div> </div> Modified: websites/staging/tomee/trunk/content/tomee-8.0/examples/jsf-cdi-and-ejb.html ============================================================================== --- websites/staging/tomee/trunk/content/tomee-8.0/examples/jsf-cdi-and-ejb.html (original) +++ websites/staging/tomee/trunk/content/tomee-8.0/examples/jsf-cdi-and-ejb.html Sat Sep 7 20:39:03 2019 @@ -95,49 +95,119 @@ <div class="row"> <div class="col-md-12"> - <p>The simple application contains a CDI managed bean <code>CalculatorBean</code>, which uses the <code>Calculator</code> EJB to add two numbers and display the results to the user. The EJB is injected in the managed bean using @Inject annotation.</p> -<p>You could run this in the latest Apache TomEE <a href="https://repository.apache.org/content/repositories/snapshots/org/apache/openejb/apache-tomee/">snapshot</a></p> -<p>The complete source code is below but lets break down to look at some smaller snippets and see how it works.</p> + <div id="preamble"> +<div class="sectionbody"> +<div class="paragraph"> +<p>The simple application contains a CDI managed bean <code>CalculatorBean</code>, +which uses the <code>Calculator</code> EJB to add two numbers and display the +results to the user. The EJB is injected in the managed bean using +@Inject annotation.</p> +</div> +<div class="paragraph"> +<p>You could run this in the latest Apache TomEE +<a href="https://repository.apache.org/content/repositories/snapshots/org/apache/openejb/apache-tomee/">snapshot</a></p> +</div> +<div class="paragraph"> +<p>The complete source code is below but lets break down to look at some +smaller snippets and see how it works.</p> +</div> +<div class="paragraph"> <p>A little note on the setup:</p> -<p>As for the libraries, myfaces-api and myfaces-impl are provided in tomee/lib and hence they should not be a part of the war. In maven terms, they would be with scope 'provided'</p> -<p>Also note that we use servlet 2.5 declaration in web.xml<br/><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br/> xmlns="http://java.sun.com/xml/ns/javaee"<br/> xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"<br/> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee<br/> <a href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd</a>"<br/> version="2.5"></p> +</div> +<div class="paragraph"> +<p>As for the libraries, myfaces-api and myfaces-impl are provided in +tomee/lib and hence they should not be a part of the war. In maven +terms, they would be with scope `provided'</p> +</div> +<div class="paragraph"> +<p>Also note that we use servlet 2.5 declaration in web.xml</p> +</div> +<div class="paragraph"> <p>And we use 2.0 version of faces-config</p> -<p><faces-config xmlns="http://java.sun.com/xml/ns/javaee"<br/> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br/> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee<br/> <a href="http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd</a>"<br/> version="2.0"></p> -<p>To make this a cdi-aware-archive (i.e bean archive) an empty beans.xml is added in WEB-INF</p> -<pre><code> <?xml version="1.0" encoding="UTF-8"?> - - <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee - http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> - </beans> -</code></pre> -<p>We'll first declare the FacesServlet in the web.xml</p> -<pre><code> <servlet> +</div> +<div class="paragraph"> +<p>To make this a cdi-aware-archive (i.e bean archive) an empty beans.xml +is added in WEB-INF</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre> <?xml version="1.0" encoding="UTF-8"?> + + <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee + http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> + </beans></pre> +</div> +</div> +<div class="paragraph"> +<p>Weâll first declare the FacesServlet in the web.xml</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> - </servlet> -</code></pre> + </servlet></pre> +</div> +</div> +<div class="paragraph"> <p>FacesServlet acts as the master controller.</p> -<p>We'll then create the calculator.xhtml file.</p> -<pre><code> <h:outputText value='Enter first number'/> - <h:inputText value='#{calculatorBean.x}'/> - <h:outputText value='Enter second number'/> - <h:inputText value='#{calculatorBean.y}'/> - <h:commandButton action="#{calculatorBean.add}" value="Add"/> -</code></pre> -<p>Notice how we've used the bean here. By default, the bean name would be the simple name of the bean class with the first letter in lower case.</p> -<p>We've annotated the <code>CalculatorBean</code> with <code>@RequestScoped</code>. So when a request comes in, the bean is instantiated and placed in the request scope.</p> -<p><h:inputText value='#{calculatorBean.x}'/></p> -<p>Here, getX() method of calculatorBean is invoked and the resulting value is displayed. x being a Double, we rightly should see 0.0 displayed.</p> -<p>When you change the value and submit the form, these entered values are bound using the setters in the bean and then the commandButton-action method is invoked.</p> +</div> +<div class="paragraph"> +<p>Weâll then create the calculator.xhtml file.</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre> <h:outputText value='Enter first number'/> + <h:inputText value='#{calculatorBean.x}'/> + <h:outputText value='Enter second number'/> + <h:inputText value='#{calculatorBean.y}'/> + <h:commandButton action="#{calculatorBean.add}" value="Add"/></pre> +</div> +</div> +<div class="paragraph"> +<p>Notice how weâve used the bean here. By default, the bean name would be +the simple name of the bean class with the first letter in lower case.</p> +</div> +<div class="paragraph"> +<p>Weâve annotated the <code>CalculatorBean</code> with <code>@RequestScoped</code>. So when a +request comes in, the bean is instantiated and placed in the request +scope.</p> +</div> +<div class="paragraph"> +<p>Here, getX() method of calculatorBean is invoked and the resulting value +is displayed. x being a Double, we rightly should see 0.0 displayed.</p> +</div> +<div class="paragraph"> +<p>When you change the value and submit the form, these entered values are +bound using the setters in the bean and then the commandButton-action +method is invoked.</p> +</div> +<div class="paragraph"> <p>In this case, CalculatorBean#add() is invoked.</p> -<p>Calculator#add() delegates the work to the ejb, gets the result, stores it and then returns what view is to be rendered.</p> -<p>The return value "success" is checked up in faces-config navigation-rules and the respective page is rendered.</p> -<p>In our case, 'result.xhtml' page is rendered where use EL and display the result from the request-scoped <code>calculatorBean</code>.</p> -<h1>Source Code</h1> -<h2>CalculatorBean</h2> -<pre><code>import javax.enterprise.context.RequestScoped; +</div> +<div class="paragraph"> +<p>Calculator#add() delegates the work to the ejb, gets the result, stores +it and then returns what view is to be rendered.</p> +</div> +<div class="paragraph"> +<p>The return value <code>success</code> is checked up in faces-config +navigation-rules and the respective page is rendered.</p> +</div> +<div class="paragraph"> +<p>In our case, <code>result.xhtml</code> page is rendered where use EL and display +the result from the request-scoped <code>calculatorBean</code>.</p> +</div> +</div> +</div> +<h1 id="_source_code" class="sect0">Source Code</h1> +<div class="sect1"> +<h2 id="_calculatorbean">CalculatorBean</h2> +<div class="sectionbody"> +<div class="literalblock"> +<div class="content"> +<pre>import javax.enterprise.context.RequestScoped; import javax.inject.Named; import javax.inject.Inject; @@ -176,12 +246,19 @@ public class CalculatorBean { public String add() { result = calculator.add(x, y); - return "success"; + return "success"; } -} -</code></pre> -<h2>Calculator</h2> -<pre><code>package org.superbiz.jsf; +}</pre> +</div> +</div> +</div> +</div> +<div class="sect1"> +<h2 id="_calculator">Calculator</h2> +<div class="sectionbody"> +<div class="literalblock"> +<div class="content"> +<pre>package org.superbiz.jsf; import javax.ejb.Stateless; @@ -191,26 +268,57 @@ public class Calculator{ public double add(double x, double y) { return x + y; } -} -</code></pre> -<h1>web.xml</h1> -<p><?xml version="1.0"?></p> -<p><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br/> xmlns="http://java.sun.com/xml/ns/javaee"<br/> xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"<br/> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee<br/> <a href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd</a>"<br/> version="2.5"></p> -<p><description>MyProject web.xml</description></p> -<p><!-- Faces Servlet --><br/> <servlet><br/> <servlet-name>Faces Servlet</servlet-name><br/> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class><br/> <load-on-startup>1</load-on-startup><br/> </servlet></p> -<p><!-- Faces Servlet Mapping --><br/> <servlet-mapping><br/> <servlet-name>Faces Servlet</servlet-name><br/> <url-pattern>*.jsf</url-pattern><br/> </servlet-mapping></p> -<p><!-- Welcome files --><br/> <welcome-file-list><br/> <welcome-file>index.jsp</welcome-file><br/> <welcome-file>index.html</welcome-file><br/> </welcome-file-list></p> -<p></web-app></p> -<h1>Calculator.xhtml</h1> -<p><?xml version="1.0" encoding="UTF-8"?><br/><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br/>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br/><html xmlns="http://www.w3.org/1999/xhtml"<br/> xmlns:f="http://java.sun.com/jsf/core"<br/> xmlns:h="http://java.sun.com/jsf/html"></p> -<p><h:body bgcolor="white"><br/> <f:view><br/> <h:form><br/> <h:panelGrid columns="2"><br/> <h:outputText value='Enter first number'/><br/> <h:inputText value='#{calculatorBean.x}'/><br/> <h:outputText value='Enter second number'/><br/> <h:inputText value='#{calculatorBean.y}'/><br/> <h:commandButton action="#{calculatorBean.add}" value="Add"/><br/> </h:panelGrid><br/> </h:form><br/> </f:view><br/></h:body><br/></html></p> +}</pre> +</div> +</div> +<div class="paragraph"> +<p>#web.xml</p> +</div> +<div class="paragraph"> +<p>MyProject web.xml</p> +</div> +<div class="paragraph"> +<p>Faces Servlet javax.faces.webapp.FacesServlet 1</p> +</div> +<div class="paragraph"> +<p>Faces Servlet *.jsf</p> +</div> +<div class="paragraph"> +<p>index.jsp index.html</p> +</div> +<div class="paragraph"> +<p>#Calculator.xhtml</p> +</div> +<div class="paragraph"> +<p><!DOCTYPE html PUBLIC <code>-//W3C//DTD XHTML 1.0 Transitional//EN'' +</code><a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd''>" class="bare">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd''></a>;</p> +</div> +<div class="paragraph"> <p>#Result.xhtml</p> -<p><?xml version="1.0" encoding="UTF-8"?><br/><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br/> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br/><html xmlns="http://www.w3.org/1999/xhtml"<br/> xmlns:f="http://java.sun.com/jsf/core"<br/> xmlns:h="http://java.sun.com/jsf/html"></p> -<p><h:body><br/><f:view><br/> <h:form id="mainForm"><br/> <h2><h:outputText value="Result of adding #{calculatorBean.x} and #{calculatorBean.y} is #{calculatorBean.result }"/></h2><br/> <h:commandLink action="back"><br/> <h:outputText value="Home"/><br/> </h:commandLink><br/> </h:form><br/></f:view><br/></h:body><br/></html></p> +</div> +<div class="paragraph"> +<p><!DOCTYPE html PUBLIC <code>-//W3C//DTD XHTML 1.0 Transitional//EN'' +</code><a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd''>" class="bare">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd''></a>;</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre> <h:commandLink action="back"> + <h:outputText value="Home"/> + </h:commandLink> +</h:form></pre> +</div> +</div> +<div class="paragraph"> <p>#faces-config.xml</p> -<p><?xml version="1.0"?><br/> <faces-config xmlns="http://java.sun.com/xml/ns/javaee"<br/> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br/> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee<br/> <a href="http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd</a>"<br/> version="2.0"></p> -<p><navigation-rule><br/> <from-view-id>/calculator.xhtml</from-view-id><br/> <navigation-case><br/> <from-outcome>success</from-outcome><br/> <to-view-id>/result.xhtml</to-view-id><br/> </navigation-case><br/> </navigation-rule></p> -<p><navigation-rule><br/> <from-view-id>/result.xhtml</from-view-id><br/> <navigation-case><br/> <from-outcome>back</from-outcome><br/> <to-view-id>/calculator.xhtml</to-view-id><br/> </navigation-case><br/> </navigation-rule><br/> </faces-config></p> +</div> +<div class="paragraph"> +<p>/calculator.xhtml success /result.xhtml</p> +</div> +<div class="paragraph"> +<p>/result.xhtml back /calculator.xhtml</p> +</div> +</div> +</div> </div> </div> Modified: websites/staging/tomee/trunk/content/tomee-8.0/examples/mp-jwt-bean-validation-strongly-typed.html ============================================================================== --- websites/staging/tomee/trunk/content/tomee-8.0/examples/mp-jwt-bean-validation-strongly-typed.html (original) +++ websites/staging/tomee/trunk/content/tomee-8.0/examples/mp-jwt-bean-validation-strongly-typed.html Sat Sep 7 20:39:03 2019 @@ -98,6 +98,18 @@ <div class="paragraph"> <p>TODO</p> </div> +<div class="admonitionblock caution"> +<table> +<tr> +<td class="icon"> +<i class="fa icon-caution" title="Caution"></i> +</td> +<td class="content"> +This feature has been temporarily removed in <code>master</code> and needs to be reworked. It is anticipated this will complete before Apache TomEE 8.0.0 final. +</td> +</tr> +</table> +</div> </div> </div> Modified: websites/staging/tomee/trunk/content/tomee-8.0/examples/mp-jwt-bean-validation.html ============================================================================== --- websites/staging/tomee/trunk/content/tomee-8.0/examples/mp-jwt-bean-validation.html (original) +++ websites/staging/tomee/trunk/content/tomee-8.0/examples/mp-jwt-bean-validation.html Sat Sep 7 20:39:03 2019 @@ -98,6 +98,18 @@ <div class="paragraph"> <p>TomEE has a fun feature that allows the use of Bean Validation as an alternative or compliment to the <code>@RolesAllowed</code> annotation. The motivation of the feature is that <code>JsonWebToken</code> is effectively a bean and a security check is ultimately an act of producing a boolean result using some minimal input. It is a perfect problem for Bean Validation.</p> </div> +<div class="admonitionblock caution"> +<table> +<tr> +<td class="icon"> +<i class="fa icon-caution" title="Caution"></i> +</td> +<td class="content"> +This feature has been temporarily removed in <code>master</code> and needs to be reworked. It is anticipated this will complete before Apache TomEE 8.0.0 final. +</td> +</tr> +</table> +</div> <div class="paragraph"> <p>The feature ultimately allows you to implement a method like this:</p> </div> Modified: websites/staging/tomee/trunk/content/tomee-8.0/examples/simple-cdi-interceptor.html ============================================================================== --- websites/staging/tomee/trunk/content/tomee-8.0/examples/simple-cdi-interceptor.html (original) +++ websites/staging/tomee/trunk/content/tomee-8.0/examples/simple-cdi-interceptor.html Sat Sep 7 20:39:03 2019 @@ -95,88 +95,157 @@ <div class="row"> <div class="col-md-12"> - <h1>Simple CDI Interceptor</h1> -<p>Let's write a simple application that would allow us to book tickets for a movie show. As with all applications, logging is one cross-cutting concern that we have. </p> -<p>(Relevant snippets are inlined but you can check out the complete code, from the links provided)</p> -<p>How do we mark which methods are to be intercepted ? Wouldn't it be handy to annotate a method like </p> -<pre><code>@Log -public void aMethod(){...} -</code></pre> -<p>Let's create an annotation that would "mark" a method for interception. </p> -<pre><code>@InterceptorBinding + <div class="paragraph"> +<p>Letâs write a simple application that would allow us to book tickets for +a movie show. As with all applications, logging is one cross-cutting +concern that we have.</p> +</div> +<div class="paragraph"> +<p>(Relevant snippets are inlined but you can check out the complete code, +from the links provided)</p> +</div> +<div class="paragraph"> +<p>How do we mark which methods are to be intercepted ? Wouldnât it be +handy to annotate a method like</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@Log +public void aMethod(){...}</pre> +</div> +</div> +<div class="paragraph"> +<p>Letâs create an annotation that would "mark" a method for +interception.</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@InterceptorBinding @Target({ TYPE, METHOD }) @Retention(RUNTIME) public @interface Log { -} -</code></pre> -<p>Sure, you haven't missed the @InterceptorBinding annotation above ! Now that our custom annotation is created, lets attach it (or to use a better term for it, "bind it" ) to an interceptor. </p> -<p>So here's our logging interceptor. An @AroundInvoke method and we are almost done.</p> -<pre><code>@Interceptor +}</pre> +</div> +</div> +<div class="paragraph"> +<p>Sure, you havenât missed the <code>@InterceptorBinding</code> annotation above ! Now +that our custom annotation is created, lets attach it (or to use a +better term for it, "bind it" ) to an interceptor.</p> +</div> +<div class="paragraph"> +<p>So hereâs our logging interceptor. An <code>@AroundInvoke</code> method and we are +almost done.</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@Interceptor @Log //binding the interceptor here. now any method annotated with @Log would be intercepted by logMethodEntry public class LoggingInterceptor { @AroundInvoke public Object logMethodEntry(InvocationContext ctx) throws Exception { - System.out.println("Entering method: " + ctx.getMethod().getName()); - //or logger.info statement + System.out.println("Entering method: " + ctx.getMethod().getName()); + //or logger.info statement return ctx.proceed(); } -} -</code></pre> -<p>Now the @Log annotation we created is bound to this interceptor.</p> -<p>That done, let's annotate at class-level or method-level and have fun intercepting ! </p> -<pre><code>@Log +}</pre> +</div> +</div> +<div class="paragraph"> +<p>Now the <code>@Log</code> annotation we created is bound to this interceptor.</p> +</div> +<div class="paragraph"> +<p>That done, letâs annotate at class-level or method-level and have fun +intercepting !</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>@Log @Stateful public class BookShow implements Serializable { private static final long serialVersionUID = 6350400892234496909L; public List<String> getMoviesList() { List<String> moviesAvailable = new ArrayList<String>(); - moviesAvailable.add("12 Angry Men"); - moviesAvailable.add("Kings speech"); + moviesAvailable.add("12 Angry Men"); + moviesAvailable.add("Kings speech"); return moviesAvailable; } public Integer getDiscountedPrice(int ticketPrice) { return ticketPrice - 50; } // assume more methods are present -} -</code></pre> -<p>The <code>@Log</code> annotation applied at class level denotes that all the methods should be intercepted with <code>LoggingInterceptor</code>.</p> -<p>Before we say "all done" there's one last thing we are left with ! To enable the interceptors ! </p> -<p>Lets quickly put up a [beans.xml file]</p> -<pre><code><beans> +}</pre> +</div> +</div> +<div class="paragraph"> +<p>The <code>@Log</code> annotation applied at class level denotes that all the +methods should be intercepted with <code>LoggingInterceptor</code>.</p> +</div> +<div class="paragraph"> +<p>Before we say "all done" thereâs one last thing we are left with ! To +enable the interceptors !</p> +</div> +<div class="paragraph"> +<p>Lets quickly put up a <code>beans.xml</code> file in <code>META-INF</code></p> +</div> +<div class="literalblock"> +<div class="content"> +<pre><beans> <interceptors> <class>org.superbiz.cdi.bookshow.interceptors.LoggingInterceptor </class> </interceptors> -</beans> -</code></pre> -<p>in META-INF</p> -<p>Those lines in beans.xml not only "enable" the interceptors, but also define the "order of execution" of the interceptors. But we'll see that in another example on multiple-cdi-interceptors.</p> -<p>Fire up the test, and we should see a 'Entering method: getMoviesList' printed in the console.</p> -<h1>Tests</h1> -<pre><code>Apache OpenEJB 4.0.0-beta-2 build: 20111103-01:00 -http://tomee.apache.org/ -INFO - openejb.home = /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors -INFO - openejb.base = /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors -INFO - Using 'javax.ejb.embeddable.EJBContainer=true' -INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service) -INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager) -INFO - Found EjbModule in classpath: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors/target/classes -INFO - Beginning load: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors/target/classes -INFO - Configuring enterprise application: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors -INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container) -INFO - Auto-creating a container for bean cdi-simple-interceptors.Comp: Container(type=MANAGED, id=Default Managed Container) -INFO - Configuring Service(id=Default Stateful Container, type=Container, provider-id=Default Stateful Container) -INFO - Auto-creating a container for bean BookShow: Container(type=STATEFUL, id=Default Stateful Container) -INFO - Enterprise application "/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors" loaded. -INFO - Assembling app: /media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors -INFO - Jndi(name="java:global/cdi-simple-interceptors/BookShow!org.superbiz.cdi.bookshow.beans.BookShow") -INFO - Jndi(name="java:global/cdi-simple-interceptors/BookShow") -INFO - Created Ejb(deployment-id=BookShow, ejb-name=BookShow, container=Default Stateful Container) -INFO - Started Ejb(deployment-id=BookShow, ejb-name=BookShow, container=Default Stateful Container) -INFO - Deployed Application(path=/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors) -Entering method: getMoviesList -</code></pre> +</beans></pre> +</div> +</div> +<div class="paragraph"> +<p>Those lines in <code>beans.xml</code> not only "enable" the interceptors, but also +define the "order of execution" of the interceptors. But weâll see +that in another example on multiple-cdi-interceptors.</p> +</div> +<div class="paragraph"> +<p>Fire up the test, and we should see a <code>Entering method: getMoviesList</code> +printed in the console.</p> +</div> +<div class="literalblock"> +<div class="content"> +<pre>#Tests Apache OpenEJB 4.0.0-beta-2 build: 20111103-01:00 +http://tomee.apache.org/ INFO - openejb.home = +/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors +INFO - openejb.base = +/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors +INFO - Using `javax.ejb.embeddable.EJBContainer=true' INFO - Configuring +Service(id=Default Security Service, type=SecurityService, +provider-id=Default Security Service) INFO - Configuring +Service(id=Default Transaction Manager, type=TransactionManager, +provider-id=Default Transaction Manager) INFO - Found EjbModule in +classpath: +/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors/target/classes +INFO - Beginning load: +/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors/target/classes +INFO - Configuring enterprise application: +/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors +INFO - Configuring Service(id=Default Managed Container, type=Container, +provider-id=Default Managed Container) INFO - Auto-creating a container +for bean cdi-simple-interceptors.Comp: Container(type=MANAGED, +id=Default Managed Container) INFO - Configuring Service(id=Default +Stateful Container, type=Container, provider-id=Default Stateful +Container) INFO - Auto-creating a container for bean BookShow: +Container(type=STATEFUL, id=Default Stateful Container) INFO - +Enterprise application +``/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors'' +loaded. INFO - Assembling app: +/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors +INFO - +Jndi(name=``java:global/cdi-simple-interceptors/BookShow!org.superbiz.cdi.bookshow.beans.BookShow'') +INFO - Jndi(name=``java:global/cdi-simple-interceptors/BookShow'') INFO +- Created Ejb(deployment-id=BookShow, ejb-name=BookShow, +container=Default Stateful Container) INFO - Started +Ejb(deployment-id=BookShow, ejb-name=BookShow, container=Default +Stateful Container) INFO - Deployed +Application(path=/media/fthree/Workspace/open4/openejb/examples/cdi-simple-interceptors) +Entering method: getMoviesList</pre> +</div> +</div> </div> </div> Modified: websites/staging/tomee/trunk/content/tomee-8.0/examples/spring-data-proxy-meta.html ============================================================================== --- websites/staging/tomee/trunk/content/tomee-8.0/examples/spring-data-proxy-meta.html (original) +++ websites/staging/tomee/trunk/content/tomee-8.0/examples/spring-data-proxy-meta.html Sat Sep 7 20:39:03 2019 @@ -95,12 +95,27 @@ <div class="row"> <div class="col-md-12"> - <h1>Spring Data With Meta sample</h1> -<p>This example simply simplifies the usage of spring-data sample providing a meta annotation @SpringRepository to do all the dynamic procy EJB job.</p> + <div class="sect1"> +<h2 id="_spring_data_with_meta_sample">Spring Data With Meta sample</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>This example simply simplifies the usage of spring-data sample providing +a meta annotation <code>@SpringRepository</code> to do all the dynamic proxy EJB job.</p> +</div> +<div class="paragraph"> <p>It replaces @Proxy and @Stateless annotations.</p> -<p>Isn't it more comfortable?</p> -<p>To do it we defined a meta annotation "Metatype" and used it.</p> +</div> +<div class="paragraph"> +<p>Isnât it more comfortable?</p> +</div> +<div class="paragraph"> +<p>To do it we defined a meta annotation <code>`Metatype</code> and used it.</p> +</div> +<div class="paragraph"> <p>The proxy implementation is the same than for spring-data sample.</p> +</div> +</div> +</div> </div> </div> Modified: websites/staging/tomee/trunk/content/tomee-8.0/examples/spring-data-proxy.html ============================================================================== --- websites/staging/tomee/trunk/content/tomee-8.0/examples/spring-data-proxy.html (original) +++ websites/staging/tomee/trunk/content/tomee-8.0/examples/spring-data-proxy.html Sat Sep 7 20:39:03 2019 @@ -95,12 +95,30 @@ <div class="row"> <div class="col-md-12"> - <h1>Spring Data sample</h1> -<p>This example uses OpenEJB hooks to replace an EJB implementation by a proxy to uses Spring Data in your preferred container.</p> -<p>It is pretty simple: simply provide to OpenEJB an InvocationHandler using delegating to spring data and that's it!</p> -<p>It is what is done in org.superbiz.dynamic.SpringDataProxy.</p> -<p>It contains a little trick: even if it is not annotated "implementingInterfaceClass" attribute is injected by OpenEJB to get the interface.</p> + <div class="sect1"> +<h2 id="_spring_data_sample">Spring Data sample</h2> +<div class="sectionbody"> +<div class="paragraph"> +<p>This example uses OpenEJB hooks to replace an EJB implementation by a +proxy to uses Spring Data in your preferred container.</p> +</div> +<div class="paragraph"> +<p>It is pretty simple: simply provide to OpenEJB an InvocationHandler +using delegating to spring data and thatâs it!</p> +</div> +<div class="paragraph"> +<p>It is what is done in <code>org.superbiz.dynamic.SpringDataProxy</code>.</p> +</div> +<div class="paragraph"> +<p>It contains a little trick: even if it is not annotated +<code>implementingInterfaceClass</code> attribute is injected by OpenEJB to get +the interface.</p> +</div> +<div class="paragraph"> <p>Then we simply create the Spring Data repository and delegate to it.</p> +</div> +</div> +</div> </div> </div>