<style>
/* Changing the layout to use less space for mobiles */
@media screen and (max-device-width: 480px), screen and (-webkit-min-device-pixel-ratio: 2) {
    #email-body { min-width: 30em !important; }
    #email-page { padding: 8px !important; }
    #email-banner { padding: 8px 8px 0 8px !important; }
    #email-avatar { margin: 1px 8px 8px 0 !important; padding: 0 !important; }
    #email-fields { padding: 0 8px 8px 8px !important; }
    #email-gutter { width: 0 !important; }
}
</style>
<div id="email-body">
<table id="email-wrap" align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#f0f0f0;color:#000000;width:100%;">
    <tr valign="top">
        <td id="email-page" style="padding:16px !important;">
            <table align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#ffffff;border:1px solid #bbbbbb;color:#000000;width:100%;">
                <tr valign="top">
                    <td bgcolor="#3e4c4e" style="background-color:#3e4c4e;color:#ffffff;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;line-height:1;"><img src="https://www.jboss.org/dms/hibernate/images/jira/jiraheader_hibernate.png" alt="" style="vertical-align:top;" /></td>
                </tr><tr valign="top">
    <td id="email-banner" style="padding:32px 32px 0 32px;">

                
        
        
            <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;">
    <tr valign="top">
        <td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;padding:0;">
                                        <img id="email-avatar" src="https://hibernate.onjira.com/secure/useravatar?ownerId=neimeier&avatarId=11040" alt="" height="48" width="48" border="0" align="left" style="padding:0;margin: 0 16px 16px 0;" />
                        <div id="email-action" style="padding: 0 0 8px 0;font-size:12px;line-height:18px;">
                                    <a class="user-hover" rel="neimeier" id="email_neimeier" href="https://hibernate.onjira.com/secure/ViewProfile.jspa?name=neimeier" style="color:#6c797f;">Martin Neimeier</a>
     commented on <img src="https://hibernate.onjira.com/images/icons/newfeature.gif" height="16" width="16" border="0" align="absmiddle" alt="New Feature"> <a style='color:#6c797f;text-decoration:none;' href='https://hibernate.onjira.com/browse/HHH-7527'>HHH-7527</a>
            </div>
                        <div id="email-summary" style="font-size:16px;line-height:20px;padding:2px 0 16px 0;">
                <a style='color:#6c797f;text-decoration:none;' href='https://hibernate.onjira.com/browse/HHH-7527'><strong>OSGI manifests for hibernate-orm</strong></a>
            </div>
                    </td>
    </tr>
</table>
    </td>
</tr>
<tr valign="top">
    <td id="email-fields" style="padding:0 32px 32px 32px;">
        <table border="0" cellpadding="0" cellspacing="0" style="padding:0;text-align:left;width:100%;" width="100%">
            <tr valign="top">
                <td id="email-gutter" style="width:64px;white-space:nowrap;"></td>
                <td>
                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                        <tr valign="top">
    <td colspan="2" style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0 0 16px 0;width:100%;">
        <div class="comment-block" style="background-color:#edf5ff;border:1px solid #dddddd;color:#000000;padding:12px;"><p>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:</p>

<ul>
        <li>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.</li>
        <li>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.</li>
        <li>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.</li>
        <li>The remaining packages will be marked as API packages - they will be included in the Export-Package section of the OSGI manifest.</li>
</ul>


<p>In the first review I have identified the following problems (no guaranty for completeness)</p>

<h1><a name="InternalPackagesexposedininterfaceofAPI%2FSPIClass"></a>Internal Packages exposed in interface of API/SPI-Class</h1>
<p>org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.BulkOperationCleanupAction)<br/>
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.CollectionRecreateAction)<br/>
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.CollectionRemoveAction)<br/>
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.CollectionUpdateAction)<br/>
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.EntityDeleteAction)<br/>
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.EntityIdentityInsertAction)<br/>
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.EntityInsertAction)<br/>
org.hibernate.engine.spi.ActionQueue.addAction(org.hibernate.action.internal.EntityUpdateAction)<br/>
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<br/>
org.hibernate.loader.Loader.scroll(QueryParameters, Type[], org.hibernate.hql.internal.HolderInstantiator, SessionImplementor)<br/>
org.hibernate.loader.hql.QueryLoader.QueryLoader(org.hibernate.hql.internal.ast.QueryTranslatorImpl, SessionFactoryImplementor, org.hibernate.hql.internal.ast.tree.SelectClause)<br/>
org.hibernate.loader.hql.QueryLoader.getAggregatedSelectExpression() return type is org.hibernate.hql.internal.ast.tree.AggregatedSelectExpression<br/>
org.hibernate.loader.criteria.ScalarCollectionCriteriaInfoProvider.ScalarCollectionCriteriaInfoProvider(org.hibernate.hql.internal.ast.util.SessionFactoryHelper, String)</p>

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

<p>   org.hibernate.internal.jaxb.JaxbRoot&lt;T&gt; in:<br/>
org.hibernate.metamodel.source.hbm.MappingDocument.getJaxbRoot()<br/>
org.hibernate.metamodel.source.hbm.MappingDocument.MappingDocument(JaxbRoot&lt;JaxbHibernateMapping&gt;, MetadataImplementor)</p>

<p>   org.hibernate.internal.jaxb.Origin in:<br/>
org.hibernate.metamodel.source.LocalBindingContext.getOrigin()<br/>
and several other places</p>

<p>   org.hibernate.internal.jaxb.mapping.hbm.CustomSqlElement in:<br/>
org.hibernate.metamodel.source.hbm.Helper.buildCustomSql(CustomSqlElement)</p>

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

<p>   org.hibernate.internal.jaxb.mapping.hbm.PluralAttributeElement in:<br/>
org.hibernate.metamodel.source.hbm.AbstractPluralAttributeSourceImpl.AbstractPluralAttributeSourceImpl(PluralAttributeElement, AttributeSourceContainer)</p>

<p>   org.hibernate.internal.util.xml.XmlDocument in:<br/>
org.hibernate.cfg.Configuration.add(XmlDocument)</p>

<p>   org.hibernate.metamodel.source.internal.MetadataImpl in:<br/>
org.hibernate.metamodel.source.annotations.AnnotationMetadataSourceProcessorImpl.AnnotationMetadataSourceProcessorImpl(MetadataImpl)</p>

<p>   org.hibernate.cache.ehcache.internal.strategy.EhcacheAccessStrategyFactory in: <br/>
org.hibernate.cache.ehcache.AbstractEhcacheRegionFactory.accessStrategyFactory</p>

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

<p>   org.hibernate.jpa.internal.TransactionImpl in:<br/>
org.hibernate.jpa.spi.AbstractEntityManagerImpl.tx</p>


<h1><a name="Internalpackagesusedbyotherjars%28theywillnothaveaccesstotheclassesbecauseofthePrivatePackagenatureofinternalpackages%29%3A"></a>Internal packages used by other jars (they will not have access to the classes because of the Private-Package nature of internal packages):</h1>
<p>org.hibernate.bytecode.instrumentation.internal.FieldInterceptionHelper - defined in hibernate-core + used in hibernate-entitymanager<br/>
org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory - defined in hibernate-core + used in hibernate-entitymanager <br/>
org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory - defined in hibernate-core + used in hibernate-entitymanager<br/>
org.hibernate.engine.transaction.internal.jta.JtaStatusHelper - defined in hibernate-core + used in hibernate-entitymanager<br/>
org.hibernate.event.internal.DefaultDeleteEventListener- defined in hibernate-core + used in hibernate-entitymanager<br/>
org.hibernate.event.internal.DefaultFlushEntityEventListener- defined in hibernate-core + used in hibernate-entitymanager<br/>
org.hibernate.event.internal.DefaultFlushEventListener- defined in hibernate-core + used in hibernate-entitymanager<br/>
org.hibernate.event.internal.DefaultMergeEventListener- defined in hibernate-core + used in hibernate-entitymanager<br/>
org.hibernate.event.internal.DefaultPersistEventListener- defined in hibernate-core + used in hibernate-entitymanager<br/>
org.hibernate.event.internal.DefaultSaveEventListener- defined in hibernate-core + used in hibernate-entitymanager<br/>
org.hibernate.event.internal.DefaultSaveOrUpdateEventListener- defined in hibernate-core + used in hibernate-entitymanager<br/>
org.hibernate.event.internal.DefaultAutoFlushEventListener - defined in hibernate-core + used in hibernate-entitymanager</p>

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


<h1><a name="Otherfindings"></a>Other findings</h1>
<ul>
        <li>hibernate-envers doesn't have a clear split of api,spi and internal packages right now.</li>
        <li>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.<br/>
   There are two ways to solve this problem in OSGI:
        <ul>
                <li>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.</li>
                <li>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.</li>
        </ul>
        </li>
</ul>


<p>  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.</p>

<ul>
        <li>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.</li>
</ul>
</div>
        <div style="color:#505050;padding:4px 0 0 0;">                </div>
    </td>
</tr>
                    </table>
                </td>
            </tr>
        </table>
    </td>
</tr>













            </table>
        </td><!-- End #email-page -->
    </tr>
    <tr valign="top">
        <td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:10px;line-height:14px;padding: 0 16px 16px 16px;text-align:center;">
            This message is automatically generated by JIRA.<br />
            If you think it was sent incorrectly, please contact your <a style='color:#6c797f;' href='https://hibernate.onjira.com/secure/ContactAdministrators!default.jspa'>JIRA administrators</a>.<br />
            For more information on JIRA, see: <a style='color:#6c797f;' href='http://www.atlassian.com/software/jira'>http://www.atlassian.com/software/jira</a>
        </td>
    </tr>
</table><!-- End #email-wrap -->
</div><!-- End #email-body -->