Bug 115887 - [DataBinding] Dependency on non-foundation class library should be removed
Summary: [DataBinding] Dependency on non-foundation class library should be removed
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P2 normal (vote)
Target Milestone: 3.3   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 153630
Blocks: 121434 118570
  Show dependency tree
 
Reported: 2005-11-10 14:16 EST by Douglas Pollock CLA
Modified: 2007-06-26 13:35 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Douglas Pollock CLA 2005-11-10 14:16:11 EST
"org.eclipse.jface.databinding" is included in the RCP drops (as of tonight's 
nightly builds).  As such, it must only use foundation library code.  To set 
up a foundation environment, do the following: 
 
1.) Check out "org.eclipse.osgi" 
2.) Open the properties on "org.eclipse.jface.databinding" 
3.) Go to the Java Build Path > Libraries 
4.) Remove JRE System Library 
5.) Add JAR: "org.eclipse.osgi/osgi/ee.foundation.jar" 
optional: add "org.eclipse.osgi/osgi/XMLParserAPIs.jar" as well
Comment 1 Boris Bokowski CLA 2005-11-10 14:35:34 EST
... and don't commit the change to .classpath when you do this
Comment 2 Boris Bokowski CLA 2005-11-10 16:13:20 EST
Fixed one part of this.

The JavaBeans classes are not part of Foundation, we need to discuss what we can do.
Comment 3 Boris Bokowski CLA 2005-11-15 14:17:55 EST
I talked to Nick about this, and he said that we might get away with a couple
"impurities" as long as it is a small contained piece of the data binding
framework. Right now, the JavaBeans model support is contained in one package.
Comment 4 Douglas Pollock CLA 2005-11-15 15:09:41 EST
While I think this is true, I think that it would be best to separate the 
non-Foundation pieces into their own plug-in. 
 
Comment 5 Nick Edgar CLA 2005-11-15 15:34:45 EST
Jeff, do you have any recommendations here?  We have a few cases where our
choice of dependencies requires splitting out some pretty fine-grained plug-ins
if we're going to be strict about it.  Another case is the action set for Update
currently in org.eclipse.ide, which should really belong in an
org.eclipse.update.ui.ide plug-in.
Comment 6 Dave Orme CLA 2005-11-15 16:13:37 EST
Boris, I think the only JavaBeans stuff we use is the Introspector and BeanInfo
stuff, right?

If so, it's not hard to re-create the important parts of that and just eliminate
the dependency.

That's what I did for Sweet (which is in CVS).  I know that Sweet uses dynamic
proxies, which is also non-foundation, but maybe it could be used as a reference
for implementing our own support.
Comment 7 Boris Bokowski CLA 2005-11-15 16:49:57 EST
The problem is PropertyChangeListener. We cannot register a listener with a bean
object without implementing this class, which is not part of foundation if I'm
not mistaken.
Comment 8 Jeff McAffer CLA 2005-11-17 23:26:25 EST
Hmmm, lots of little plugins would be unfortunate.  It would likely be better 
to go down the path of having optional pieces within the plugin and clearly 
documenting them as needing a differnet JRE.  To that end we should come up 
with a conventional form and place for such notices.
Comment 9 Boris Bokowski CLA 2005-11-18 00:21:40 EST
> To that end we should come up 
> with a conventional form and place for such notices.

Ideally, automatic checking should be possible for cases like this too, if not
as part of PDE, then as part of the build process.
Comment 10 Jeff McAffer CLA 2005-11-18 09:06:12 EST
Not sure what we would check.  It either compiles or it does not.  If you want 
it to compile the you have to setup the build.properties correctly.  Needing 
to do this is a sure sign that something in the plugin needs more detailed 
JavaDoc indicating what works only if a certain JRE is available.
Comment 11 Boris Bokowski CLA 2005-11-28 17:52:09 EST
In the meantime, we have grown more dependencies on non-foundation classes.

- PropertyChangeListener and other JavaBean classes for bean model support
- DecimalFormat, DateFormat from java.text for validators

Treating these as "impurities" in separate packages has the drawback that the tooling does not enforce that you can still run a sizeable part of the plug-in using just the foundation class library. We would have to check this manually every now and then.

Because of that, I'm leaning towards either spliting into two plug-ins, or giving up on the goal of supporting foundation and requiring the full 1.3 or 1.4 class libraries.
Comment 12 Douglas Pollock CLA 2005-11-28 23:12:35 EST
+1 for splitting (if anyone cares <g>)
Comment 13 Jeff McAffer CLA 2005-12-02 11:40:26 EST
-1 for giving up
+1 for something that means you don't have to give up
Comment 14 Dave Orme CLA 2005-12-02 14:17:21 EST
(In reply to comment #13)
> -1 for giving up
> +1 for something that means you don't have to give up

Let me see if I can rephrase the problem and maybe that will help us work it:

The whole data binding framework depends on one foundational interface (pun not intended):

/** JavaDoc removed */
public interface IUpdatable {
	public void addChangeListener(IChangeListener changeListener);
	public void removeChangeListener(IChangeListener changeListener);
	public void dispose();
}

Right now the change notification contract above can be satisfied one of two ways:

1) By using EMF and building on its change notification mechanism.
2) By using java.beans.* with its PropertyChangeListener interface.

Our problem, then, is that neither (1) or (2) is foundation and that a lot of folks would prefer to work with POJOs than with EMF.

So it seems that if we must be able to run on Foundation, that our only real choice is to invent our own change listener interface to use in place of java.beans.PropertyChangeListener, if java.beans.PropertyChangeListener isn't present.

This would imply creating a new eclipse.beans.PropertyChangeListener (or something) and creating a new (EclipseBeanUpdatable, EclipseBeanUpdatableValue, EclipseBeanUpdatableCollection, ...)

