From: <one...@us...> - 2003-01-04 11:16:00
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg In directory sc8-pr-cvs1:/tmp/cvs-serv14211/src/net/sf/hibernate/cfg Modified Files: Configuration.java Datastore.java Log Message: reformatted code with beautiful, shiny, happy TABS! improved an exception Index: Configuration.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Configuration.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Configuration.java 1 Jan 2003 13:53:55 -0000 1.1.1.1 --- Configuration.java 4 Jan 2003 11:15:27 -0000 1.2 *************** *** 17,21 **** * <pre> * <?xml version='1.0' encoding='utf-8'?> ! * <!DOCTYPE hibernate-configuration PUBLIC * "-//Hibernate/Hibernate Configuration DTD//EN" * "http://hibernate.sourceforge.net/hibernate-configuration.dtd"> --- 17,21 ---- * <pre> * <?xml version='1.0' encoding='utf-8'?> ! * <!DOCTYPE hibernate-configuration PUBLIC * "-//Hibernate/Hibernate Configuration DTD//EN" * "http://hibernate.sourceforge.net/hibernate-configuration.dtd"> *************** *** 58,62 **** private Log log = LogFactory.getLog(Configuration.class); ! private String resource; --- 58,62 ---- private Log log = LogFactory.getLog(Configuration.class); ! private String resource; *************** *** 66,70 **** protected Configuration() { } ! public Configuration(String resource) { this.resource = resource; --- 66,70 ---- protected Configuration() { } ! public Configuration(String resource) { this.resource = resource; *************** *** 77,81 **** */ protected InputStream getConfigurationInputStream() throws HibernateException { ! log.info("Configuration resource: " + resource); --- 77,81 ---- */ protected InputStream getConfigurationInputStream() throws HibernateException { ! log.info("Configuration resource: " + resource); *************** *** 86,92 **** } return stream; ! } ! private void addProperties(Node parent, Properties properties) { NodeList children = parent.getChildNodes(); --- 86,92 ---- } return stream; ! } ! private void addProperties(Node parent, Properties properties) { NodeList children = parent.getChildNodes(); *************** *** 103,107 **** Environment.verifyProperties(properties); }; ! public SessionFactory[] configure() throws HibernateException { --- 103,107 ---- Environment.verifyProperties(properties); }; ! public SessionFactory[] configure() throws HibernateException { *************** *** 109,113 **** InputStream stream = getConfigurationInputStream(); ! Document doc; try { --- 109,113 ---- InputStream stream = getConfigurationInputStream(); ! Document doc; try { *************** *** 121,125 **** topLevelProps.putAll( Environment.getProperties() ); addProperties( doc.getDocumentElement(), topLevelProps ); ! NodeList sfElements = doc.getDocumentElement().getElementsByTagName("session-factory"); for ( int i=0; i<sfElements.getLength(); i++ ) { --- 121,125 ---- topLevelProps.putAll( Environment.getProperties() ); addProperties( doc.getDocumentElement(), topLevelProps ); ! NodeList sfElements = doc.getDocumentElement().getElementsByTagName("session-factory"); for ( int i=0; i<sfElements.getLength(); i++ ) { *************** *** 131,135 **** Datastore ds = Hibernate.createDatastore(); ! NodeList mapElements = sfNode.getChildNodes(); for ( int j=0; j<mapElements.getLength(); j++ ) { --- 131,135 ---- Datastore ds = Hibernate.createDatastore(); ! NodeList mapElements = sfNode.getChildNodes(); for ( int j=0; j<mapElements.getLength(); j++ ) { *************** *** 153,157 **** ds.storeJar( jar.getNodeValue() ); } ! else { if (file==null) throw new HibernateException("<mapping> element in configuration specifies no attributes"); log.debug(name + "<-" + file); --- 153,157 ---- ds.storeJar( jar.getNodeValue() ); } ! else { if (file==null) throw new HibernateException("<mapping> element in configuration specifies no attributes"); log.debug(name + "<-" + file); *************** *** 160,164 **** } } ! factories.add( ds.buildSessionFactory(props) ); --- 160,164 ---- } } ! factories.add( ds.buildSessionFactory(props) ); *************** *** 172,173 **** --- 172,176 ---- } } + + + Index: Datastore.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Datastore.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Datastore.java 1 Jan 2003 13:53:55 -0000 1.1.1.1 --- Datastore.java 4 Jan 2003 11:15:27 -0000 1.2 *************** *** 14,163 **** import net.sf.hibernate.tool.hbm2ddl.JdbcDatabaseInfo; ! /** ! An instance of <tt>Datastore</tt> represents an entire mapping from a set of ! Java classes to a relational model. Usually an application will configure a ! single instance of <tt>Datastore</tt>, obtain a single instance of ! <tt>SessionFactory</tt> and then instantiate <tt>Session</tt>s in ! threads servicing client requests. The <tt>Datastore</tt> is meant as a ! configuration-time object.<br> ! <br> ! New instances are provided by the factory method ! <tt>Hibernate.createDatastore()</tt><br> ! <br> ! It is not intended that implementors be threadsafe. ! ! @see SessionFactory ! @see Hibernate#createDatastore() */ public interface Datastore { /** ! Obtain a factory for <tt>Session</tt>s. Connections may be provided by the application ! or according to System properties. ! ! @return SessionFactory ! @throws HibernateException */ public SessionFactory buildSessionFactory() throws HibernateException; ! /** ! Obtain a factory for <tt>Session</tt>s. Connections may be provided by the application ! or according to the given <tt>Properties</tt>. ! ! @param connectionProps connection properties ! @return SessionFactory ! @throws HibernateException */ public SessionFactory buildSessionFactory(Properties connectionProps) ! throws HibernateException; ! /** ! Obtain a factory for <tt>Session</tt>s, specifying an <tt>Interceptor</tt>. Connections ! may be provided by the application or according to System properties. ! ! @return SessionFactory ! @param interceptor a factory-scoped interceptor ! @throws HibernateException */ public SessionFactory buildSessionFactory(Interceptor interceptor) throws HibernateException; ! /** ! Obtain a factory for <tt>Session</tt>s, specifying an <tt>Interceptor</tt>. Connections ! may be provided by the application or according to the given <tt>Properties</tt>. ! ! @param connectionProps connection properties ! @param interceptor intercepts important session events ! @return SessionFactory ! @throws HibernateException */ public SessionFactory buildSessionFactory(Properties connectionProps, Interceptor interceptor) ! throws HibernateException; ! /** ! Load persistence mappings from an XML file. ! ! @param xmlFile the filename ! @return Datastore ! @throws MappingException */ public Datastore storeFile(String xmlFile) throws MappingException; ! /** ! Load persistence mappings from an XML file, using <tt>getResourceAsStream()</tt>. ! ! @param path the resource path ! @param classLoader the <tt>ClassLoader</tt> to use ! @return Datastore ! @throws MappingException */ public Datastore storeResource(String path, ClassLoader classLoader) ! throws MappingException; /** ! Load persistence mappings from an input stream containing XML. ! ! @param xmlInputStream an input stream containing XML data ! @return Datastore ! @throws MappingException */ public Datastore storeInputStream(InputStream xmlInputStream) ! throws MappingException; ! /** ! Load persistence mappings from a string containing XML. ! ! @param xml ! @return Datastore ! @throws MappingException */ public Datastore storeXML(String xml) throws MappingException; ! /** ! Load persistence mappings from a parsed XML document. ! ! @param doc ! @return Datastore ! @throws MappingException */ public Datastore storeDocument(Document doc) throws MappingException; ! ! /** ! Look for a mapping file for the given class using a naming convention. ! <tt>storeClass(eg.Foo.class)</tt> looks for <tt>eg/Foo.hbm.xml</tt> in ! the classpath. ! ! @param persistentClass the mapped persistent class ! @return Datastore ! @throws MappingException */ public Datastore storeClass(Class persistentClass) throws MappingException; ! /** ! Look for mapping files in a jar. Any files with names ending in <tt>.hbm.xml</tt> ! will be assumed to be mapping documents. ! ! @param resource the <tt>.jar</tt> file ! @return Datastore ! @throws MappingException */ public Datastore storeJar(String resource) throws MappingException; ! /** ! Generates a list of SQL statements that may be used to create the tables ! needed by this <tt>Datastore</tt>. ! ! @param dialect the script SQL dialect */ public String[] generateSchemaCreationScript(Dialect dialect) ! throws HibernateException; ! /** ! Generates a list of SQL statements that may be used to drop the tables ! needed by this <tt>Datastore</tt>. ! ! @param dialect the script SQL dialect */ public String[] generateDropSchemaScript(Dialect dialect) ! throws HibernateException; ! ! public String[] generateSchemaUpdateScript(Dialect dialect, JdbcDatabaseInfo info) throws HibernateException; } --- 14,166 ---- import net.sf.hibernate.tool.hbm2ddl.JdbcDatabaseInfo; ! /** ! An instance of <tt>Datastore</tt> represents an entire mapping from a set of ! Java classes to a relational model. Usually an application will configure a ! single instance of <tt>Datastore</tt>, obtain a single instance of ! <tt>SessionFactory</tt> and then instantiate <tt>Session</tt>s in ! threads servicing client requests. The <tt>Datastore</tt> is meant as a ! configuration-time object.<br> ! <br> ! New instances are provided by the factory method ! <tt>Hibernate.createDatastore()</tt><br> ! <br> ! It is not intended that implementors be threadsafe. ! ! @see SessionFactory ! @see Hibernate#createDatastore() */ public interface Datastore { /** ! Obtain a factory for <tt>Session</tt>s. Connections may be provided by the application ! or according to System properties. ! ! @return SessionFactory ! @throws HibernateException */ public SessionFactory buildSessionFactory() throws HibernateException; ! /** ! Obtain a factory for <tt>Session</tt>s. Connections may be provided by the application ! or according to the given <tt>Properties</tt>. ! ! @param connectionProps connection properties ! @return SessionFactory ! @throws HibernateException */ public SessionFactory buildSessionFactory(Properties connectionProps) ! throws HibernateException; ! /** ! Obtain a factory for <tt>Session</tt>s, specifying an <tt>Interceptor</tt>. Connections ! may be provided by the application or according to System properties. ! ! @return SessionFactory ! @param interceptor a factory-scoped interceptor ! @throws HibernateException */ public SessionFactory buildSessionFactory(Interceptor interceptor) throws HibernateException; ! /** ! Obtain a factory for <tt>Session</tt>s, specifying an <tt>Interceptor</tt>. Connections ! may be provided by the application or according to the given <tt>Properties</tt>. ! ! @param connectionProps connection properties ! @param interceptor intercepts important session events ! @return SessionFactory ! @throws HibernateException */ public SessionFactory buildSessionFactory(Properties connectionProps, Interceptor interceptor) ! throws HibernateException; ! /** ! Load persistence mappings from an XML file. ! ! @param xmlFile the filename ! @return Datastore ! @throws MappingException */ public Datastore storeFile(String xmlFile) throws MappingException; ! /** ! Load persistence mappings from an XML file, using <tt>getResourceAsStream()</tt>. ! ! @param path the resource path ! @param classLoader the <tt>ClassLoader</tt> to use ! @return Datastore ! @throws MappingException */ public Datastore storeResource(String path, ClassLoader classLoader) ! throws MappingException; /** ! Load persistence mappings from an input stream containing XML. ! ! @param xmlInputStream an input stream containing XML data ! @return Datastore ! @throws MappingException */ public Datastore storeInputStream(InputStream xmlInputStream) ! throws MappingException; ! /** ! Load persistence mappings from a string containing XML. ! ! @param xml ! @return Datastore ! @throws MappingException */ public Datastore storeXML(String xml) throws MappingException; ! /** ! Load persistence mappings from a parsed XML document. ! ! @param doc ! @return Datastore ! @throws MappingException */ public Datastore storeDocument(Document doc) throws MappingException; ! ! /** ! Look for a mapping file for the given class using a naming convention. ! <tt>storeClass(eg.Foo.class)</tt> looks for <tt>eg/Foo.hbm.xml</tt> in ! the classpath. ! ! @param persistentClass the mapped persistent class ! @return Datastore ! @throws MappingException */ public Datastore storeClass(Class persistentClass) throws MappingException; ! /** ! Look for mapping files in a jar. Any files with names ending in <tt>.hbm.xml</tt> ! will be assumed to be mapping documents. ! ! @param resource the <tt>.jar</tt> file ! @return Datastore ! @throws MappingException */ public Datastore storeJar(String resource) throws MappingException; ! /** ! Generates a list of SQL statements that may be used to create the tables ! needed by this <tt>Datastore</tt>. ! ! @param dialect the script SQL dialect */ public String[] generateSchemaCreationScript(Dialect dialect) ! throws HibernateException; ! /** ! Generates a list of SQL statements that may be used to drop the tables ! needed by this <tt>Datastore</tt>. ! ! @param dialect the script SQL dialect */ public String[] generateDropSchemaScript(Dialect dialect) ! throws HibernateException; ! ! public String[] generateSchemaUpdateScript(Dialect dialect, JdbcDatabaseInfo info) throws HibernateException; } + + + |