Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "JFace Data Binding/PojoBindable/PojoBindableSVN"
(→Pojo Bindable Configuration (bindable.properties)) |
(→Import the projects from SVN) |
||
Line 109: | Line 109: | ||
<ol> | <ol> | ||
<li>the 3 ASM projects stored into [http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/dependencies/ dependencies] : | <li>the 3 ASM projects stored into [http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/dependencies/ dependencies] : | ||
− | <ul><li>[http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/dependencies/com.springsource.org.objectweb.asm com.springsource.org.objectweb.asm] : ASM bundle "org.objectweb.asm" version | + | <ul><li>Bundle [http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/dependencies/com.springsource.org.objectweb.asm com.springsource.org.objectweb.asm] : ASM bundle "org.objectweb.asm" version |
of 3.2.0 getted from [http://www.springsource.com/repository/app/ SpringSource Enterprise Bundle Repository]. | of 3.2.0 getted from [http://www.springsource.com/repository/app/ SpringSource Enterprise Bundle Repository]. | ||
</li> | </li> | ||
− | <li>[http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/dependencies/com.springsource.org.objectweb.asm.commons com.springsource.org.objectweb.asm.commons] : ASM Commons bundle "org.objectweb.asm" version | + | <li>Bundle [http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/dependencies/com.springsource.org.objectweb.asm.commons com.springsource.org.objectweb.asm.commons] : ASM Commons bundle "org.objectweb.asm" version |
of 3.2.0 getted from [http://www.springsource.com/repository/app/ SpringSource Enterprise Bundle Repository]. | of 3.2.0 getted from [http://www.springsource.com/repository/app/ SpringSource Enterprise Bundle Repository]. | ||
</li> | </li> | ||
− | <li>[http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/dependencies/com.springsource.org.objectweb.asm.tree com.springsource.org.objectweb.asm.tree]: ASM Tree bundle "org.objectweb.asm" version | + | <li>Bundle [http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/dependencies/com.springsource.org.objectweb.asm.tree com.springsource.org.objectweb.asm.tree]: ASM Tree bundle "org.objectweb.asm" version |
of 3.2.0 getted from [http://www.springsource.com/repository/app/ SpringSource Enterprise Bundle Repository]. This bundle is not required for Pojo Bindable but just required for com.springsource.org.objectweb.asm.commons bundle. | of 3.2.0 getted from [http://www.springsource.com/repository/app/ SpringSource Enterprise Bundle Repository]. This bundle is not required for Pojo Bindable but just required for com.springsource.org.objectweb.asm.commons bundle. | ||
</li> | </li> | ||
</ul> | </ul> | ||
</li> | </li> | ||
− | <li>[http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/examples/org.eclipse.core.examples.databinding.pojo.bindable/ org.eclipse.core.examples.databinding.pojo.bindable]: Pojo Bindable bundle example.</li> | + | <li>Bundle [http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/org.eclipse.core.databinding.pojo.bindable/ org.eclipse.core.databinding.pojo.bindable]: Pojo Bindable bundle.</li> |
+ | <li>Bundle [http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/osgi-equinox/org.eclipse.core.databinding.pojo.bindable.equinox org.eclipse.core.databinding.pojo.bindable.equinox]: Pojo Bindable bundle which publish a BindableWeaver service to transform Class to Pojo bindable (implements BindableAware interface).</li> | ||
+ | <li>Fragment [http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/osgi-equinox/org.eclipse.core.databinding.pojo.bindable.equinox.weaving org.eclipse.core.databinding.pojo.bindable.equinox.weaving]: Pojo Bindable bundle which consume a BindableWeaver service to transform Class to Pojo bindable (implements BindableAware interface). </li> | ||
+ | <li>Bundle [http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/examples/org.eclipse.core.examples.databinding.pojo.bindable/ org.eclipse.core.examples.databinding.pojo.bindable]: Pojo Bindable bundle example.</li> | ||
<li>TODO other bundles (see screenshot). | <li>TODO other bundles (see screenshot). | ||
</li> | </li> |
Revision as of 01:02, 13 April 2010
Contents
Pojo Bindable SVN
For the last version of Pojo Bindable you can (for the moment) get it from the SVN on Dynaresume project. You can find the whole Pojo bindable project at http://dynaresume.googlecode.com/svn/trunk/JFace-Pojo-Bindable/ :
- dependencies. This folder contains the ASM bundles required by Pojo Bindable :
- com.springsource.org.objectweb.asm : ASM bundle "org.objectweb.asm" version of 3.2.0 getted from SpringSource Enterprise Bundle Repository.
- com.springsource.org.objectweb.asm.commons : ASM Commons bundle "org.objectweb.asm" version of 3.2.0 getted from SpringSource Enterprise Bundle Repository.
- com.springsource.org.objectweb.asm.tree: ASM Tree bundle "org.objectweb.asm" version of 3.2.0 getted from SpringSource Enterprise Bundle Repository. This bundle is not required for Pojo Bindable but just required for com.springsource.org.objectweb.asm.commons bundle.
- org.eclipse.core.databinding.pojo.bindable: Pojo Bindable bundle project.
- examples. This folder contains Java Agent/OSGi examples with Pojo Bindable.
- osgi-equinox. This folder contains OSGi bundles required to use Pojo Bindable into OSGi context.
- tests. This folder contains tests with pojo Bindable.
Pojo Bindable into OSGi context
You can find a basic sample with Pojo bindable into org.eclipse.core.examples.databinding.pojo.bindable.equinox bundle. This bundle has an Activator which create a basic PojoPerson coming from another bundle org.eclipse.core.examples.databinding.pojo.bindable.model:
package org.eclipse.core.examples.databinding.pojo.bindable.model; public class PojoPerson { String name = "HelloWorld"; public String getName() { return name; } public void setName(String name) { this.name = name; } }
and add it a PropertyChangeListener listener :
public class Activator implements BundleActivator { /* * (non-Javadoc) * * @see * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext * ) */ public void start(BundleContext context) throws Exception { // Create Pojo instance PojoPerson person = new PojoPerson(); PropertyChangeListener listener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { System.out.println("---------- Property User changed --------"); System.out.println(" PropertyName=" + event.getPropertyName()); System.out.println(" OldValue=" + event.getOldValue()); System.out.println(" NewValue=" + event.getNewValue()); System.out .println("------------------------------------------"); } }; // Add Listener try { Method m = person.getClass().getMethod("addPropertyChangeListener", String.class, PropertyChangeListener.class); m.invoke(person, "name", listener); } catch (Exception e) { e.printStackTrace(); } // Change name property. person.setName("New name"); } ... }
When bundle is started, you will see on console :
---------- Property User changed -------- PropertyName=name OldValue=HelloWorld NewValue=New name ------------------------------------------
You can notice that there is no dependencies to Pojo Bindable in this code. If Pojo Bindable is well configured into OSGi context, when PojoPersonn Class is used, the bytecode is updated when Class is loaded to add PropertyChangeSupport.
Pojo Bindable works into OSGi context only with Equinox. Indead Pojo bindable provides an OSGi fragment org.eclipse.core.databinding.pojo.bindable.equinox.weaving which is linked to org.eclipse.osgi and use Adaptor Hook.
How test Pojo Bindable into OSGi context?
To test the bundle org.eclipse.core.examples.databinding.pojo.bindable.equinox, you must :
Import the projects from SVN
Import from SVN the projects :
- the 3 ASM projects stored into dependencies :
- Bundle com.springsource.org.objectweb.asm : ASM bundle "org.objectweb.asm" version of 3.2.0 getted from SpringSource Enterprise Bundle Repository.
- Bundle com.springsource.org.objectweb.asm.commons : ASM Commons bundle "org.objectweb.asm" version of 3.2.0 getted from SpringSource Enterprise Bundle Repository.
- Bundle com.springsource.org.objectweb.asm.tree: ASM Tree bundle "org.objectweb.asm" version of 3.2.0 getted from SpringSource Enterprise Bundle Repository. This bundle is not required for Pojo Bindable but just required for com.springsource.org.objectweb.asm.commons bundle.
- Bundle org.eclipse.core.databinding.pojo.bindable: Pojo Bindable bundle.
- Bundle org.eclipse.core.databinding.pojo.bindable.equinox: Pojo Bindable bundle which publish a BindableWeaver service to transform Class to Pojo bindable (implements BindableAware interface).
- Fragment org.eclipse.core.databinding.pojo.bindable.equinox.weaving: Pojo Bindable bundle which consume a BindableWeaver service to transform Class to Pojo bindable (implements BindableAware interface).
- Bundle org.eclipse.core.examples.databinding.pojo.bindable: Pojo Bindable bundle example.
- TODO other bundles (see screenshot).
Pojo Bindable Bundles
If you wish use Pojo Bindable into OSGi context, you must use Bundles/Fragments :
- Bundle com.springsource.org.objectweb.asm
- Bundle com.springsource.org.objectweb.asm.commons
- Bundle com.springsource.org.objectweb.asm.tree
- Bundle org.eclipse.core.databinding.pojo.bindable
- Bundle org.eclipse.core.databinding.pojo.bindable.equinox
- Fragment (linked to org.eclipse.osgi) org.eclipse.core.databinding.pojo.bindable.equinox.weaving
Pojo Bindable Configuration (bindable.properties)
To configure Pojo bindable like Bindable Java Agent, you must create an OSGi Fragment linked to org.eclipse.core.databinding.pojo.bindable.equinox bundle and create a file bindable.properties into the fragment project. Into our example Pojo bindable is configured with the org.eclipse.core.examples.databinding.pojo.bindable.equinox.fragment OSGi Fragment. This fragment contains bindable.properties with this content :
bindable.packages=org.eclipse.core.examples.databinding.pojo.bindable.model bindable.debug=true
This configuration will transform the classes coming from org.eclipse.core.examples.databinding.pojo.bindable.model packages like our PojoPerson. Pojo bindable debug mode is set to true, so you will see each teh whole classes wich must be loaded and check your Class is transformed as explained here.
Pojo Bindable Examples
Import as binary project org.eclipse.osgi
Pojo Bindable use Equinix Adaptor Hook. The bundle weawing is fragment OSGi attached to org.eclipse.osgi bundle. To work with PDE, import the bundle org.eclipse.osgi as binary project into your workspace :
Your workspace look like this :
Launch configuration
Start the bundle with Pojo Bindable OSGi.launch.
Bundle org.eclipse.core.databinding.pojo.bindable.equinox (Level=3)
If you edit the launch Pojo Bindable OSGi.launch, you can notice that into Bundle tab :
- bundle org.eclipse.osgi is selected into Workspace (node). The bundle org.eclipse.osgi from target Platform must not selected.
- bundle org.eclipse.core.databinding.pojo.bindable.equinox must be started (level=3) before the bundle which use PojoPerson.
-Dosgi.framework.extensions=org.eclipse.core.databinding.pojo.bindable.equinox.weaving
Into Arguments tabs you can notice :
-Dosgi.framework.extensions=org.eclipse.core.databinding.pojo.bindable.equinox.weaving
Pojo Bindable & EclipseLink
EclipseLink provider Dynamic Weaving Fragment for Equinox into org.eclipse.persistence.jpa.equinox.weaving fragment to transform bytecode.
- Download org.eclipse.persistence.jpa.equinox.weaving
- Download org.eclipse.persistence.jpa.equinox.bindable. This bundle require a OSGi Fragment to configure Bindable properties (packages, debug mode...). You can find an example into fragment org.eclipse.persistence.examples.jpa.equinox.bindable.fragment which contains bindable.properties.