Difference between revisions of "ADempiere/Equinox Integration 2"

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.
(preparing the change of more complete documentation at OSGI Hengsin)
 
(39 intermediate revisions by 6 users not shown)
Line 1: Line 1:
Approach 2: Embedding ADempiere in Equinox
+
Approach 2: Embedding ADempiere in Equinox done by [[User:Viola|Joerg Viola]].
 +
However, the OSGI '''Project is undergoing revamp by [[OSGI HengSin|Heng Sin]]''' and is almost beta at this stage. Thus this page is only a reference point for academic reference until documentation of the new project becomes more complete there. - [[User:Red1|Redhuan D. Oon]]
  
[[Image:Pluginlist.png]]
+
[[Image:Pluginlist.png|440px|thumb|ADempiere is getting pluggable like the Eclipse framework!]]
  
 
= Status: Alpha Code - Review required =
 
= Status: Alpha Code - Review required =
  
 +
* Current release tag: 4.0.0pr01
 
* Swing client can be fired up inside equinox.
 
* Swing client can be fired up inside equinox.
 
* very few tests applied
 
* very few tests applied
 
* Webstart has been fired up with equinox.
 
* Webstart has been fired up with equinox.
 
* zkwebui runs inside OSGi through equinox servlet bridge
 
* zkwebui runs inside OSGi through equinox servlet bridge
* Development environment setup automated as far as reasonable
+
* deployment now integrated in the standard adempiere setup!
* Currently, deployment is in no way integrated in the standard adempiere setup!
+
** currently only swing standalone and zkwebui accessible
 +
** webstart has to be packed in a war for deploying in any web container
  
 
= Setup =
 
= Setup =
  
* Code is in https://adempiere.svn.sourceforge.net/svnroot/adempiere/branches/osgi/approach2 - this is a "real" svn branch - check it out!
+
* Code is in http://adempiere.svn.sourceforge.net/svnroot/adempiere/branches/osgi/approach2 - check it into your IDE.
 
* Use multiple project setup
 
* Use multiple project setup
** Simple trick on slow sf.net to get into multiple project setup: Do one checkout, rename top-level .project file, import projects into workspace
+
** Simple trick on slow sf.net to get into multiple project setup: Do one checkout, rename top-level .project file to make it give way to all the sub-projects.
 +
**Accept OK to import all projects into workspace.
  
 
== Eclipse setup ==
 
== Eclipse setup ==
Line 28: Line 32:
  
 
== Development Environment ==
 
== Development Environment ==
* cd to equinox target and say "ant"
+
 
** This won't build anything but instead set up three development platforms under the folder "dist":
+
* Use the standard ADempiere deployment:  
** dist/standalone is an (empty) Equinox 3.5.0-Container runtime
+
** cd utils_dev
** dist/webstart is a webapp containing the JNLP and jars for the web-started app
+
./RUN_build.sh
** dist/web is an (empty) servlet-bridge accessible Equinox 3.5.0-Container webapp.
+
* This creates and adempiere/Adempiere installation with a new "osgi" folder. This is the OSGi container platform
* After having these successfully set up, you have to deploy the adempiere plugins into these environments
+
* For updating a modified plug-in, use
 +
./RUN_plugin.sh <name of plugin project>
  
 
== Swing Standalone ==
 
== Swing Standalone ==
  
* Open '''base/META-INF/MANIFEST.MF''', press the "export deployable plugins and fragments" icon in the top-right corner
+
* Use the standard ./RUN_ADempiere.sh in deploy directory
* select the plugins base, client and tools.
+
* choose equinox-target/dist/standalone as the output directory
+
* Finish
+
* on commandline, cd to copy of equinox-target
+
* ant run-standalone
+
  
 
== WebStart ==
 
== WebStart ==
  
 +
* '''Currently available only for debug deployment, see below'''
 +
** Todo: Feature is to be build and packed into war
 
* A new top-level project webstart has been created
 
* A new top-level project webstart has been created
 
* This is a feature (equinox language).
 
* This is a feature (equinox language).
Line 51: Line 53:
 
* If you do not have one, create a keystore
 
* If you do not have one, create a keystore
 
** eg. using: keytool -genkey -alias adempiere -keystore equinox-target/dist/keystore
 
** eg. using: keytool -genkey -alias adempiere -keystore equinox-target/dist/keystore
 +
* submit ant dist-webstart in /equinox-target
 
* open webstart/feature.xml (should open in the eclipse feature editor)
 
* open webstart/feature.xml (should open in the eclipse feature editor)
 
* Press the "export deployable feature" icon in the top-right corner
 
* Press the "export deployable feature" icon in the top-right corner
Line 63: Line 66:
 
== ZK Web UI ==
 
== ZK Web UI ==
  
 +
* Install as described above
 
* install a tomcat-5.5.28
 
* install a tomcat-5.5.28
* ln -s equinox-target/dist/web tomcat-5.5.28/webapps/adempiere
+
* ln -s ADEMPIERE_INSTALLwebapp/bridge tomcat-5.5.28/webapps/adempiere
* Open '''zkwebui/META-INF/MANIFEST.MF'''
+
** "Export deployable plugins and fragments" (top-right corner icon)
+
** Select all plugins
+
** Choose equinox-target/dist/web/WEB-INF/eclipse as output directory
+
 
