Difference between revisions of "Opentaps-osgi"
m (→Conclusion) |
|||
(15 intermediate revisions by 2 users not shown) | |||
Line 29: | Line 29: | ||
== Get Started Quickly == | == Get Started Quickly == | ||
+ | This quick start section is based on ( http://springosgi.googlepages.com/ ) article. | ||
To get you started please take the following steps: | To get you started please take the following steps: | ||
=== Get your environment ready === | === Get your environment ready === | ||
− | + | If you use eclipse, you can use the following tools: | |
* eclipse JEE 3.5 Galileo | * eclipse JEE 3.5 Galileo | ||
− | * subclipse SVN eclipse plugin that works with m2eclipse maven eclipse plugin | + | * subclipse SVN eclipse plugin that works with m2eclipse maven eclipse plugin from <tt> http://subclipse.tigris.org/update_1.6.x</tt> |
− | * m2eclipse maven eclipse plugin | + | * m2eclipse maven eclipse plugin from <tt>http://m2eclipse.sonatype.org/update/</tt> |
+ | ** If you have problems with this checkout, such as for example the following error message: | ||
+ | <pre> | ||
+ | Cannot find a solution satisfying the following requirements org.eclipse.ui [3.4.2.M20090204-0800]. | ||
+ | </pre> | ||
+ | Then just get the Maven Integration package and Maven SCM Handler for Subclipse. This problem is discussed on [http://www.mail-archive.com/user@m2eclipse.codehaus.org/msg04111.html m2eclipse-users mailing list] | ||
* java sdk 1.6.0_14 | * java sdk 1.6.0_14 | ||
+ | |||
+ | Alternatively, you can download subversion and maven and do this manually from the command line. | ||
=== Checkout the code === | === Checkout the code === | ||
+ | If you are using eclipse: | ||
* start eclipse and create a new workspace | * start eclipse and create a new workspace | ||
* open SVN Repository Exploring perspective | * open SVN Repository Exploring perspective | ||
* Add SVN Repository: svn://svn.opentaps.org/opentaps | * Add SVN Repository: svn://svn.opentaps.org/opentaps | ||
− | * File -> Import -> Maven -> Checkout as Maven project from SCM< | + | * File -> Import -> Maven -> Checkout as Maven project from SCM. Use the parameters: |
− | + | <pre> | |
− | + | SCM: svn | |
− | * click Finish button | + | URL: svn://svn.opentaps.org/opentaps/branches/danutc-2.0/org.opentaps.osgi/trunk/ |
− | + | </pre> | |
− | + | * click Finish button. This will start the import from SVN, which could take a while. | |
− | catalina.config | + | |
− | catalina.start.osgi.config | + | After the import is finished switch to JEE perspective; you should see the following projects: |
− | lib | + | <pre> |
− | log4j.config | + | apps |
− | opentaps-erp-crm | + | catalina.config |
− | platform | + | catalina.start.osgi.config |
− | reverser | + | lib |
− | reverser-client.war | + | log4j.config |
+ | opentaps-erp-crm | ||
+ | platform | ||
+ | reverser | ||
+ | reverser-client.war | ||
sample | sample | ||
− | + | </pre> | |
+ | |||
+ | The projects are already connected to svn | ||
+ | |||
+ | Or, from the commandline: | ||
+ | <pre> | ||
+ | $ svn co svn://svn.opentaps.org/opentaps/branches/danutc-2.0/org.opentaps.osgi/trunk/ | ||
+ | </pre> | ||
=== Build the Projects === | === Build the Projects === | ||
+ | From eclipse: | ||
* open opentaps-erp-crm | * open opentaps-erp-crm | ||
* right click on pom.xml and select Run As Maven build ... | * right click on pom.xml and select Run As Maven build ... | ||
− | * | + | * On the "Edit Configuration" screen, enter <tt>clean compile package install</tt> for Goals |
* click Apply then Run buttons | * click Apply then Run buttons | ||
* the first time the build will take long time as it downloads all dependencies from Internet | * the first time the build will take long time as it downloads all dependencies from Internet | ||
* after BUILD SUCCESSFUL message on console select all projects and refresh them to be in synch with the build | * after BUILD SUCCESSFUL message on console select all projects and refresh them to be in synch with the build | ||
* in the problem window eclipse reports errors that will be fixed as soon as we configure the environment | * in the problem window eclipse reports errors that will be fixed as soon as we configure the environment | ||
+ | |||
+ | From the commandline: | ||
+ | |||
+ | First you need to build the "reverser" sample application, which you can do by: | ||
+ | <pre> | ||
+ | $ cd opentaps-erp-crm/sample/reverser/ | ||
+ | $ mvn clean | ||
+ | $ mvn install | ||
+ | </pre> | ||
+ | This will cause "reverser" to be packaged in your user's .m2/ directory. | ||
+ | |||
+ | Then, go back to the <tt>opentaps-erp-crm</tt> directory and use maven again: | ||
+ | <pre> | ||
+ | $ cd opentaps-erp-crm | ||
+ | $ mvn clean | ||
+ | $ mvn compile | ||
+ | $ mvn package | ||
+ | $ mvn install | ||
+ | </pre> | ||
=== Configure the OSGi Environment === | === Configure the OSGi Environment === | ||
Line 91: | Line 131: | ||
* there are 5 workspace projects and 49 Target Platform plug-ins selected | * there are 5 workspace projects and 49 Target Platform plug-ins selected | ||
* click Validate Bundles button and there should be no problems found (make sure all bundles are selected) | * click Validate Bundles button and there should be no problems found (make sure all bundles are selected) | ||
+ | * select the start level 5 for org.springframework.osgi.web.extender; this ensures that the extender starts after Tomcat is started (the default start level is 4) | ||
* click Run button and watch the console window for logs | * click Run button and watch the console window for logs | ||
* focus on console window and type ss to see the list of active bundles (notice catalina, reverser and reverser-client) | * focus on console window and type ss to see the list of active bundles (notice catalina, reverser and reverser-client) | ||
Line 98: | Line 139: | ||
* it displays the reversed string (also watch the console window) | * it displays the reversed string (also watch the console window) | ||
* click on browser back button and enter a new string | * click on browser back button and enter a new string | ||
+ | |||
+ | From commandline: | ||
+ | |||
+ | First start the osgi console: | ||
+ | <pre> | ||
+ | $ cd opentaps-erp-crm | ||
+ | $ cd platform/target/platform | ||
+ | $ java -jar org.eclipse.osgi-3.5.0.200811061137.jar -console | ||
+ | </pre> | ||
+ | |||
+ | From the console, you can always get a list of the available commands with: | ||
+ | <pre> | ||
+ | osgi> help | ||
+ | </pre> | ||
+ | |||
+ | Now you can load your bundles. To load bundles from files, you would need the full path, like this: | ||
+ | <pre> | ||
+ | osgi> install file:///Users/sichen/IdeaProjects/osgi/opentaps-erp-crm/platform/target/platform/org.springframework.osgi.web.extender-1.1.3.RELEASE.jar | ||
+ | Bundle id is 6 | ||
+ | </pre> | ||
+ | |||
+ | You need to load '''all''' the jars in your <tt>opentaps-erp-crm/platform/target/platform/</tt> directory with <tt>install</tt>, plus the following files, again with the full path: | ||
+ | <pre> | ||
+ | osgi> install file:///Users/sichen/IdeaProjects/osgi/opentaps-erp-crm/sample/reverser/target/org.opentaps.osgi.sample.reverser-0.0.1-SNAPSHOT.jar | ||
+ | osgi> install file:///Users/sichen/IdeaProjects/osgi/opentaps-erp-crm/sample/reverser-client.war | ||
+ | </pre> | ||
+ | |||
+ | Then you need to start '''all''' the bundles with the <tt>start</tt> command: | ||
+ | <pre> | ||
+ | osgi> start 6 | ||
+ | |||
+ | osgi> start 7 | ||
+ | </pre> | ||
+ | |||
+ | You just need to start them once. Next time you start the console, they should be started already. | ||
+ | |||
+ | To set the start level: | ||
+ | <pre> | ||
+ | osgi> setbsl 5 6 | ||
+ | Bundle 6 Start Level = 5 | ||
+ | </pre> | ||
=== Software Maintenance === | === Software Maintenance === |
Latest revision as of 22:18, 27 October 2009
This page provides information about projects at:
svn://svn.opentaps.org/opentaps/branches/danutc-2.0/org.opentaps.osgi
What is opentaps-osgi?
We aim to migrate ofbiz and opentaps to a more modern architecture based on:
- OSGi
- BPM
- ESB
- SCA
It appears that many open source products have been migrated to OSGi. To take full advantage of these products would be desirable to have opentaps and ofbiz restructured as OSGi modules.
Also migration to OSGi enables better architecture and more agile development. I make these statements based on information available on Internet.
In current build the following features are deployed and illustrated:
- Eclipse Equinox OSGi
- Spring DM (Dynamic Modules for OSGi development) and Spring Core
- Tomcat
- full maven build
- Eclipse PDE development
- OSGi Platform maven project build
- OSGi Extension Projects: log4j configuration, catalina configuration, catalina.start.osgi configuration
- Sample OSGi Service using Spring DM
- Sample Web Application that uses the service above
Get Started Quickly
This quick start section is based on ( http://springosgi.googlepages.com/ ) article.
To get you started please take the following steps:
Get your environment ready
If you use eclipse, you can use the following tools:
- eclipse JEE 3.5 Galileo
- subclipse SVN eclipse plugin that works with m2eclipse maven eclipse plugin from http://subclipse.tigris.org/update_1.6.x
- m2eclipse maven eclipse plugin from http://m2eclipse.sonatype.org/update/
- If you have problems with this checkout, such as for example the following error message:
Cannot find a solution satisfying the following requirements org.eclipse.ui [3.4.2.M20090204-0800].
Then just get the Maven Integration package and Maven SCM Handler for Subclipse. This problem is discussed on m2eclipse-users mailing list
- java sdk 1.6.0_14
Alternatively, you can download subversion and maven and do this manually from the command line.
Checkout the code
If you are using eclipse:
- start eclipse and create a new workspace
- open SVN Repository Exploring perspective
- Add SVN Repository: svn://svn.opentaps.org/opentaps
- File -> Import -> Maven -> Checkout as Maven project from SCM. Use the parameters:
SCM: svn URL: svn://svn.opentaps.org/opentaps/branches/danutc-2.0/org.opentaps.osgi/trunk/
- click Finish button. This will start the import from SVN, which could take a while.
After the import is finished switch to JEE perspective; you should see the following projects:
apps catalina.config catalina.start.osgi.config lib log4j.config opentaps-erp-crm platform reverser reverser-client.war sample
The projects are already connected to svn
Or, from the commandline:
$ svn co svn://svn.opentaps.org/opentaps/branches/danutc-2.0/org.opentaps.osgi/trunk/
Build the Projects
From eclipse:
- open opentaps-erp-crm
- right click on pom.xml and select Run As Maven build ...
- On the "Edit Configuration" screen, enter clean compile package install for Goals
- click Apply then Run buttons
- the first time the build will take long time as it downloads all dependencies from Internet
- after BUILD SUCCESSFUL message on console select all projects and refresh them to be in synch with the build
- in the problem window eclipse reports errors that will be fixed as soon as we configure the environment
From the commandline:
First you need to build the "reverser" sample application, which you can do by:
$ cd opentaps-erp-crm/sample/reverser/ $ mvn clean $ mvn install
This will cause "reverser" to be packaged in your user's .m2/ directory.
Then, go back to the opentaps-erp-crm directory and use maven again:
$ cd opentaps-erp-crm $ mvn clean $ mvn compile $ mvn package $ mvn install
Configure the OSGi Environment
We need to install the OSGi Platform in PDE.
- Window -> Preferences -> Plug-in Development -> Target Platform click Add... button
- Nothing: Start with empty target definition the click Next button
- click Add button to add a new location
- select Installation then click Next
- location: ${workspace_loc}/opentaps-erp-crm/platform/target/platform and click Next
- You should see a list of 49 plug-ins that are loaded from platform project; click Finish and Finish
- Select New Target Platform check box and click Apply button then OK button
- Now in the Problems window all compilation errors should be gone; there are some XML errors that are not important
Run the Platform
- click on Run Configurations... drop down menu
- select OSGi Framework and click New
- Name: opentaps-osgi
- there are 5 workspace projects and 49 Target Platform plug-ins selected
- click Validate Bundles button and there should be no problems found (make sure all bundles are selected)
- select the start level 5 for org.springframework.osgi.web.extender; this ensures that the extender starts after Tomcat is started (the default start level is 4)
- click Run button and watch the console window for logs
- focus on console window and type ss to see the list of active bundles (notice catalina, reverser and reverser-client)
- type status to see more comprehensive information
- in browser go to http://localhost:8888/reverser-client/
- enter a string and click Reverse String button
- it displays the reversed string (also watch the console window)
- click on browser back button and enter a new string
From commandline:
First start the osgi console:
$ cd opentaps-erp-crm $ cd platform/target/platform $ java -jar org.eclipse.osgi-3.5.0.200811061137.jar -console
From the console, you can always get a list of the available commands with:
osgi> help
Now you can load your bundles. To load bundles from files, you would need the full path, like this:
osgi> install file:///Users/sichen/IdeaProjects/osgi/opentaps-erp-crm/platform/target/platform/org.springframework.osgi.web.extender-1.1.3.RELEASE.jar Bundle id is 6
You need to load all the jars in your opentaps-erp-crm/platform/target/platform/ directory with install, plus the following files, again with the full path:
osgi> install file:///Users/sichen/IdeaProjects/osgi/opentaps-erp-crm/sample/reverser/target/org.opentaps.osgi.sample.reverser-0.0.1-SNAPSHOT.jar osgi> install file:///Users/sichen/IdeaProjects/osgi/opentaps-erp-crm/sample/reverser-client.war
Then you need to start all the bundles with the start command:
osgi> start 6 osgi> start 7
You just need to start them once. Next time you start the console, they should be started already.
To set the start level:
osgi> setbsl 5 6 Bundle 6 Start Level = 5
Software Maintenance
Change the reverser OSGi Service
- type ss in console window and note the bundle numbers for reverser and reverser-client bundles (4 and 25 in my current run)
- in reverser project go and modify reverse method in org.springframework.osgi.sample.service.impl.StringReverserImpl
return " >>> " + reveresed;
- save the file
- notice that the web application did not pick the change yet (try to reverse more strings)
- in console window type "refresh 4" where 4 in my case is the bundle number for reverser OSGi service
- try to reverse more strings and notice that the message on screen reflects your change
Change the reverser-client Web Application
- do a change in file reverser-client.war\src\main\webapp\index.jsp
- please note that the change is not activated yet
- right click on reverser-client.war/pom.xml and select Run As... -> Maven Build ...
- Goals: clean compile package install
- click Apply and Run buttons
- in osgi console window type "refresh 25" where 25 in my case is the bundle number for reverser-client web application
- note that your change is now reflected on page in browser (refresh the page as it may be cached)
Conclusion
- we have a full OSGi developmet environment working
- the roundtrip for sofware maintenance changes is very short as we need to refresh only the component we changed (we do not need to restart the whole platform)
- we have a solid maven build
- it works for me and I did not encountered any problems so far
- I am ready to move forward