It's ugly, but it would work.

I don't think that this should replace our java.beans implementation because I don't think we can credibly claim to be a generic data binding framework without supporting java.beans.

Thoughts, comments, other ideas?
Comment 15 Dave Orme CLA 2005-12-02 14:26:33 EST
(In reply to comment #14)
> So it seems that if we must be able to run on Foundation, that our only real
> choice is to invent our own change listener interface to use in place of
> java.beans.PropertyChangeListener, if java.beans.PropertyChangeListener isn't
> present.

Maybe the answer is staring me in the face.  Here's another idea:

Maybe this new change listener interface is just IChangeListener above... :-) (see comment 14)  The semantics for using them are identical to using the JavaBeans addPropertyChangeListener(pcl), removePropertyChangeListener(pcl), etc.

We still would need a new EclipseUpdatableValue, EclipseUpdatableCollection, and so on that can recognize addChangeListener(IChangeListener), removeChangeListner(IChangeListener), and so on.

And as I mentioned in bug #118570, we need to separate classes (like this IChangeListener) that folks will put in their models into a separate plug-in since these models might run inside a web server or other application server, and dragging in data binding, which drags in JFace which drags in SWT will be unacceptable in that environment.

Thoughts?
Comment 16 Boris Bokowski CLA 2006-05-10 23:21:11 EDT
Changing priority to P2.
Comment 17 Boris Bokowski CLA 2006-11-10 15:56:23 EST
We are almost there. The remaining non-foundation dependency is on String.matches() and the package java.util.regex.  This is currently used in the validator classes.

To get rid of these dependencies, I see two alternatives:

1. Remove RegexStringValidator, and implement the *2*PrimitiveValidator classes in a way that does not use regular expressions.  I.e., translate the existing regular expressions into code that uses startsWith(), indexOf(), substring() and the like.

2. Move the default validators (and converters?) into org.eclipse.core.databinding.beans, which can use 1.4 level API.  This would be easier to do, but it also means that we would have to add a convenience method to the beans plug-in to create a vanilla data binding context and use that in most cases instead of just calling a constructor on DataBindingContext.

Thoughts? Comments?
Comment 18 Boris Bokowski CLA 2006-11-10 15:59:36 EST
BTW, if you want to set up Eclipse with a foundation-1.0 execution environment, here are the steps that worked for me: http://wiki.eclipse.org/index.php/J9
Comment 19 Jeff McAffer CLA 2006-11-10 21:19:52 EST
There is an in between option that says you use regex if available. The frustrating thing about the Bundle-RequiredExecutionEnvironment setting is that it is multi-purpose.  It covers things like language level features (generics, assertions, ...) and byte code type codes to JRE classes.  The latter is a problem because often the same classes are available from other sources.  XML parsing is a perfect example.  As is JMX support.  We have bundles that supply these API and implementations independent of the underlying JRE.  (Note that with the new bootdelegation support you will actually be able to use these other implementations even in the face of them existing in the JRE).

So, what I am getting at here is if you Import-Package the regex things you need then any old bundle that has them can supply them to you.  Then the quesiton for you becomes, can you run without regex.  If you can, make the Import optional and do your pattern matching conditionally.  For example, check to see if regex is there, if so, use it, if not, do something else (graceful degradation)  This is not always possible but it is a useful approach if you can swing it.
Comment 20 Dave Orme CLA 2006-11-10 22:34:21 EST
(In reply to comment #17)
> We are almost there. The remaining non-foundation dependency is on
> String.matches() and the package java.util.regex.  This is currently used in
> the validator classes.
> 
> To get rid of these dependencies, I see two alternatives:
> 
> 1. Remove RegexStringValidator, and implement the *2*PrimitiveValidator classes
> in a way that does not use regular expressions.  I.e., translate the existing
> regular expressions into code that uses startsWith(), indexOf(), substring()
> and the like.

Either this or Jeff's suggestion are my choices.  I also bet a brain-dead simple regex engine without bells and whistles would be pretty easy to code too, if we needed.  It wouldn't compile to a finite state machine, but for our work, we don't normally need that performance.  This could be the default if Java's regexes aren't available.

Another thought--Is Apache ORO approved/used anywhere in Platform?

If we do #1 here, I suggest that we move the regex validator to a non-foundation package--maybe the JavaBeans one.  It's too useful to give up entirely.
Comment 21 Jeff McAffer CLA 2006-11-10 23:44:44 EST
I believe ORO or something compatible is used in other projects.  I think I saw someone talking about it in Orbit.  In any event, if you can code a path that makes regex optional then it really doesn't matter.  People who want ot use it can add ORO/whatever
Comment 22 Boris Bokowski CLA 2006-11-14 14:17:08 EST
If possible, I would like to keep core.databinding clean - this makes it easy to check that we are only using foundation/1.0 classes.  It also avoids the complexity of having optional dependencies, and parts of the API that depends on those optional dependencies.

About moving RegexStringValidator to core.databinding.beans - I initially thought this was a good idea, until I tried to move it and had to pick a package name in the new plug-in for it.  Packages in core.databinding.beans should have that prefix, and the regex stuff clearly has nothing to do with beans.  I then looked at the class again and realized that it is just a convenience implementation.  It does not have any interesting code on its own, so I would suggest for now that we remove it.  Clients can still create validators based on regexps by just delegating to the 1.4 API available to them.

If we could agree on taking approach #1 and removing RegexStringValidator, all we need before we can close this bugzilla is someone who implements the *2*PrimitiveValidator classes without using regexps.

Any volunteers? ;)
Comment 23 Boris Bokowski CLA 2007-06-26 13:35:39 EDT
This was fixed in 3.3.