* rm -rf tomcat-5.5.28/work/* (ensure using current build)
 
* rm -rf tomcat-5.5.28/work/* (ensure using current build)
 
* fire up tomcat: catalina.sh jpda run (jpda  for remote debugging)
 
* fire up tomcat: catalina.sh jpda run (jpda  for remote debugging)
Line 86: Line 86:
 
Now what to do if you want to change a plugin and test it?
 
Now what to do if you want to change a plugin and test it?
 
* If you changed code in a plugin, open its MANIFEST.MF
 
* If you changed code in a plugin, open its MANIFEST.MF
* deploy it - the deployment dialog remembers the different output directories
+
* deploy it: utils_dev/RUN_plugin <project name>
 
* choose the standalone or the web OSGi container - wherever you want to test
 
* choose the standalone or the web OSGi container - wherever you want to test
 
* attach to the OSGi console running, refresh the bundle and test.
 
* attach to the OSGi console running, refresh the bundle and test.
 
Webstart can only be tested by deploying all features which is quite time consuming.
 
Webstart can only be tested by deploying all features which is quite time consuming.
 
Do it after everything runs in the standalone container.
 
Do it after everything runs in the standalone container.
 +
 +
= Running standalone within Eclipse =
 +
 +
Alternatively, you can run/debug Adempiere standalone within Eclipse.
 +
* Select Run -> Run configurations...
 +
* create new OSGI Framework
 +
* Under bundles Deselect All, and then select org.adempiere.client and any other plugins you want to use
 +
* Click Add Required Bundles
 +
* Run
 +
 +
[[Equinox_Integration_2_-_Swing_Client_Run_Configuration|Screenshot of an example Eclipse run configuration for swing client]]
  
 
= Core Interfaces/Extension Points =
 
= Core Interfaces/Extension Points =
Line 118: Line 129:
 
|Planned
 
|Planned
 
|Modelvalidator - called whenever a record is saved
 
|Modelvalidator - called whenever a record is saved
 +
|-
 +
|org.adempiere.osgi.IMenuAction
 +
|Implemented
 +
|Menu Action - called whenever a window menu is created
 
|}
 
|}
  
Line 133: Line 148:
 
* ZK Servlets do not save ServletConfig - Workaround checked in
 
* ZK Servlets do not save ServletConfig - Workaround checked in
 
* Standard Equinox bridging webapp incompatible with up-to-date equinox - updated version provided.
 
* Standard Equinox bridging webapp incompatible with up-to-date equinox - updated version provided.
 +
* a4e: The resource '.../External Plug-in Libraries/.classpath' does not exist
 +
** ? workaround: rm -rf ../External Plug-in Libraries ?
  
 
= See Also =
 
= See Also =
  
 
* [[Equinox Integration]]
 
* [[Equinox Integration]]
* [http://sourceforge.net/forum/forum.php?thread_id=2143547&forum_id=610546 SourceForge discussion]
+
* [[Equinox Integration 2 - Swing Client Run Configuration]] by HengSin
 
* [[ADempiere/OSGi Integration]]
 
* [[ADempiere/OSGi Integration]]
 
* [[RoadmapToModularization]]
 
* [[RoadmapToModularization]]
 +
* [http://sourceforge.net/forum/forum.php?thread_id=2143547&forum_id=610546 SourceForge discussion]
 +
* [[PMC Architecture Meeting 20100324]] that touched about OSGI development.
 +
*[[Talk:Mercurial_Test_Environment#Pointing to Heng Sin's Kenai Project]] that uses both OSGI and the Spring DM Gemini toolset.
 +
*[http://kenai.com/projects/hengsin/pages/Building Heng Sin Build Guide]
  
 +
=Further Reading=
 +
*http://www.osgi.org/About/WhyOSGi
 +
*http://impalablog.blogspot.com/2009/05/why-developers-dont-just-jump-at-osgi.html
 +
*http://blog.springsource.com/2008/05/15/why-should-i-care-about-osgi-anyway/
 
* Equinox webstart documentation: http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/java_web_start.htm
 
* Equinox webstart documentation: http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/java_web_start.htm
 
+
*[http://blog.caucho.com/?p=213 Why OSGi is cool, but not for most enterprise apps]
 
+
*[http://www.vogella.de/articles/EclipsePlugIn/article.html Vogella] has the fastest tutorial i grasped at one go - [[User:Red1|Redhuan D. Oon]]
 
[[Category:Projects and Tools]]
 
[[Category:Projects and Tools]]

Latest revision as of 07:05, 22 November 2010

Approach 2: Embedding ADempiere in Equinox done by Joerg Viola. However, the OSGI Project is undergoing revamp by Heng Sin and is almost beta at this stage. Thus this page is only a reference point for academic reference until documentation of the new project becomes more complete there. - Redhuan D. Oon

ADempiere is getting pluggable like the Eclipse framework!

Status: Alpha Code - Review required

  • Current release tag: 4.0.0pr01
  • Swing client can be fired up inside equinox.
  • very few tests applied
  • Webstart has been fired up with equinox.
  • zkwebui runs inside OSGi through equinox servlet bridge
  • deployment now integrated in the standard adempiere setup!
    • currently only swing standalone and zkwebui accessible
    • webstart has to be packed in a war for deploying in any web container

Setup

Eclipse setup

  • As usual: File/Import.../Existing Projects into Workspace
  • You find a new top-level project equinox-target. It serves the following purposes:
    • acting as an equinox-target, defining the eclipse dev environment
    • providing ant-based setup for development environment for standalone swing client, webstart and web ui.
    • Later: installing equinox runtime components in the ADempiere install process
  • Open the file equinox-target/equinox.target and click "Set as target platform" in the upper right corner.
    • Now eclipse knows about the specific equinox bundle configuration we are going to use.

Development Environment

  • Use the standard ADempiere deployment:
    • cd utils_dev
./RUN_build.sh
  • This creates and adempiere/Adempiere installation with a new "osgi" folder. This is the OSGi container platform
  • For updating a modified plug-in, use
./RUN_plugin.sh <name of plugin project>

Swing Standalone

  • Use the standard ./RUN_ADempiere.sh in deploy directory

WebStart

  • Currently available only for debug deployment, see below
    • Todo: Feature is to be build and packed into war
  • A new top-level project webstart has been created
  • This is a feature (equinox language).
    • It wraps all plugins.
  • If you do not have one, create a keystore
    • eg. using: keytool -genkey -alias adempiere -keystore equinox-target/dist/keystore
  • submit ant dist-webstart in /equinox-target
  • open webstart/feature.xml (should open in the eclipse feature editor)
  • Press the "export deployable feature" icon in the top-right corner
    • Choose equinox-target/dist/webstart as output directory
    • Under JAR signed, provide your keystore
    • Under Java Web Start, provide the location the JNLP will be downloaded from (eg. http://localhost:8080/webstart) and the JVM spec (1.5+)
    • Click Finish
  • Run it using one of the following options:
    • on the console, cd to equinox-target/dist/webstart and execute javaws adempiere-equinox.jnlp
    • in a web-container, link a webapp to equinox-target/dist/webstart and download the app from webstart/adempiere-equinox.jnlp

ZK Web UI

  • Install as described above
  • install a tomcat-5.5.28
  • ln -s ADEMPIERE_INSTALLwebapp/bridge tomcat-5.5.28/webapps/adempiere
  • rm -rf tomcat-5.5.28/work/* (ensure using current build)
  • fire up tomcat: catalina.sh jpda run (jpda for remote debugging)
  • http://localhost:8080/adempiere/index.zul
  • Enjoy

Development cycle

Though initial setup seems to be quite expensive, the development turnaround cycle is not.

A fine tool is the OSGi console, a text console currently launched at standalone and web deployment. The terminal window after start simply accepts keyboard input, type "help" for available commands:

* help
* ss - short status of all bundles
* refresh <bundle id>

Now what to do if you want to change a plugin and test it?

  • If you changed code in a plugin, open its MANIFEST.MF
  • deploy it: utils_dev/RUN_plugin <project name>
  • choose the standalone or the web OSGi container - wherever you want to test
  • attach to the OSGi console running, refresh the bundle and test.

Webstart can only be tested by deploying all features which is quite time consuming. Do it after everything runs in the standalone container.

Running standalone within Eclipse

Alternatively, you can run/debug Adempiere standalone within Eclipse.

  • Select Run -> Run configurations...
  • create new OSGI Framework
  • Under bundles Deselect All, and then select org.adempiere.client and any other plugins you want to use
  • Click Add Required Bundles
  • Run

Screenshot of an example Eclipse run configuration for swing client

Core Interfaces/Extension Points

Id Status Description
org.adempiere.base.IResourceFinder Implemented Finds resources in each plugin, use since client code is in base, requiring resource from client
org.adempiere.base.IDictionaryService Implemented Dictionary migration - 2pack being one possible implementation, used by plugin utilities
org.compiere.apps.form.FormPanel Implemented FormPanel - a freely programmable Form for the Swing Client
org.adempiere.base.IColumnCallout Implemented Callout - called whenever a column on a table changes its value
org.adempiere.base.IModelValidator Planned Modelvalidator - called whenever a record is saved
org.adempiere.osgi.IMenuAction Implemented Menu Action - called whenever a window menu is created

Tutorials

Learning Points Encountered

  • client code in base: this code has no access eg. on resources in client.
    • First core interface defined: IResourceFinder
    • Adempiere.class.getResource() converted to Adempiere.getResource() - which in turn uses IResourceHandler
  • Postgres Driver in tools is java 1.6? - Have to use a 1.6 VM!
  • ZK Servlets do not save ServletConfig - Workaround checked in
  • Standard Equinox bridging webapp incompatible with up-to-date equinox - updated version provided.
  • a4e: The resource '.../External Plug-in Libraries/.classpath' does not exist
    •  ? workaround: rm -rf ../External Plug-in Libraries ?

See Also

Further Reading