Chris Custine | 9b56f8b | 2009-10-22 15:18:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | * contributor license agreements. See the NOTICE file distributed with |
| 4 | * this work for additional information regarding copyright ownership. |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | * (the "License"); you may not use this file except in compliance with |
| 7 | * the License. You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
Guillaume Nodet | 91fab3b | 2009-04-27 10:01:58 +0000 | [diff] [blame] | 17 | |
Chris Custine | 9b56f8b | 2009-10-22 15:18:51 +0000 | [diff] [blame] | 18 | EMBEDDING KARAF IN A WEB APPLICATION |
| 19 | ==================================== |
| 20 | |
| 21 | Purpose |
| 22 | ------- |
| 23 | Embed Karaf in a web application. |
| 24 | |
| 25 | |
| 26 | Prerequisites for Running the Example |
| 27 | ------------------------------------- |
| 28 | You must have the following installed on your machine: |
| 29 | |
| 30 | - JDK 1.5 or higher |
| 31 | |
| 32 | - Maven 2.0.9 or higher |
| 33 | |
| 34 | |
| 35 | Building and Deploying |
| 36 | ---------------------- |
| 37 | You can build and deploy this example in two ways: |
| 38 | |
| 39 | - A. Using Jetty: Quick and Easy |
| 40 | This option is useful if you want to see the example up and |
| 41 | running quickly. |
| 42 | |
| 43 | - B. Using Your Favorite Web Container |
| 44 | This option is useful if you want to see Karaf running |
| 45 | as a web application inside your favorite web container. |
| 46 | |
| 47 | |
| 48 | A. Using Jetty: Quick and Easy |
| 49 | ------------------------------ |
| 50 | To build the example and deploy to Jetty, complete the |
| 51 | following steps: |
| 52 | |
| 53 | 1. In a command prompt/shell, change to the directory |
| 54 | that contains this README.txt file. |
| 55 | |
| 56 | 2. Enter the following Maven command: |
| 57 | |
| 58 | mvn package jetty:run |
| 59 | |
| 60 | This Maven command builds the example web application, starts |
| 61 | Jetty and deploys the web application to Jetty. Once complete, |
| 62 | you should see the following printed to the console: |
| 63 | |
| 64 | [INFO] Started Jetty Server |
| 65 | [INFO] Starting scanner at interval of 10 seconds. |
| 66 | |
| 67 | Running a Client |
| 68 | ---------------- |
| 69 | To test the example, you can use the Apache Felix Karaf client |
| 70 | to connect to the server and issue a Karaf command. For example, |
| 71 | try executing the "features:list" command as follows: |
| 72 | |
| 73 | 1. In a command prompt/shell, change to your product |
| 74 | installation directory. |
| 75 | |
| 76 | 2. Run the following command: |
| 77 | |
| 78 | java -jar lib/karaf-client.jar features:list |
| 79 | |
| 80 | In this case, you should see output similar to the following: |
| 81 | |
| 82 | [uninstalled] [2.5.6.SEC01 ] spring karaf-${version} |
| 83 | [uninstalled] [1.2.0 ] spring-dm karaf-${version} |
| 84 | [uninstalled] [1.1.0.1-fuse-SNAPSHOT] wrapper karaf-${version} |
| 85 | [uninstalled] [1.1.0.1-fuse-SNAPSHOT] obr karaf-${version} |
| 86 | [uninstalled] [1.1.0.1-fuse-SNAPSHOT] http karaf-${version} |
| 87 | [uninstalled] [1.1.0.1-fuse-SNAPSHOT] webconsole karaf-${version} |
| 88 | [installed ] [1.1.0.1-fuse-SNAPSHOT] ssh karaf-${version} |
| 89 | [installed ] [1.1.0.1-fuse-SNAPSHOT] management karaf-${version} |
| 90 | |
| 91 | |
| 92 | B. Using Your Favorite Web Container |
| 93 | ------------------------------------ |
| 94 | You can deploy the web application to your favorite web |
| 95 | container, by completing the following steps: |
| 96 | |
| 97 | 1. In a command prompt/shell, change to the directory |
| 98 | that contains this README.txt file. |
| 99 | |
| 100 | 2. Enter the following command: |
| 101 | |
| 102 | mvn package |
| 103 | |
| 104 | Maven builds the web application, web-${version}.war, and |
| 105 | saves it in the target directory of this example. Deploy this |
| 106 | WAR file to your favorite web container. Once the application |
| 107 | is running, you can test it using the Apache Felix Karaf client |
| 108 | as described in the "Running a Client" section above. |