Opentaps-osgi

From Opentaps Wiki
Revision as of 07:48, 21 July 2009 by Danutc (talk | contribs) (Configure the OSGi Environment)
Jump to navigationJump to search

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

To get you started please take the following steps:

Get your environment ready

I use the following tools:

Checkout the code

  • 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

- SCM URL: svn
- svn://svn.opentaps.org/opentaps/branches/danutc-2.0/org.opentaps.osgi/trunk

  • click Finish button
  • 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

Build the Projects

  • open opentaps-erp-crm
  • right click on pom.xml and select Run As Maven build ...
  • Goals: clean compile package install
  • 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

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)
  • 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 a 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

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 compnent we changes (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