Hibernate ORM
  1. Hibernate ORM
  2. HHH-7527 OSGi hibernate-orm
  3. HHH-7943

C3P0, Proxool, ehcache, and infinispan services for OSGi

    Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.3.0.Beta2
    • Component/s: None
    • Labels:
      None
    • Last commented by a user?:
      true

      Description

      hibernate-c3p0 and hibernate-proxool have internal packages defined as Private-Package in the MANIFEST. Rather than export them so that Core can get to the providers, or define them as bundle fragments of core, register the providers as services.

        Issue Links

          Activity

          Hide
          Tuomas Kiviaho added a comment -

          C3P0ConnectionProvider uses com.mchange.v2.c3p0.DriverManagerDataSource and DriverManager isn't OSGi friendly (when it checks if driver is allowed). I with that C3P0ConnectionProvider would be modified so that creation of initial datasource could be overridden. Then I could extend a provider on my own a version that uses org.osgi.service.jdbc.DataSourceFactory.

          Show
          Tuomas Kiviaho added a comment - C3P0ConnectionProvider uses com.mchange.v2.c3p0.DriverManagerDataSource and DriverManager isn't OSGi friendly (when it checks if driver is allowed). I with that C3P0ConnectionProvider would be modified so that creation of initial datasource could be overridden. Then I could extend a provider on my own a version that uses org.osgi.service.jdbc.DataSourceFactory.
          Hide
          Steve Ebersole added a comment -

          You can do this already. Just extend org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl and supply that as your connection provider:

          MyConnectionProvider.java
          public class MyConnectionProvider extends DatasourceConnectionProviderImpl {
              public MyConnectionProvider() {
                  super();
                  super.setDataSource( getYourDataSource() );
              }
          
              protected DataSource getYourDataSource() {
                  // not familiar with org.osgi.service.jdbc.DataSourceFactory, so this part left as an exercise.
              }
          }
          

          Or, ConnectionProvider is such a simple contract. Just implement it directly.

          Show
          Steve Ebersole added a comment - You can do this already. Just extend org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl and supply that as your connection provider: MyConnectionProvider.java public class MyConnectionProvider extends DatasourceConnectionProviderImpl { public MyConnectionProvider() { super (); super .setDataSource( getYourDataSource() ); } protected DataSource getYourDataSource() { // not familiar with org.osgi.service.jdbc.DataSourceFactory, so this part left as an exercise. } } Or, ConnectionProvider is such a simple contract. Just implement it directly.
          Hide
          Steve Ebersole added a comment -

          Brett, the idea was to register these with the StrategySelectorService.

          Show
          Steve Ebersole added a comment - Brett, the idea was to register these with the StrategySelectorService.
          Hide
          Steve Ebersole added a comment -

          Brett, specifically what I mean is that the intention was that a call would be made from classes within the hibernate-c3p0 and hibernate-proxool artifacts which registered org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider.class and org.hibernate.service.jdbc.connections.internal.ProxoolConnectionProvider.class with the StrategySelectorService.

          My understanding is that that should work. hibernate-c3p0 and hibernate-proxool obviously have access to their own class loaders.

          Show
          Steve Ebersole added a comment - Brett, specifically what I mean is that the intention was that a call would be made from classes within the hibernate-c3p0 and hibernate-proxool artifacts which registered org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider.class and org.hibernate.service.jdbc.connections.internal.ProxoolConnectionProvider.class with the StrategySelectorService . My understanding is that that should work. hibernate-c3p0 and hibernate-proxool obviously have access to their own class loaders.
          Hide
          Steve Ebersole added a comment -

          Brett, if you can get to this for Beta1 great. If not, we'll just push it to Beta2.

          Show
          Steve Ebersole added a comment - Brett, if you can get to this for Beta1 great. If not, we'll just push it to Beta2.
          Hide
          Brett Meyer added a comment -

          Steve Ebersole, with respect to OSGi, there will be a collision since both c3p0 and proxool export the org.hibernate.service.jdbc.connections.internal package. Any issues with refactoring that in master?

          Show
          Brett Meyer added a comment - Steve Ebersole , with respect to OSGi, there will be a collision since both c3p0 and proxool export the org.hibernate.service.jdbc.connections.internal package. Any issues with refactoring that in master?
          Hide
          Brett Meyer added a comment -

          Tuomas Kiviaho, following up with HHH-8209 – good catch.

          Show
          Brett Meyer added a comment - Tuomas Kiviaho , following up with HHH-8209 – good catch.
          Hide
          Brett Meyer added a comment -

          Reopening to add support for ehcache and infinispan

          Show
          Brett Meyer added a comment - Reopening to add support for ehcache and infinispan

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development