$ git clone https://github.com/WASdev/sample.async.websockets.gitApache Maven commands
$ mvn installYou can skip tests with the following:
$ mvn install -DskipTests=trueIn addition to publishing the WAR to the local Maven repository, the built WAR file is copied into the apps directory of the server configuration located in the async-websocket-wlpcfg directory:
async-websocket-wlpcfg
+- target
+- async-websocket-wlpcfg-1.0.zip <-- packaged server file containing the server, application, and configuration
+- wlp
+- usr
+- server
+- websocketSample
+- server.xml <-- server configuration
+- apps <- directory for applications
+- async-websocket-application.war <- sample application
+- logs <- created by running the server locally
+- workarea <- created by running the server locally
Change the current directory to the async-websocket-wlpcfg sub-project, and use the following commands to start the server and run the application:
To run the server in the foreground:
$ mvn liberty:run-serverTo run the server in a background process:
$ mvn liberty:start-serverTo stop the server:
$ mvn liberty:stop-serverThis 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 EE 7 Full Platform 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 the Gradle wrapper (Windows machines use gradlew.bat):
- Execute the full Gradle build. The Liberty Gradle Plug-in will download and install the Liberty server.
$ ./gradlew clean build
async-websocket-wlpcfg
+- build
+- wlp
+- usr
+- servers
+- websocketSample
+- server.xml <-- server configuration
+- apps <-- directory for applications
+- async-websocket-application <-- the websocket application
+- logs <-- created by running the server locally
+- workarea <-- created by running the server locally
-
To start the server with the Websocket sample execute:
$ ./gradlew libertyStart
Alternatively, execute the run command:
$ ./gradlew libertyRun --no-daemon
Once the server has started, the application will be available under http://localhost:9082/websocket/.
- To stop the server, execute:
$ ./gradlew libertyStop
Note, if Gradle is properly installed, Gradle commands can be executed directly using gradle and wouldn't require gradlew.
Please refer to the Liberty Gradle Plug-in repository for documentation about using the Liberty Gradle Plug-in.