Name: sample.javaee7.concurrency
Owner: WASdev
Description: Demonstrates how to use managed executors, managed scheduled executors, and context service to perform tasks in parallel in a simple application.
Created: 2016-02-11 15:17:30.0
Updated: 2017-06-07 21:21:24.0
Pushed: 2017-10-24 21:20:39.0
Size: 112
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This application on demonstrates how to use managed executors, managed scheduled executors and context service to perform tasks in parallel in a simple application.
The sample can be built using Apache Maven. In the directory where you cloned the repository issue the following command to build the source.
$ mvn install
Then, in the same directory issue the following command to run it on a Liberty server.
$ mvn liberty:run-server
You can connect to the application at http://hostname:port/sample.javaee7.concurrency/.
The WebSphere Development Tools (WDT) for Eclipse can be used to control the server (start/stop/dump/etc.), it also supports incremental publishing with minimal restarts, working with a debugger to step through your applications, etc.
WDT also provides:
Installing WDT on Eclipse is as simple as a drag-and-drop, but the process is explained on wasdev.net.
This project can also be built and run with Gradle. The provided build.gradle
file applies the Liberty Gradle Plug-in and is configured to automatically download and install the Liberty Java EE7 Web Profile runtime from Maven Central. The Liberty Gradle Plug-in has built-in tasks that can be used to create, configure, and run the application on the Liberty server.
Use the following steps to run the application with Gradle:
Execute the full Gradle build. The Liberty Gradle Plug-in will download and install the Liberty server.
adle clean build
To start the server with the Servlet sample execute:
adle libertyStart
Alternatively, execute the run command:
adle libertyRun --no-daemon
Once the server has started, the application will be available under http://localhost:9080/sample.javaee7.concurrency/.
adle libertyStop
Please refer to the ci.gradle repository for documentation about using the Liberty Gradle Plug-in.
Configure required resources
Verify that a Derby JDBC Provider instance exists. In the administrative console, click Resources > JDBC > JDBC providers.
If that provider does not exist, create one with a Connection pool datasource implementation type, and point to the Derby.jar file; for example: ${WAS_INSTALL_ROOT}/derby/lib
Verify that a Default datasource instance is configured. Click Resources > JDBC > Data sources.
If that datasource does not exist, create one with the name “Default datasource” and the JNDI name “DefaultDatasource” that points to the Derby JDBC Provider and “${WAS_INSTALL_ROOT}/derby/DefaultDB” database.
To create the actual database, remotely connect to your machine hosting WebSphere Classic using SSH.
Start wsadmin tool with Jython option
Run command
AdminApp.install('<path-to-the-app>/sample.javaee7.concurrency.war','[-node <your-node-name> -server <your-server-name> -appname sample.javaee7.concurrency -contextroot sample.javaee7.concurrency -MapWebModToVH [[ sample.javaee7.concurrency sample.javaee7.concurrency.war,WEB-INF/web.xml default_host ]] -MapResEnvRefToRes [[ sample.javaee7.concurrency "" sample.javaee7.concurrency.war,WEB-INF/web.xml com.ibm.ws.samples.concurrency.ConcurrencySampleServlet/contextService javax.enterprise.concurrent.ContextService wm/default ][ sample.javaee7.concurrency "" sample.javaee7.concurrency.war,WEB-INF/web.xml com.ibm.ws.samples.concurrency.ConcurrencySampleServlet/executor javax.enterprise.concurrent.ManagedScheduledExecutorService wm/default ]]]' )
Save configuration
© Copyright IBM Corporation 2016, 2017.
This information contains sample code provided in source code form. You may copy, modify, and distribute these sample programs in any form without payment to IBM for the purposes of developing, using, marketing or distributing application programs conforming to the application programming interface for the operating platform for which the sample code is written.
Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN “AS IS” BASIS AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR ECONOMIC CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE SAMPLE SOURCE CODE. IBM SHALL NOT BE LIABLE FOR LOSS OF, OR DAMAGE TO, DATA, OR FOR LOST PROFITS, BUSINESS REVENUE, GOODWILL, OR ANTICIPATED SAVINGS. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS TO THE SAMPLE SOURCE CODE.