[jboss-cvs] JBossAS SVN: r104838 - in branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/deployers: metadata and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun May 16 15:08:05 EDT 2010
Author: alesj
Date: 2010-05-16 15:08:04 -0400 (Sun, 16 May 2010)
New Revision: 104838
Modified:
branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/deployers/HibernateDeployer.java
branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/deployers/metadata/HibernateMetaData.java
Log:
[JBPAPP-4176]; support multiple sessions in metadata
Modified: branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/deployers/HibernateDeployer.java
===================================================================
--- branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/deployers/HibernateDeployer.java 2010-05-16 15:12:13 UTC (rev 104837)
+++ branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/deployers/HibernateDeployer.java 2010-05-16 19:08:04 UTC (rev 104838)
@@ -21,6 +21,8 @@
*/
package org.jboss.hibernate.deployers;
+import java.util.List;
+
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
@@ -28,6 +30,7 @@
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.hibernate.deployers.metadata.HibernateMetaData;
import org.jboss.hibernate.deployers.metadata.SessionFactoryMetaData;
+import org.jboss.virtual.VirtualFile;
/**
* Hibernate deployer.
@@ -49,18 +52,22 @@
if (unit instanceof VFSDeploymentUnit == false)
return;
- SessionFactoryMetaData sessionFactoryMetaData = metaData.getSessionFactory();
- if (sessionFactoryMetaData == null)
+ List<SessionFactoryMetaData> sessionFactoryMetaDatas = metaData.getSessionFactories();
+ if (sessionFactoryMetaDatas == null || sessionFactoryMetaDatas.isEmpty())
return;
VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
if (scanFromTop)
vfsUnit = vfsUnit.getTopLevel();
- // build the hibernate bean
- BeanMetaData beanMetaData = sessionFactoryMetaData.getBeanMetaData(vfsUnit.getRoot());
- vfsUnit.addAttachment(BeanMetaData.class + "$Hibernate", beanMetaData);
- log.info("Created Hibernate bean: " + beanMetaData);
+ VirtualFile root = vfsUnit.getRoot();
+ for (int i = 0; i < sessionFactoryMetaDatas.size(); i++)
+ {
+ // build the hibernate bean
+ BeanMetaData beanMetaData = sessionFactoryMetaDatas.get(i).getBeanMetaData(root);
+ vfsUnit.addAttachment(BeanMetaData.class + "$Hibernate#" + (i + 1), beanMetaData);
+ log.debug("Created Hibernate bean: " + beanMetaData);
+ }
}
/**
@@ -74,3 +81,4 @@
this.scanFromTop = scanFromTop;
}
}
+
Modified: branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/deployers/metadata/HibernateMetaData.java
===================================================================
--- branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/deployers/metadata/HibernateMetaData.java 2010-05-16 15:12:13 UTC (rev 104837)
+++ branches/JBPAPP_5_1/hibernate-int/src/main/org/jboss/hibernate/deployers/metadata/HibernateMetaData.java 2010-05-16 19:08:04 UTC (rev 104838)
@@ -22,6 +22,7 @@
package org.jboss.hibernate.deployers.metadata;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -41,30 +42,36 @@
*/
@JBossXmlSchema(namespace="urn:jboss:hibernate-deployer:1.0", elementFormDefault=XmlNsForm.QUALIFIED, replacePropertyRefs=false)
@XmlRootElement(name="hibernate-configuration")
- at XmlType(name="hibernateConfigurationType", propOrder={"sessionFactory"})
+ at XmlType(name="hibernateConfigurationType", propOrder={"sessionFactories"})
public class HibernateMetaData implements Serializable, BeanMetaDataFactory
{
- private static final long serialVersionUID = 1;
+ private static final long serialVersionUID = 2;
- private SessionFactoryMetaData sessionFactory;
+ private List<SessionFactoryMetaData> sessionFactories;
- public SessionFactoryMetaData getSessionFactory()
+ public List<SessionFactoryMetaData> getSessionFactories()
{
- return sessionFactory;
+ return sessionFactories;
}
@XmlElement(name = "session-factory")
- public void setSessionFactory(SessionFactoryMetaData sessionFactory)
+ public void setSessionFactories(List<SessionFactoryMetaData> sessionFactories)
{
- this.sessionFactory = sessionFactory;
+ this.sessionFactories = sessionFactories;
}
@XmlTransient
public List<BeanMetaData> getBeans()
{
- if (sessionFactory != null)
- return Collections.singletonList(sessionFactory.getBeanMetaData());
+ if (sessionFactories != null && sessionFactories.isEmpty() == false)
+ {
+ List<BeanMetaData> bmds = new ArrayList<BeanMetaData>();
+ for (SessionFactoryMetaData sfmd : sessionFactories)
+ bmds.add(sfmd.getBeanMetaData());
+ return bmds;
+ }
else
return Collections.emptyList();
}
}
+
More information about the jboss-cvs-commits
mailing list