Martin Neimeier commented on New Feature HHH-7527

As already discussed with Steve, I have done some code reviews. The reviews should show potential problems which could show up if the following approach is implemented when it comes to generation of OSGI manifests for all jars:

  • All packages which contain ".internal" or ".internal." in the package name will be marked as INTERNAL Packages - they will be included in the Private-Package section of the OSGI manifest.
  • All packages which contain ".spi" or ".spi." in the package name will be marked as SPI Packages - they will be included in the Export-Package section of the OSGI manifest.
  • All packages which start with "org.hibernate.testing" in the package name will ignored - they will be included in the Private-Package section of the OSGI manifest.
  • The remaining packages will be marked as API packages - they will be included in the Export-Package section of the OSGI manifest.

In the first review I have identified the following problems (no guaranty for completeness)

Internal Packages exposed in interface of API/SPI-Class

org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.BulkOperationCleanupAction)
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.CollectionRecreateAction)
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.CollectionRemoveAction)
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.CollectionUpdateAction)
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.EntityDeleteAction)
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.EntityIdentityInsertAction)
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.EntityInsertAction)
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.EntityUpdateAction)
org.hibernate.cfg.SettingsFactory.DEF_CACHE_REG_FACTORY returns the class name of an internal class which may be not visible to consumers of the bundle
org.hibernate.loader.Loader.scroll(QueryParameters, Type[], org.hibernate.hql.internal.HolderInstantiator, SessionImplementor)
org.hibernate.loader.hql.QueryLoader.QueryLoader(org.hibernate.hql.internal.ast.QueryTranslatorImpl, SessionFactoryImplementor, org.hibernate.hql.internal.ast.tree.SelectClause)
org.hibernate.loader.hql.QueryLoader.getAggregatedSelectExpression() return type is org.hibernate.hql.internal.ast.tree.AggregatedSelectExpression
org.hibernate.loader.criteria.ScalarCollectionCriteriaInfoProvider.ScalarCollectionCriteriaInfoProvider(org.hibernate.hql.internal.ast.util.SessionFactoryHelper, String)

org.hibernate.internal.CriteriaImpl in:
org.hibernate.engine.spi.SessionImplementor.list(CriteriaImpl)
org.hibernate.engine.spi.SessionImplementor.scroll(CriteriaImpl, ScrollMode)
org.hibernate.envers.entities.mapper.relation.lazy.AbstractDelegateSessionImplementor.list(CriteriaImpl)
org.hibernate.envers.entities.mapper.relation.lazy.AbstractDelegateSessionImplementor.scroll(CriteriaImpl, ScrollMode)
org.hibernate.loader.criteria.CriteriaJoinWalker.CriteriaJoinWalker(OuterJoinLoadable, CriteriaQueryTranslator, SessionFactoryImplementor, CriteriaImpl, String, LoadQueryInfluencers, String)
org.hibernate.loader.criteria.CriteriaJoinWalker.CriteriaJoinWalker(OuterJoinLoadable, CriteriaQueryTranslator, SessionFactoryImplementor, CriteriaImpl, String, LoadQueryInfluencers)
org.hibernate.loader.criteria.CriteriaLoader.CriteriaLoader(OuterJoinLoadable, SessionFactoryImplementor, CriteriaImpl, String, LoadQueryInfluencers)
org.hibernate.loader.criteria.CriteriaQueryTranslator.CriteriaQueryTranslator(SessionFactoryImplementor, CriteriaImpl, String, String, CriteriaQuery)
org.hibernate.loader.criteria.CriteriaQueryTranslator.CriteriaQueryTranslator(SessionFactoryImplementor, CriteriaImpl, String, String)

org.hibernate.internal.jaxb.JaxbRoot<T> in:
org.hibernate.metamodel.source.hbm.MappingDocument.getJaxbRoot()
org.hibernate.metamodel.source.hbm.MappingDocument.MappingDocument(JaxbRoot<JaxbHibernateMapping>, MetadataImplementor)

org.hibernate.internal.jaxb.Origin in:
org.hibernate.metamodel.source.LocalBindingContext.getOrigin()
and several other places

org.hibernate.internal.jaxb.mapping.hbm.CustomSqlElement in:
org.hibernate.metamodel.source.hbm.Helper.buildCustomSql(CustomSqlElement)

org.hibernate.internal.jaxb.mapping.hbm.EntityElement in:
org.hibernate.metamodel.source.hbm.AbstractEntitySourceImpl.AbstractEntitySourceImpl(MappingDocument, EntityElement)
amd several other places

