|
From: <one...@us...> - 2003-01-26 02:37:05
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg
In directory sc8-pr-cvs1:/tmp/cvs-serv30323/sf/hibernate/cfg
Modified Files:
Configuration.java
Log Message:
javadoc for Configuration
Index: Configuration.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Configuration.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Configuration.java 26 Jan 2003 01:33:34 -0000 1.4
--- Configuration.java 26 Jan 2003 02:37:02 -0000 1.5
***************
*** 45,51 ****
/**
! * NOT threadsafe
*/
-
public class Configuration implements Mapping {
--- 45,63 ----
/**
! * An instance of <tt>Configuration</tt> allows the application
! * to specify properties and mapping documents to be used when
! * creating a <tt>SessionFactory</tt>. Usually an application will create
! * a single <tt>Configuration</tt>, build a single instance of
! * <tt>SessionFactory</tt> and then instantiate <tt>Session</tt>s in
! * threads servicing client requests. The <tt>Configuration</tt> is meant
! * only as an initialization-time object. <tt>SessionFactory</tt>s are
! * immutable and do not retain any association back to the
! * <tt>Configuration</tt>.<br>
! * <br>
! * A new <tt>Configuration</tt> will use the properties specified in
! * <tt>hibernate.properties</tt> by default.
! *
! * @see net.sf.hibernate.SessionFactory
*/
public class Configuration implements Mapping {
***************
*** 59,82 ****
--- 71,113 ----
private static Log log = LogFactory.getLog(Configuration.class);
+ /**
+ * Returns the identifier type of a mapped class
+ */
public Type getIdentifierType(Class persistentClass) throws MappingException {
return ( (PersistentClass) classes.get(persistentClass) ).getIdentifier().getType();
}
+ /**
+ * Iterate the class mappings
+ */
public Iterator getClassMappings() {
return classes.values().iterator();
}
+ /**
+ * Iterate the collection mappings
+ */
public Iterator getCollectionMappings() {
return collections.values().iterator();
}
+ /**
+ * Iterate the table mappings
+ */
private Iterator getTableMappings() {
return tables.values().iterator();
}
+ /**
+ * Get the mapping for a particular class
+ */
public PersistentClass getClassMapping(Class persistentClass) {
return (PersistentClass) classes.get(persistentClass);
}
+ /**
+ * Read mappings from a particular XML file
+ * @param xmlFile a path to a file
+ */
public Configuration addFile(String xmlFile) throws MappingException {
log.info("Mapping file: " + xmlFile);
***************
*** 91,94 ****
--- 122,129 ----
}
+ /**
+ * Read mappings from a <tt>String</tt>
+ * @param xml an XML string
+ */
public Configuration addXML(String xml) throws MappingException {
if ( log.isDebugEnabled() ) log.debug("Mapping XML:\n" + xml);
***************
*** 103,106 ****
--- 138,145 ----
}
+ /**
+ * Read mappings from a DOM <tt>Document</tt>
+ * @param doc a DOM document
+ */
public Configuration addDocument(Document doc) throws MappingException {
if ( log.isDebugEnabled() ) log.debug("Mapping XML:\n" + doc);
***************
*** 125,128 ****
--- 164,171 ----
}
+ /**
+ * Read mappings from an <tt>InputStream</tt>
+ * @param xmlInputStream an <tt>InputStream</tt> containing XML
+ */
public Configuration addInputStream(InputStream xmlInputStream) throws MappingException {
try {
***************
*** 139,142 ****
--- 182,190 ----
}
+ /**
+ * Read mappings from an application resource
+ * @param path a resource
+ * @param classLoader a <tt>ClassLoader</tt> to use
+ */
public Configuration addResource(String path, ClassLoader classLoader) throws MappingException {
log.info("Mapping resource: " + path);
***************
*** 146,149 ****
--- 194,202 ----
}
+ /**
+ * Read a mapping from an application resource, using a convention.
+ * The class <tt>foo.bar.Foo</tt> is mapped by the file <tt>foo/bar/Foo.hbm.xml</tt>.
+ * @param persistentClass the mapped class
+ */
public Configuration addClass(Class persistentClass) throws MappingException {
String fileName = persistentClass.getName().replace(StringHelper.DOT,'/') + ".hbm.xml";
***************
*** 154,157 ****
--- 207,214 ----
}
+ /**
+ * Read all mappings from a jar file
+ * @param resource an application resource (a jar file)
+ */
public Configuration addJar(String resource) throws MappingException {
***************
*** 207,210 ****
--- 264,270 ----
}
+ /**
+ * Generate DDL for dropping tables
+ */
public String[] generateDropSchemaScript(Dialect dialect) throws HibernateException {
***************
*** 241,244 ****
--- 301,307 ----
}
+ /**
+ * Generate DDL for creating tables
+ */
public String[] generateSchemaCreationScript(Dialect dialect) throws HibernateException {
secondPassCompile();
***************
*** 282,285 ****
--- 345,351 ----
}
+ /**
+ * Generate DDL for altering tables
+ */
public String[] generateSchemaUpdateScript(Dialect dialect, JdbcDatabaseInfo databaseInfo) throws HibernateException {
secondPassCompile();
***************
*** 365,368 ****
--- 431,437 ----
}
+ /**
+ * Get the named queries
+ */
public Map getNamedQueries() {
return namedQueries;
***************
*** 426,429 ****
--- 495,507 ----
}
+ /**
+ * Instantiate a new <tt>SessionFactory</tt>, using the properties and
+ * mappings in this configuration. The <tt>SessionFactory</tt> will be
+ * immutable, so changes made to the <tt>Configuration</tt> after
+ * building the <tt>SessionFactory</tt> will not affect it.
+ *
+ * @see net.sf.hibernate.SessionFactory
+ * @return a new factory for <tt>Session</tt>s
+ */
public SessionFactory buildSessionFactory() throws HibernateException {
secondPassCompile();
***************
*** 434,457 ****
}
public Interceptor getInterceptor() {
return interceptor;
}
!
public Properties getProperties() {
return properties;
}
! public void setInterceptor(Interceptor interceptor) {
this.interceptor = interceptor;
}
! public void setProperties(Properties properties) {
this.properties = properties;
}
public void setProperty(String propertyName, String value) {
properties.setProperty(propertyName, value);
}
public String getProperty(String propertyName) {
return properties.getProperty(propertyName);
--- 512,555 ----
}
+ /**
+ * Return the configured <tt>Interceptor</tt>
+ */
public Interceptor getInterceptor() {
return interceptor;
}
!
! /**
! * Get all properties
! */
public Properties getProperties() {
return properties;
}
! /**
! * Configure an <tt>Interceptor</tt>
! */
! public Configuration setInterceptor(Interceptor interceptor) {
this.interceptor = interceptor;
+ return this;
}
! /**
! * Specify a completely new set of properties
! */
! public Configuration setProperties(Properties properties) {
this.properties = properties;
+ return this;
}
+ /**
+ * Set a property
+ */
public void setProperty(String propertyName, String value) {
properties.setProperty(propertyName, value);
}
+ /**
+ * Get a property
+ */
public String getProperty(String propertyName) {
return properties.getProperty(propertyName);
***************
*** 491,499 ****
}
! public void configure() throws HibernateException {
configure("hibernate.cfg.xml");
}
! public void configure(String resource) throws HibernateException {
InputStream stream = getConfigurationInputStream(resource);
--- 589,607 ----
}
! /**
! * Use the mappings and properties specified in an application
! * resource named <tt>hibernate.cfg.xml</tt>.
! */
! public Configuration configure() throws HibernateException {
configure("hibernate.cfg.xml");
+ return this;
}
! /**
! * Use the mappings and properties specified in the given application
! * resource. The format of the resource is defined in
! * <tt>hibernate-configuration.dtd</tt>.
! */
! public Configuration configure(String resource) throws HibernateException {
InputStream stream = getConfigurationInputStream(resource);
***************
*** 546,549 ****
--- 654,659 ----
log.info("Configured SessionFactory: " + name);
log.debug("properties: " + properties);
+
+ return this;
}
|