Re: Question to pax-jdbc devs: how do you handle DataSourceFactory bundle restart?

2019-05-01 Thread 'Christoph Läubrich' via OPS4J
Correctly, the PGDataSourceFactory should simply instatiate the required 
class directly, no need for using the DriverManager at all!

See [1] line 131 or [2] line 40, 47, 54 for example.

The problem with DataSourceFactory is that it does not support dynmics 
or different class-loader spaces very well.


[1] 
https://github.com/MariaDB/mariadb-connector-j/blob/1d831664f7d871ccd871fb9b2137ce3cd3421c4d/src/main/java/org/mariadb/jdbc/internal/osgi/MariaDbDataSourceFactory.java


[2] 
https://github.com/Microsoft/mssql-jdbc/blob/dev/src/main/java/com/microsoft/sqlserver/jdbc/osgi/SQLServerDataSourceFactory.java


Am 01.05.19 um 16:49 schrieb Steinar Bang:

'Christoph Läubrich' via OPS4J :



DriverManger.register/unregister can't work reliable in OSGi
(especially with static insitilizer), thus always the
DataSourceFactory should be used instead!


PGDataSourceFactory is currently implemented using the regular PG JDBC
driver, ie. the Driver class, which in turn uses the DriverManager in
rt.jar.

So the fix should be to change the implementation of PGDataSourceFactory
to not use the Driver class via DriverManager?  Maybe
PGDataSourceFactory should create and own a Driver instance?



--
--
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups "OPS4J" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Question to pax-jdbc devs: how do you handle DataSourceFactory bundle restart?

2019-05-01 Thread Steinar Bang
> 'Christoph Läubrich' via OPS4J 
> :

> DriverManger.register/unregister can't work reliable in OSGi
> (especially with static insitilizer), thus always the
> DataSourceFactory should be used instead!

PGDataSourceFactory is currently implemented using the regular PG JDBC
driver, ie. the Driver class, which in turn uses the DriverManager in
rt.jar.

So the fix should be to change the implementation of PGDataSourceFactory
to not use the Driver class via DriverManager?  Maybe
PGDataSourceFactory should create and own a Driver instance?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Question to pax-jdbc devs: how do you handle DataSourceFactory bundle restart?

2019-05-01 Thread 'Christoph Läubrich' via OPS4J
DriverManger.register/unregister can't work reliable in OSGi (especially 
with static insitilizer), thus always the DataSourceFactory should be 
used instead!


Am 30.04.19 um 19:43 schrieb Steinar Bang:

Christian Schneider :



I see no calls to DriverManager in
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/osgi/PGBundleActivator.java


The DriverManager isn't called directly from the PGBundleActivator.

  1. DriverManager.registerDriver() is called from Driver.register()
  
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/Driver.java#L720
  2. Driver.register() is called from a static initializer in the Driver class
  
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/Driver.java#L72
  3. DriverManager.deregisterDriver() is called from Driver.deregister()
  
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/Driver.java#L737
  4. Driver.deregister() is called from the PGBundleActivator.stop() method
  
https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/osgi/PGBundleActivator.java#L56


It only registers and unregisters the DataSourceFactory service which looks
correct.


Yes, that bit is correct, and populates to my DS components that has
@Reference to DatasourceFactory (the old service is unbound and the
activate methods are called using the new service).


Not sure about the call to Driver.deregister though.
This might cause the issue.


See comment in the issue
  https://github.com/pgjdbc/pgjdbc/issues/1476#issuecomment-487370634



--
--
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups "OPS4J" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.