org.hibernate.internal.jaxb.mapping.hbm.PluralAttributeElement in:
org.hibernate.metamodel.source.hbm.AbstractPluralAttributeSourceImpl.AbstractPluralAttributeSourceImpl(PluralAttributeElement, AttributeSourceContainer)

org.hibernate.internal.util.xml.XmlDocument in:
org.hibernate.cfg.Configuration.add(XmlDocument)

org.hibernate.metamodel.source.internal.MetadataImpl in:
org.hibernate.metamodel.source.annotations.AnnotationMetadataSourceProcessorImpl.AnnotationMetadataSourceProcessorImpl(MetadataImpl)

org.hibernate.cache.ehcache.internal.strategy.EhcacheAccessStrategyFactory in:
org.hibernate.cache.ehcache.AbstractEhcacheRegionFactory.accessStrategyFactory

org.hibernate.jpa.internal.EntityManagerFactoryImpl:
org.hibernate.ejb.AbstractEntityManagerImpl.AbstractEntityManagerImpl(EntityManagerFactoryImpl, PersistenceContextType, SynchronizationType, PersistenceUnitTransactionType, Map)
in class org.hibernate.jpa.criteria.CriteriaBuilderImpl

org.hibernate.jpa.internal.TransactionImpl in:
org.hibernate.jpa.spi.AbstractEntityManagerImpl.tx

Internal packages used by other jars (they will not have access to the classes because of the Private-Package nature of internal packages):

org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper - defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory - defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory - defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.engine.transaction.internal.jta.JtaStatusHelper - defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.event.internal.DefaultDeleteEventListener- defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.event.internal.DefaultFlushEntityEventListener- defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.event.internal.DefaultFlushEventListener- defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.event.internal.DefaultMergeEventListener- defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.event.internal.DefaultPersistEventListener- defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.event.internal.DefaultSaveEventListener- defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.event.internal.DefaultSaveOrUpdateEventListener- defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.event.internal.DefaultAutoFlushEventListener - defined in hibernate-core + used in hibernate-entitymanager

org.hibernate.internal.AbstractQueryImpl - defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.internal.CoreMessageLogger - defined in hibernate-core + used in nearly all other jars
org.hibernate.internal.CriteriaImpl - defined in hibernate-core + used in hibernate-envers
org.hibernate.internal.util.ReflectHelper - defined in hibernate-core + used in hibernate-envers and hibernate-entitymanager
org.hibernate.internal.util.StringHelper - defined in hibernate-core + used in hibernate-entitymanager and hibernate-proxool
org.hibernate.internal.util.ValueHolder<T> - defined in hibernate-core + used in hibernate- entitymanager
org.hibernate.internal.util.collections.CollectionHelper - defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.internal.util.collections.ConcurrentReferenceHashMap<K, V> - defined in hibernate-core + used in hibernate-envers
org.hibernate.internal.util.config.ConfigurationHelper - defined in hibernate-core + used in hibernate-envers, hibernate-entitymanager, hibernate-proxool and hibernate-c3p0
org.hibernate.internal.util.xml.XMLHelper - defined in hibernate-core + used in hibernate-envers
org.hibernate.service.classloading.internal.ClassLoaderServiceImpl - defined in hibernate-core + used in hibernate-entitymanager
org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator - defined in hibernate-core + used in hibernate-c3p0

Other findings

  • hibernate-envers doesn't have a clear split of api,spi and internal packages right now.
  • hibernate-c3p0 and hibernate-proxool have only internal packages but which are needed by hibernate-core if it needs to instanciating the ConnectionProviders which are defined in c3p0 and proxool.
    There are two ways to solve this problem in OSGI:
    • Make the hibernate-c3p0 and hibernate-proxool bundles not standalone bundle but instead make them Bundle-Fragments which can be attached to the hibernate-core bundle. This guaranties, that the classes defined in c3p0 and proxool are visible by core.
    • Another version would be, that hibernate-c3p0 and hibernate-proxool are complet bundles but only announce a new ConnectionProvider services within OSGI. hibernate-core can get the ConnectionProviders via the OSGI service registry when it needs them (by searching services which implement the interface org.hibernate.service.jdbc.connections.spi.ConnectionProvider). So no classloading magic is needed to get it done, when the jar files are used as osgi bundles.

The second approach would be the preferred solution in my opinion - accessing services by class names is not the osgi way. To implement this behaviour, hibernate-core needs to extend his classloading with a way to incorporate osgi service lookup when it needs access to classes/services that are not found via the classpath of hibernate-core.

  • The same approach could be used for hibernate-ehcache and hibernate-infinispan - they could announce osgi services which implement the interface org.hibernate.cache.spi.RegionFactory and hibernate-core can get the services via the osg service registry.
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira