Heads up on a long needed rewrite of the <ServiceProvider> service-jar.xml code.

We've been duplicating config for years and it's been a back-burner item on the 
TODO list for quite some time.

Currently, the service-jar.xml configs, which provide defaults for anything 
configured in tomee.xml, look a bit redundant like this:

<ServiceProvider id="My DataSource" types="DataSource"> 
  JdbcDriver org.hsqldb.jdbcDriver 
  JdbcUrl jdbc:hsqldb:file:data/hsqldb/hsqldb 
  UserName sa 
  Password 
  JtaManaged true 
</ServiceProvider> 

<ServiceProvider id="My Unmanaged DataSource" types="DataSource"> 
  JdbcDriver org.hsqldb.jdbcDriver 
  JdbcUrl jdbc:hsqldb:file:data/hsqldb/hsqldb 
  UserName sa 
  Password 
  JtaManaged false 
</ServiceProvider> 

The obviously missing functionality is to be able to reuse <ServiceProvider> 
data when creating a derivative <ServiceProvider>.  Something like this:

<ServiceProvider id="My DataSource" types="DataSource"> 
  JdbcDriver org.hsqldb.jdbcDriver 
  JdbcUrl jdbc:hsqldb:file:data/hsqldb/hsqldb 
  UserName sa 
  Password 
  JtaManaged true 
</ServiceProvider> 

<ServiceProvider id="My Unmanaged DataSource" parent="My DataSource"> 
  JtaManaged false 
</ServiceProvider>

This obviously adds in subtle complexities such as circular references, etc.  
To really do it right I pretty much had to redo the guts of the 
<ServiceProvider> processing code.  It now lives here:

 - 
http://svn.apache.org/repos/asf/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/provider/

Some side benefits of the refactor:

 - Much tighter control of <ServiceProvider> declarations added.  Easy to add 
strict validation now.
 - Now possible to use something other than service-jar.xml files to declare 
providers. (only service-jar.xml is implemented, but is cleanly abstracted)
 
Finally this chunk of code which has had a few band-aids on it is clean and 
modern.  More expansion we can do in the area is fire events when a provider is 
added.

Haven't yet cleaned up the various service-jar.xml files.  Wanted to get a 
clean TCK run of the changes without that before taking an axe to them.


-David

Reply via email to