We introduced the most basic environment (STS+VIRGO) needed to develop a modular web in Java, and this section describes how to integrate snaps into Virgo and demonstrate several official demos. 1. Preliminary knowledge
What snaps is.
You can refer to http://osgi.com.cn/article/7289354. 2. Integrated snaps
First, we go into http://www.eclipse.org/virgo/download/and download Virgo snaps.
Download and extract the directory structure as follows:
Below we integrate snaps System into the Virgo Tomcat server. Step One:
The Dist directory contains snaps-related jar packs, and we copy all of the contents of the directory to ${SERVER_HOME}/REPOSITORY/USR (${server_home} is the root path of the Virgo SERVER you installed on your computer, such as F : \VIRGO-TOMCAT-SERVER-3.6.2.RELEASE\REPOSITORY\USR) and the ${server_home}/repository/ext directory.
Step Two:
Modify the file ${server_home}/configuration/org.eclipse.virgo.kernel.userregion.properties, append repository:plan/to the end of the file Org.eclipse.virgo.snaps (that is, assigning to the right of the initialartifacts) enables Virgo server to load our integrated snaps-related functionality at startup.
Step Three:
Check that our integrated snaps feature is in effect and launch our Virgo Server in Sts. Check the output information in the console, and if the configuration is installed correctly, the information shown in the following illustration will be printed.
After successfully integrating the snaps, we will then deploy the official demo to Virgo server.
We started Virgo Server in the STS IDE, opened the browser input http://localhost:8080/and entered the admin page.
Click the Artifacts tab to enter the Deployment page.
Add the jar package under the sample folder, then click Deploy.
When you click Deploy, the deployment results pop up and why you have an error. Careful observation, it is not difficult to find that there is a bundle version of the problem.
Note: This problem arises because the Virgo snaps official demo jar file was not modified in time for the updated version.
How to solve this problem.
Take the example of modifying Org.eclipse.virgo.snaps.sample.animal-3.6.2.release.jar.
Open the jar pack with RAR software, open the Meta-inf directory, modify the MANIFEST.MF file, modify 3.1 to 4, and save the changes.
Once the modifications are complete, redeploy the Org.eclipse.virgo.snaps.sample.animal-3.6.2.release.jar.
The results of the correct deployment are ejected.
Other jar package modification methods are similar, here are slightly.
After successfully deploying our Host-bundle, the STS console outputs <SN0000I> Host created for path '/animal-menu-bar '
This indicates that the host has been loaded and installed into our Virgo snaps container, open the browser, visit the http://localhost:8080/animal-menu-bar/to see the effect.
OK, and then we'll deploy the remaining 3 jars to the Virgo snaps container in turn.
Deployment method with animal, here skip, directly on the effect diagram.
After successfully deploying dog, console output <SN0010I> Snap bound to path '/animal-menu-bar/dog '
Next refresh the http://localhost:8080/animal-menu-bar/page.
found that at this time more dog this link.
Click on the dog link to see a very lovely dog.
3. Summary
The official demo shows that animal is host, and dog, Blue, and cat are snap, that is, snap is attach (attached) on the host. Snap cannot be run alone and must depend on a unique host. We can view dog, blue, cat and other jars as the new modules we develop, and when deploying new modules, we do not need to restart the server, as the example shows, dynamically installing the jar on the Virgo Server Management page for hot-swappable and dynamic deployment. This is much more flexible and scalable than the traditional approach, and reduces the impact and loss of server downtime by not having to worry about stopping servers as a result of upgrading or adding new modules.