[
https://jira.jboss.org/jira/browse/GTNPORTAL-192?page=com.atlassian.jira....
]
Boleslaw Dawidowicz commented on GTNPORTAL-192:
-----------------------------------------------
I wanted to do it this way initially but AFAIR it was just some bad timing and issues
during initial code merge... will look again at this.
JBossIDMService should user database's configuration instead of
replicate it
----------------------------------------------------------------------------
Key: GTNPORTAL-192
URL:
https://jira.jboss.org/jira/browse/GTNPORTAL-192
Project: GateIn Portal
Issue Type: Feature Request
Affects Versions: 3.0.0-Beta02
Reporter: Rafael Liu
Assignee: Boleslaw Dawidowicz
Priority: Minor
JBossIDMService is replicating all Hibernate configurations already specified in
database-configuration.xml in idm-configuration.xml. Instead, HibernateServiceImpl should
be patched with something like:
public void addPlugin(ComponentPlugin plugin) {
if (plugin instanceof AddHibernateMappingPlugin) {
AddHibernateMappingPlugin impl = (AddHibernateMappingPlugin) plugin;
try {
List path = impl.getMapping();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
for (int i = 0; i < path.size(); i++) {
String relativePath = (String) path.get(i);
if (!mappings_.contains(relativePath)) {
mappings_.add(relativePath);
URL url = cl.getResource(relativePath);
log_.info("Adding Hibernate Mapping: " + relativePath);
conf_.addURL(url);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
+ } else if (plugin instanceof AddHibernateAnnotationPlugin) {
+ AddHibernateAnnotationPlugin impl = (AddHibernateAnnotationPlugin) plugin;
+ try {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ for (int i = 0; i < path.size(); i++) {
+ String fsClazz = (String) path.get(i);
+ Class clazz = cl.loadClass(fsClazz);
+ conf_.addAnnotation(clazz);
+ log_.info("Adding Hibernate Annotation: " + relativePath);
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
}
}
}
Then create a new AddHibernateAnnotationPlugin class and reutilize HibernateService:
<external-component-plugins>
<target-component>org.exoplatform.services.database.HibernateService</target-component>
<component-plugin>
<name>add.hibernate.mapping</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.services.database.impl.AddHibernateAnnotationPlugin</type>
<priority>1</priority> <!-- carregue depois
-->
<init-params>
<values-param>
<name>hibernate.mapping</name>
<value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject</value>
<value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</value>
<value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute</value>
<value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttributeValue</value>
<value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential</value>
<value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</value>
<value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</value>
<value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</value>
<value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</value>
<value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute</value>
<value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType</value>
<value>org.jboss.identity.idm.impl.model.hibernate.HibernateRealm</value>
</values-param>
</init-params>
</component-plugin>
</external-component-plugins>
And using IoC, inject HibernateService in your constructor:
public JBossIDMService(
HibernateService hibernateService
) throws Exception {
// do something
}
Don't know why that wasn't done this way.. That was probably because
HibernateService doesn't support Annotations, only HBMs..
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira