1. First knowledge of osgi
Osgi features: Hot swapping and modular programming. It seems very attractive, but if you are a beginner, I think you will be suffering from a lot of problems at the beginning. Many concepts need to be understood, and many mistakes are just ClassNoFinded, you may be bored. There are also so many annoying configurations when constructing an osgi project (for details about how to build an eclipse-based osgi application, refer to Lin Hao's open doc, of course, you can also buy the OSGi principle and best practice he wrote. I personally feel a little old, but as a beginner, without other better Chinese materials, still worth reading)
2. osgi application debugging and release
After a period of understanding of OSGi, it is easy to build, debug, and release OSGi applications. Maven-bundle-plugin can be used for building. This maven plug-in can be used for debugging.
For more information, see the following example:
Http://www.ops4j.org/projects/pax/construct/
Release: I use glassfish3 here. glassfish itself is a basic OSGi web Application server and provides support for Web Application Bundle (WAB), which is part of OSGi specification 4.2. You can easily publish web applications.
After downloading glassfish3, start it with bin/asadmin. bat and enter start-domain.
Open http: // 127.0.0.1: 8080 to view the glassfish document page.
Http: // 127.0.0.1: 4848 is the Management page
If everything goes well, you can copy the bundle you made to domains/domain1/autodeploy/bundles to release your bundle. If it still doesn't work,
You also need to perform the following operations (this problem does not exist for the latest version ):
asadmin delete-jvm-options --target server-config -Dorg.glassfish.additionalOSGiBundlesToStart=org.apache.felix.shell,org.apache.felix.gogo.runtime,org.apache.felix.gogo.shell,org.apache.felix.gogo.command
asadmin create-jvm-options --target server-config -Dorg.glassfish.additionalOSGiBundlesToStart=org.apache.felix.shell,org.apache.felix.gogo.runtime,org.apache.felix.gogo.shell,org.apache.felix.gogo.command,org.apache.felix.shell.remote,org.apache.felix.fileinstall
In this way, you can directly copy your bundle
Domains/domain1/autodeploy/bundles,
How can I view the status of your released bundle?
Cmd
Telnet local host 6666
It is equivalent to opening the felix Console (glassfish is based on felix by default)
In this case, you can enter help to view available commands,
Common Commands include:
You can add-l to the bundle list to display the position of the bundle.
Start n starts a bundle n as the bundle id .. You can see this number in the ps command.
Stop n stop a bundle
Install url to install a bundle
Update n update a bundle
For the help of a single command, you can use help ps
More articles worth your reference include:
Http://blogs.oracle.com/arungupta/entry/osgi_application_development_using_glassfish
Http://netbeans.org/kb/docs/javaee/maven-osgiservice-cdi.html? Intcmp = 1, 925655
This article is not original. For more information, see the source and share my happiness with you.
Http://www.cnblogs.com/weirhp