Virgo and Maven integrated development environment construction (1)

        OSGI technology is gradually being used in the development of Internet applications. We will not discuss how OSGI, the familiar Equinox and Felix, are used here. Java Web application development, what is discussed here is a relatively new solution - Eclipse Virgo .

        Eclipse Virgo encapsulates OSGI again, and the bottom layer uses Equinox. Some friends know that the OSGI part of Eclipse Virgo is Spring-DM. Yes, Virgo was first developed by Spring, and Spring extended tomcat to make the container a An OSGI-Web application server integrating OSGI container and Web container. Later donated to Eclipse and renamed Eclipse Virgo.

        Today I'm here to introduce how to add OSGI capabilities to our web development to make our applications modular and dynamic.

        First of all, let's look at how to build our development environment. We will use Virgo and Maven here. Assuming that the friends who read this introduction are already familiar with Maven, because our focus is not on Maven, so skip it. We focus on how Virgo is configured and how it integrates with Maven.

         一、Virgo-tomcat-server 3.5.0-RELEASE

                     1. Installation

                          Download address: http://www.eclipse.org/downloads/download.php?file=/virgo/release/VTS/3.5.0.RELEASE/virgo-tomcat-server-3.5.0.RELEASE.zip

                      2. Associate Maven

                           Modify ${virgo_home}/configuration/org.eclipse.virgo.repository.properties to increase the location of the local maven repository

 

ext.type=external
ext.searchPattern=repository/ext/{artifact}
usr.type=watched
usr.watchDirectory=repository/usr
mvn.type=external
mvn.searchPattern=${user.home}/.m2/repository/**/{bundle}.jar
chain=ext,usr,mvn

                           The startup load order of Virgo is: plugins, repository/ext, repository/usr, mvn. Note that we are talking about the development environment here, so you need to configure maven. If it is a network environment, there is no maven. Then you only need to put all bundles and dependent third-party bundles in repository/usr/.

                      3. Open the userregion osgi console

                                  Modify ${virgo_home}/repository/ext/osgi.console.properties. Open the userregion console

                       

telnet.enabled=true
telnet.port=2501
telnet.host=localhost
ssh.enabled=true
ssh.port=2502
ssh.host=localhost

                                   You can log in to the osgi console through ssh admin@localhost -p 2502 Default password:                                    use telnet localhost 2501 to log in to the osgi console under
                                   springsources windows

                      4. Add snaps support to virgo

                              Introducing snaps. Virgo supports OSGI's WAB (web application bundle) specification. An application is composed of many bundles, but one bundle is the host. The general context of the application should be configured in this host: demo. The bundles of other web modules, assuming that one module is the user management user, and the other is the role. Then our final request path is http://localhost:8080/demo/user/xxx.html or http://localhost:8080/demo/role/xxx.html. This is the Host-Snap concept. An OSGI-Web application has one host and N Snaps divided by modules. Here we need to use Virgo's snaps support to load it first and serve us as a userregion capability.

                              Create a file org.eclipse.virgo.snaps.plan under ${virgo_home}/repository/ext/ with the content:

 

<plan name="org.eclipse.virgo.snaps" version="3.0.0" scoped="false" atomic="true"
                xmlns="http://www.springsource.org/schema/dm-server/plan"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://www.springsource.org/schema/dm-server/plan
                     http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">

        <artifact type="bundle" name="org.eclipse.virgo.snaps.api" version="[3, 4)"/>
        <artifact type="bundle" name="org.eclipse.virgo.snaps.core" version="[3, 4)"/>

</plan>

 

                                 Modify the ${virgo_home}/configuration/org.eclipse.virgo.kernel.userregion.properties file and add at the end of the file:

initialArtifacts=repository:plan/org.eclipse.virgo.kernel.userregion.springdm, repository:plan/org.eclipse.virgo.web.tomcat, repository:plan/org.eclipse.virgo.snaps

                          5. Start

                                 We are using Virgo3.5.0, which uses spring version 3.0.5.RELEASE. So, make sure that there are no other versions of spring in the mvn local repository, only the 3.0.5.RELEASE version exists. Otherwise, there will be a package conflict, causing virgo to fail to start.

                                 Startup in debug state: ./startup.sh -clean -debug

                                 After the startup is successful, visit http://localhost:8080/admin to view the osgi environment and bundle deployment
Username/password: admin/springsource

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326860198&siteId=291194637