Update of
/cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6547/modules/hibernate/src/xdoclet/modules/hibernate
Modified Files:
HibernateCfgSubTask.java HibernateSubTask.java
Log Message:
Updated for generating HIbernate 3.0 DTDs in the mapping and configuration
documents.
Index: HibernateCfgSubTask.java
===================================================================
RCS file:
/cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/HibernateCfgSubTask.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** HibernateCfgSubTask.java 7 Sep 2004 13:37:12 -0000 1.9
--- HibernateCfgSubTask.java 3 Apr 2005 10:22:34 -0000 1.10
***************
*** 21,24 ****
--- 21,25 ----
*
* @author <a href="mailto:fbrier at users.sourceforge.net">Frederick
N. Brier</a>
+ * @author <a href="mailto:dchannon at users.sourceforge.net">David
Channon</a>
* @created February 6, 2004
* @version $Revision$
***************
*** 34,37 ****
--- 35,45 ----
private final static String DTD_FILE_NAME_20 =
"resources/hibernate-configuration-2.0.dtd";
+
+ private final static String HIBERNATE_PUBLICID_30 =
"-//Hibernate/Hibernate Configuration DTD 3.0//EN";
+
+ private final static String HIBERNATE_SYSTEMID_30 =
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd";
+
+ private final static String DTD_FILE_NAME_30 =
"resources/hibernate-configuration-3.0.dtd";
+
/**
* Default template to use for hibernate files
***************
*** 44,47 ****
--- 52,56 ----
private static String GENERATED_CONFIG_FILE_NAME = "hibernate.cfg.xml";
+ private String hibernateVersion = HibernateCFGVersion.HIBERNATE_2_0;
private String jndiName = null;
private String dataSource = null;
***************
*** 75,81 ****
setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
setDestinationFile(GENERATED_CONFIG_FILE_NAME);
! setPublicId(HIBERNATE_PUBLICID_20);
! setSystemId(HIBERNATE_SYSTEMID_20);
! setDtdURL(getClass().getResource(DTD_FILE_NAME_20));
}
--- 84,97 ----
setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
setDestinationFile(GENERATED_CONFIG_FILE_NAME);
! }
!
! /**
! * Get the Hibernate configuration DTD version.
! *
! * @return
! */
! public String getVersion()
! {
! return hibernateVersion;
}
***************
*** 198,201 ****
--- 214,228 ----
/**
+ * Sets the hibernate configuration DTD version to use. Legal values are
"2.0" and "3.0".
+ *
+ * @param version
+ * @ant.not-required No. Default is "2.0".
+ */
+ public void setVersion(HibernateCFGVersion version)
+ {
+ hibernateVersion = version.getValue();
+ }
+
+ /**
* Automatically export schema DDL to the database when the
SessionFactory is created. With create-drop, the
* database schema will be dropped when the SessionFactory is closed
explicitely. eg. update | create | create-drop
***************
*** 400,403 ****
--- 427,451 ----
}
+ /**
+ * Generate Hibernate Configuration file (hibernate.cfg.xml).
+ *
+ * @exception XDocletException
+ */
+ public void execute() throws XDocletException
+ {
+ if (hibernateVersion.equals(HibernateCFGVersion.HIBERNATE_2_0)) {
+ setPublicId(HIBERNATE_PUBLICID_20);
+ setSystemId(HIBERNATE_SYSTEMID_20);
+ setDtdURL(getClass().getResource(DTD_FILE_NAME_20));
+ }
+ else {
+ setPublicId(HIBERNATE_PUBLICID_30);
+ setSystemId(HIBERNATE_SYSTEMID_30);
+ setDtdURL(getClass().getResource(DTD_FILE_NAME_30));
+ }
+
+ startProcess();
+ }
+
public void validateOptions() throws XDocletException
{
***************
*** 477,479 ****
--- 525,550 ----
}
+ /**
+ * Based on Matt Raible's code for the Hibernate sub-task.
+ *
+ * @author <a href="mailto:dchannon at users.sourceforge.net">David
Channon</a>
+ * @created April 02, 2005
+ */
+ public static class HibernateCFGVersion extends
org.apache.tools.ant.types.EnumeratedAttribute
+ {
+ public final static String HIBERNATE_2_0 = "2.0";
+ public final static String HIBERNATE_3_0 = "3.0";
+
+ /**
+ * Gets the Values attribute of the HibernateCFGVersion object.
+ *
+ * @return The Values value
+ */
+ public java.lang.String[] getValues()
+ {
+ return (new java.lang.String[]{
+ HIBERNATE_2_0, HIBERNATE_3_0
+ });
+ }
+ }
}
Index: HibernateSubTask.java
===================================================================
RCS file:
/cvsroot/xdoclet/xdoclet/modules/hibernate/src/xdoclet/modules/hibernate/HibernateSubTask.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** HibernateSubTask.java 14 Aug 2004 16:07:43 -0000 1.11
--- HibernateSubTask.java 3 Apr 2005 10:22:34 -0000 1.12
***************
*** 14,20 ****
/**
! * This task generates Hibernate xml mapping file for a given class. Supports
Hibernate 1.1 & 2.0.
*
* @author S�bastien Guimont ([EMAIL PROTECTED])
* @created August 9th, 2002
* @version $Revision$
--- 14,21 ----
/**
! * This task generates Hibernate xml mapping file for a given class. Supports
Hibernate 1.1, 2.0, 2.1 & 3.0.
*
* @author S�bastien Guimont ([EMAIL PROTECTED])
+ * @author <a href="mailto:dchannon at
users.sourceforge.net">David Channon</a>
* @created August 9th, 2002
* @version $Revision$
***************
*** 45,48 ****
--- 46,55 ----
private final static String DTD_FILE_NAME_20 =
"resources/hibernate-mapping_2_0.dtd";
+ private final static String HIBERNATE_PUBLICID_30 =
"-//Hibernate/Hibernate Mapping DTD 3.0//EN";
+
+ private final static String HIBERNATE_SYSTEMID_30 =
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd";
+
+ private final static String DTD_FILE_NAME_30 =
"resources/hibernate-mapping_3_0.dtd";
+
/**
* Default template to use for hibernate files.
***************
*** 93,97 ****
/**
! * Sets the hibernate version to use. Legal values are "1.1", "2.0" and
"2.1".
*
* @param version
--- 100,104 ----
/**
! * Sets the hibernate version to use. Legal values are "1.1", "2.0",
"2.1" and "3.0".
*
* @param version
***************
*** 116,124 ****
setDtdURL(getClass().getResource(DTD_FILE_NAME_11));
}
! else {
setPublicId(HIBERNATE_PUBLICID_20);
setSystemId(HIBERNATE_SYSTEMID_20);
setDtdURL(getClass().getResource(DTD_FILE_NAME_20));
}
startProcess();
}
--- 123,137 ----
setDtdURL(getClass().getResource(DTD_FILE_NAME_11));
}
! if (hibernateVersion.equals(HibernateVersion.HIBERNATE_2_0) ||
! hibernateVersion.equals(HibernateVersion.HIBERNATE_2_1)) {
setPublicId(HIBERNATE_PUBLICID_20);
setSystemId(HIBERNATE_SYSTEMID_20);
setDtdURL(getClass().getResource(DTD_FILE_NAME_20));
}
+ else {
+ setPublicId(HIBERNATE_PUBLICID_30);
+ setSystemId(HIBERNATE_SYSTEMID_30);
+ setDtdURL(getClass().getResource(DTD_FILE_NAME_30));
+ }
startProcess();
}
***************
*** 158,161 ****
--- 171,175 ----
public final static String HIBERNATE_2_0 = "2.0";
public final static String HIBERNATE_2_1 = "2.1";
+ public final static String HIBERNATE_3_0 = "3.0";
/**
***************
*** 167,171 ****
{
return (new java.lang.String[]{
! HIBERNATE_1_1, HIBERNATE_2_0, HIBERNATE_2_1
});
}
--- 181,185 ----
{
return (new java.lang.String[]{
! HIBERNATE_1_1, HIBERNATE_2_0, HIBERNATE_2_1, HIBERNATE_3_0
});
}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
xdoclet-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel