You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
(387) |
May
(1066) |
Jun
(689) |
Jul
(504) |
Aug
(697) |
Sep
(660) |
Oct
(591) |
Nov
(393) |
Dec
(324) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(567) |
Feb
(448) |
Mar
(461) |
Apr
(368) |
May
(887) |
Jun
(243) |
Jul
(429) |
Aug
(670) |
Sep
(648) |
Oct
(684) |
Nov
(599) |
Dec
(317) |
2008 |
Jan
(388) |
Feb
(400) |
Mar
(323) |
Apr
(214) |
May
(228) |
Jun
(120) |
Jul
(168) |
Aug
(64) |
Sep
(78) |
Oct
(127) |
Nov
(28) |
Dec
|
2009 |
Jan
|
Feb
(1) |
Mar
(22) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Juergen H. <jho...@us...> - 2008-10-21 19:55:33
|
Update of /cvsroot/springframework/spring/src/org/springframework/jdbc/support/xml In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23464/src/org/springframework/jdbc/support/xml Modified Files: SqlXmlHandler.java SqlXmlValue.java Added Files: Jdbc4SqlXmlHandler.java Log Message: provided Jdbc4SqlXmlHandler as default implementation of the SqlXmlHandler interface; added SqlValue class to "jdbc.support" package, with SqlXmlValue derived from SqlValue instead of SqlTypeValue --- NEW FILE: Jdbc4SqlXmlHandler.java --- /* * Copyright 2002-2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.jdbc.support.xml; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.SQLXML; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; import org.w3c.dom.Document; import org.springframework.dao.DataAccessResourceFailureException; /** * Default implementation of the {@link SqlXmlHandler} interface. * Provides database-specific implementations for storing and * retrieving XML documents to and from fields in a database, * relying on the JDBC 4.0 <code>java.sql.SQLXML</code> facility. * * @author Thomas Risberg * @author Juergen Hoeller * @since 2.5.6 * @see java.sql.SQLXML * @see java.sql.ResultSet#getSQLXML * @see java.sql.PreparedStatement#setSQLXML */ public class Jdbc4SqlXmlHandler implements SqlXmlHandler { //------------------------------------------------------------------------- // Convenience methods for accessing XML content //------------------------------------------------------------------------- public String getXmlAsString(ResultSet rs, String columnName) throws SQLException { return rs.getSQLXML(columnName).getString(); } public String getXmlAsString(ResultSet rs, int columnIndex) throws SQLException { return rs.getSQLXML(columnIndex).getString(); } public InputStream getXmlAsBinaryStream(ResultSet rs, String columnName) throws SQLException { return rs.getSQLXML(columnName).getBinaryStream(); } public InputStream getXmlAsBinaryStream(ResultSet rs, int columnIndex) throws SQLException { return rs.getSQLXML(columnIndex).getBinaryStream(); } public Reader getXmlAsCharacterStream(ResultSet rs, String columnName) throws SQLException { return rs.getSQLXML(columnName).getCharacterStream(); } public Reader getXmlAsCharacterStream(ResultSet rs, int columnIndex) throws SQLException { return rs.getSQLXML(columnIndex).getCharacterStream(); } public Source getXmlAsSource(ResultSet rs, String columnName, Class sourceClass) throws SQLException { return rs.getSQLXML(columnName).getSource(sourceClass != null ? sourceClass : DOMSource.class); } public Source getXmlAsSource(ResultSet rs, int columnIndex, Class sourceClass) throws SQLException { return rs.getSQLXML(columnIndex).getSource(sourceClass != null ? sourceClass : DOMSource.class); } //------------------------------------------------------------------------- // Convenience methods for building XML content //------------------------------------------------------------------------- public SqlXmlValue newSqlXmlValue(final String value) { return new AbstractJdbc4SqlXmlValue() { protected void provideXml(SQLXML xmlObject) throws SQLException, IOException { xmlObject.setString(value); } }; } public SqlXmlValue newSqlXmlValue(final XmlBinaryStreamProvider provider) { return new AbstractJdbc4SqlXmlValue() { protected void provideXml(SQLXML xmlObject) throws SQLException, IOException { provider.provideXml(xmlObject.setBinaryStream()); } }; } public SqlXmlValue newSqlXmlValue(final XmlCharacterStreamProvider provider) { return new AbstractJdbc4SqlXmlValue() { protected void provideXml(SQLXML xmlObject) throws SQLException, IOException { provider.provideXml(xmlObject.setCharacterStream()); } }; } public SqlXmlValue newSqlXmlValue(final Class resultClass, final XmlResultProvider provider) { return new AbstractJdbc4SqlXmlValue() { protected void provideXml(SQLXML xmlObject) throws SQLException, IOException { provider.provideXml(xmlObject.setResult(resultClass)); } }; } public SqlXmlValue newSqlXmlValue(final Document document) { return new AbstractJdbc4SqlXmlValue() { protected void provideXml(SQLXML xmlObject) throws SQLException, IOException { ((DOMResult) xmlObject.setResult(DOMResult.class)).setNode(document); } }; } /** * Internal base class for {@link SqlXmlValue} implementations. */ private static abstract class AbstractJdbc4SqlXmlValue implements SqlXmlValue { private SQLXML xmlObject; public void setValue(PreparedStatement ps, int paramIndex) throws SQLException { this.xmlObject = ps.getConnection().createSQLXML(); try { provideXml(this.xmlObject); } catch (IOException ex) { throw new DataAccessResourceFailureException("Failure encountered while providing XML", ex); } ps.setSQLXML(paramIndex, this.xmlObject); } public void cleanup() { try { this.xmlObject.free(); } catch (SQLException ex) { throw new DataAccessResourceFailureException("Could not free SQLXML object", ex); } } protected abstract void provideXml(SQLXML xmlObject) throws SQLException, IOException; } } Index: SqlXmlValue.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/jdbc/support/xml/SqlXmlValue.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SqlXmlValue.java 5 Jun 2008 22:35:55 -0000 1.2 --- SqlXmlValue.java 21 Oct 2008 19:55:26 -0000 1.3 *************** *** 17,24 **** package org.springframework.jdbc.support.xml; ! import org.springframework.jdbc.core.DisposableSqlTypeValue; /** ! * Subinterface of {@link org.springframework.jdbc.core.SqlTypeValue} * that supports passing in XML data to specified column and adds a * cleanup callback, to be invoked after the value has been set and --- 17,24 ---- package org.springframework.jdbc.support.xml; ! import org.springframework.jdbc.support.SqlValue; /** ! * Subinterface of {@link org.springframework.jdbc.support.SqlValue} * that supports passing in XML data to specified column and adds a * cleanup callback, to be invoked after the value has been set and *************** *** 27,33 **** * @author Thomas Risberg * @since 2.5.5 ! * @see org.springframework.jdbc.core.DisposableSqlTypeValue */ ! public interface SqlXmlValue extends DisposableSqlTypeValue { } --- 27,33 ---- * @author Thomas Risberg * @since 2.5.5 ! * @see org.springframework.jdbc.support.SqlValue */ ! public interface SqlXmlValue extends SqlValue { } Index: SqlXmlHandler.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/jdbc/support/xml/SqlXmlHandler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SqlXmlHandler.java 13 Jun 2008 18:46:01 -0000 1.3 --- SqlXmlHandler.java 21 Oct 2008 19:55:26 -0000 1.4 *************** *** 19,23 **** import java.io.InputStream; import java.io.Reader; - import java.io.Writer; import java.sql.ResultSet; import java.sql.SQLException; --- 19,22 ---- *************** *** 28,52 **** /** ! * Abstraction for handling XML fields in specific databases. * ! * <p>Its main purpose is to isolate database specific handling of XML stored in the ! * database. JDBC 4.0 introduces the new data type <code>java.sql.SQLXML</code> but ! * most databases and their drivers currently rely on database specific data types ! * and features. * ! * <p>Provides accessor methods for XML fields, and acts as factory for * {@link SqlXmlValue} instances. * * @author Thomas Risberg * @since 2.5.5 ! * @see java.sql.ResultSet#getSQLXML * @see java.sql.SQLXML */ public interface SqlXmlHandler { /** * Retrieve the given column as String from the given ResultSet. ! * Might simply invoke <code>ResultSet.getString</code> or work with ! * <code>SQLXML</code> or database specific classes depending on the * database and driver. * @param rs the ResultSet to retrieve the content from --- 27,57 ---- /** ! * Abstraction for handling XML fields in specific databases. Its main purpose ! * is to isolate database-specific handling of XML stored in the database. * ! * <p>JDBC 4.0 introduces the new data type <code>java.sql.SQLXML</code> ! * but most databases and their drivers currently rely on database-specific ! * data types and features. * ! * <p>Provides accessor methods for XML fields and acts as factory for * {@link SqlXmlValue} instances. * * @author Thomas Risberg * @since 2.5.5 ! * @see Jdbc4SqlXmlHandler * @see java.sql.SQLXML + * @see java.sql.ResultSet#getSQLXML + * @see java.sql.PreparedStatement#setSQLXML */ public interface SqlXmlHandler { + //------------------------------------------------------------------------- + // Convenience methods for accessing XML content + //------------------------------------------------------------------------- + /** * Retrieve the given column as String from the given ResultSet. ! * <p>Might simply invoke <code>ResultSet.getString</code> or work with ! * <code>SQLXML</code> or database-specific classes depending on the * database and driver. * @param rs the ResultSet to retrieve the content from *************** *** 61,66 **** /** * Retrieve the given column as String from the given ResultSet. ! * Might simply invoke <code>ResultSet.getString</code> or work with ! * <code>SQLXML</code> or database specific classes depending on the * database and driver. * @param rs the ResultSet to retrieve the content from --- 66,71 ---- /** * Retrieve the given column as String from the given ResultSet. ! * <p>Might simply invoke <code>ResultSet.getString</code> or work with ! * <code>SQLXML</code> or database-specific classes depending on the * database and driver. * @param rs the ResultSet to retrieve the content from *************** *** 75,80 **** /** * Retrieve the given column as binary stream from the given ResultSet. ! * Might simply invoke <code>ResultSet.getAsciiStream</code> or work with ! * <code>SQLXML</code> or database specific classes depending on the * database and driver. * @param rs the ResultSet to retrieve the content from --- 80,85 ---- /** * Retrieve the given column as binary stream from the given ResultSet. ! * <p>Might simply invoke <code>ResultSet.getAsciiStream</code> or work with ! * <code>SQLXML</code> or database-specific classes depending on the * database and driver. * @param rs the ResultSet to retrieve the content from *************** *** 89,94 **** /** * Retrieve the given column as binary stream from the given ResultSet. ! * Might simply invoke <code>ResultSet.getAsciiStream</code> or work with ! * <code>SQLXML</code> or database specific classes depending on the * database and driver. * @param rs the ResultSet to retrieve the content from --- 94,99 ---- /** * Retrieve the given column as binary stream from the given ResultSet. ! * <p>Might simply invoke <code>ResultSet.getAsciiStream</code> or work with ! * <code>SQLXML</code> or database-specific classes depending on the * database and driver. * @param rs the ResultSet to retrieve the content from *************** *** 103,108 **** /** * Retrieve the given column as character stream from the given ResultSet. ! * Might simply invoke <code>ResultSet.getCharacterStream</code> or work with ! * <code>SQLXML</code> or database specific classes depending on the * database and driver. * @param rs the ResultSet to retrieve the content from --- 108,113 ---- /** * Retrieve the given column as character stream from the given ResultSet. ! * <p>Might simply invoke <code>ResultSet.getCharacterStream</code> or work with ! * <code>SQLXML</code> or database-specific classes depending on the * database and driver. * @param rs the ResultSet to retrieve the content from *************** *** 117,122 **** /** * Retrieve the given column as character stream from the given ResultSet. ! * Might simply invoke <code>ResultSet.getCharacterStream</code> or work with ! * <code>SQLXML</code> or database specific classes depending on the * database and driver. * @param rs the ResultSet to retrieve the content from --- 122,127 ---- /** * Retrieve the given column as character stream from the given ResultSet. ! * <p>Might simply invoke <code>ResultSet.getCharacterStream</code> or work with ! * <code>SQLXML</code> or database-specific classes depending on the * database and driver. * @param rs the ResultSet to retrieve the content from *************** *** 132,137 **** * Retrieve the given column as Source implemented using the specified source class * from the given ResultSet. ! * Might work with <code>SQLXML</code> or database specific classes depending on the ! * database and driver. * @param rs the ResultSet to retrieve the content from * @param columnName the column name to use --- 137,142 ---- * Retrieve the given column as Source implemented using the specified source class * from the given ResultSet. ! * <p>Might work with <code>SQLXML</code> or database-specific classes depending ! * on the database and driver. * @param rs the ResultSet to retrieve the content from * @param columnName the column name to use *************** *** 147,152 **** * Retrieve the given column as Source implemented using the specified source class * from the given ResultSet. ! * Might work with <code>SQLXML</code> or database specific classes depending on the ! * database and driver. * @param rs the ResultSet to retrieve the content from * @param columnIndex the column index to use --- 152,157 ---- * Retrieve the given column as Source implemented using the specified source class * from the given ResultSet. ! * <p>Might work with <code>SQLXML</code> or database-specific classes depending ! * on the database and driver. * @param rs the ResultSet to retrieve the content from * @param columnIndex the column index to use *************** *** 159,165 **** Source getXmlAsSource(ResultSet rs, int columnIndex, Class sourceClass) throws SQLException; /** ! * Get an instance of an <code>SqlXmlValue</code> implementation to be used together with ! * the database specific implementation of this <code>SqlXmlHandler</code>. * @param value the XML String value providing XML data * @return the implementation specific instance --- 164,175 ---- Source getXmlAsSource(ResultSet rs, int columnIndex, Class sourceClass) throws SQLException; + + //------------------------------------------------------------------------- + // Convenience methods for building XML content + //------------------------------------------------------------------------- + /** ! * Create a <code>SqlXmlValue</code> instance for the given XML data, ! * as supported by the underlying JDBC driver. * @param value the XML String value providing XML data * @return the implementation specific instance *************** *** 170,175 **** /** ! * Get an instance of an <code>SqlXmlValue</code> implementation to be used together with ! * the database specific implementation of this <code>SqlXmlHandler</code>. * @param provider the <code>XmlBinaryStreamProvider</code> providing XML data * @return the implementation specific instance --- 180,185 ---- /** ! * Create a <code>SqlXmlValue</code> instance for the given XML data, ! * as supported by the underlying JDBC driver. * @param provider the <code>XmlBinaryStreamProvider</code> providing XML data * @return the implementation specific instance *************** *** 180,185 **** /** ! * Get an instance of an <code>SqlXmlValue</code> implementation to be used together with ! * the database specific implementation of this <code>SqlXmlHandler</code>. * @param provider the <code>XmlCharacterStreamProvider</code> providing XML data * @return the implementation specific instance --- 190,195 ---- /** ! * Create a <code>SqlXmlValue</code> instance for the given XML data, ! * as supported by the underlying JDBC driver. * @param provider the <code>XmlCharacterStreamProvider</code> providing XML data * @return the implementation specific instance *************** *** 190,195 **** /** ! * Get an instance of an <code>SqlXmlValue</code> implementation to be used together with ! * the database specific implementation of this <code>SqlXmlHandler</code>. * @param resultClass the Result implementation class to be used * @param provider the <code>XmlResultProvider</code> that will provide the XML data --- 200,205 ---- /** ! * Create a <code>SqlXmlValue</code> instance for the given XML data, ! * as supported by the underlying JDBC driver. * @param resultClass the Result implementation class to be used * @param provider the <code>XmlResultProvider</code> that will provide the XML data *************** *** 201,206 **** /** ! * Get an instance of an <code>SqlXmlValue</code> implementation to be used together with ! * the database specific implementation of this <code>SqlXmlHandler</code>. * @param doc the XML Document to be used * @return the implementation specific instance --- 211,216 ---- /** ! * Create a <code>SqlXmlValue</code> instance for the given XML data, ! * as supported by the underlying JDBC driver. * @param doc the XML Document to be used * @return the implementation specific instance |
From: Juergen H. <jho...@us...> - 2008-10-21 19:55:33
|
Update of /cvsroot/springframework/spring/src/org/springframework/jdbc/support In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23464/src/org/springframework/jdbc/support Added Files: SqlValue.java Log Message: provided Jdbc4SqlXmlHandler as default implementation of the SqlXmlHandler interface; added SqlValue class to "jdbc.support" package, with SqlXmlValue derived from SqlValue instead of SqlTypeValue --- NEW FILE: SqlValue.java --- /* * Copyright 2002-2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.jdbc.support; import java.sql.PreparedStatement; import java.sql.SQLException; /** * Simple interface for complex types to be set as statement parameters. * * <p>Implementations perform the actual work of setting the actual values. They must * implement the callback method <code>setValue</code> which can throw SQLExceptions * that will be caught and translated by the calling code. This callback method has * access to the underlying Connection via the given PreparedStatement object, if that * should be needed to create any database-specific objects. * * @author Juergen Hoeller * @since 2.5.6 * @see org.springframework.jdbc.core.SqlTypeValue * @see org.springframework.jdbc.core.DisposableSqlTypeValue */ public interface SqlValue { /** * Set the value on the given PreparedStatement. * @param ps the PreparedStatement to work on * @param paramIndex the index of the parameter for which we need to set the value * @throws SQLException if a SQLException is encountered while setting parameter values */ void setValue(PreparedStatement ps, int paramIndex) throws SQLException; /** * Clean up resources held by this value object. */ void cleanup(); } |
From: Juergen H. <jho...@us...> - 2008-10-21 19:55:33
|
Update of /cvsroot/springframework/spring/src/org/springframework/jdbc/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23464/src/org/springframework/jdbc/core Modified Files: DisposableSqlTypeValue.java SqlTypeValue.java StatementCreatorUtils.java Log Message: provided Jdbc4SqlXmlHandler as default implementation of the SqlXmlHandler interface; added SqlValue class to "jdbc.support" package, with SqlXmlValue derived from SqlValue instead of SqlTypeValue Index: SqlTypeValue.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/jdbc/core/SqlTypeValue.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SqlTypeValue.java 8 Apr 2006 20:55:26 -0000 1.12 --- SqlTypeValue.java 21 Oct 2008 19:55:26 -0000 1.13 *************** *** 1,4 **** /* ! * Copyright 2002-2006 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); --- 1,4 ---- /* ! * Copyright 2002-2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); *************** *** 23,28 **** /** ! * Interface to be implemented for setting values for more complex database specific ! * types not supported by the standard setObject method. * * <p>Implementations perform the actual work of setting the actual values. They must --- 23,29 ---- /** ! * Interface to be implemented for setting values for more complex database-specific ! * types not supported by the standard <code>setObject</code> method. This is ! * effectively an extended variant of {@link org.springframework.jdbc.support.SqlValue}. * * <p>Implementations perform the actual work of setting the actual values. They must *************** *** 38,41 **** --- 39,43 ---- * @see java.sql.PreparedStatement#setObject * @see JdbcOperations#update(String, Object[], int[]) + * @see org.springframework.jdbc.support.SqlValue */ public interface SqlTypeValue { *************** *** 57,62 **** * @param sqlType SQL type of the parameter we are setting * @param typeName the type name of the parameter (optional) ! * @throws SQLException if a SQLException is encountered setting parameter values ! * (that is, there's no need to catch SQLException) * @see java.sql.Types * @see java.sql.PreparedStatement#setObject --- 59,63 ---- * @param sqlType SQL type of the parameter we are setting * @param typeName the type name of the parameter (optional) ! * @throws SQLException if a SQLException is encountered while setting parameter values * @see java.sql.Types * @see java.sql.PreparedStatement#setObject Index: StatementCreatorUtils.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/jdbc/core/StatementCreatorUtils.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** StatementCreatorUtils.java 2 Jul 2008 10:44:17 -0000 1.37 --- StatementCreatorUtils.java 21 Oct 2008 19:55:26 -0000 1.38 *************** *** 36,39 **** --- 36,41 ---- import org.apache.commons.logging.LogFactory; + import org.springframework.jdbc.support.SqlValue; + /** * Utility methods for PreparedStatementSetter/Creator and CallableStatementCreator *************** *** 187,191 **** // override type info? if (inValue instanceof SqlParameterValue) { ! SqlParameterValue parameterValue = (SqlParameterValue)inValue; if (logger.isDebugEnabled()) { logger.debug("Overriding typeinfo with runtime info from SqlParameterValue: column index " + paramIndex + --- 189,193 ---- // override type info? if (inValue instanceof SqlParameterValue) { ! SqlParameterValue parameterValue = (SqlParameterValue) inValue; if (logger.isDebugEnabled()) { logger.debug("Overriding typeinfo with runtime info from SqlParameterValue: column index " + paramIndex + *************** *** 202,207 **** } ! if (logger.isDebugEnabled()) { ! logger.debug("Setting SQL statement parameter value: column index " + paramIndex + ", parameter value [" + inValueToUse + "], value class [" + (inValueToUse != null ? inValueToUse.getClass().getName() : "null") + --- 204,209 ---- } ! if (logger.isTraceEnabled()) { ! logger.trace("Setting SQL statement parameter value: column index " + paramIndex + ", parameter value [" + inValueToUse + "], value class [" + (inValueToUse != null ? inValueToUse.getClass().getName() : "null") + *************** *** 210,340 **** if (inValueToUse == null) { ! if (sqlTypeToUse == SqlTypeValue.TYPE_UNKNOWN) { ! boolean useSetObject = false; ! sqlTypeToUse = Types.NULL; ! try { ! DatabaseMetaData dbmd = ps.getConnection().getMetaData(); ! String databaseProductName = dbmd.getDatabaseProductName(); ! String jdbcDriverName = dbmd.getDriverName(); ! if (databaseProductName.startsWith("Informix") || ! jdbcDriverName.startsWith("Microsoft SQL Server")) { ! useSetObject = true; ! } ! else if (databaseProductName.startsWith("DB2") || ! jdbcDriverName.startsWith("jConnect") || ! jdbcDriverName.startsWith("SQLServer")|| ! jdbcDriverName.startsWith("Apache Derby Embedded")) { ! sqlTypeToUse = Types.VARCHAR; ! } ! } ! catch (Throwable ex) { ! logger.debug("Could not check database or driver name", ex); ! } ! if (useSetObject) { ! ps.setObject(paramIndex, null); } ! else { ! ps.setNull(paramIndex, sqlTypeToUse); } } ! else if (typeNameToUse != null) { ! ps.setNull(paramIndex, sqlTypeToUse, typeNameToUse); } else { ! ps.setNull(paramIndex, sqlTypeToUse); } } ! else { // inValue != null ! if (inValueToUse instanceof SqlTypeValue) { ! ((SqlTypeValue) inValueToUse).setTypeValue(ps, paramIndex, sqlTypeToUse, typeNameToUse); } ! else if (sqlTypeToUse == Types.VARCHAR || sqlTypeToUse == Types.LONGVARCHAR || ! (sqlTypeToUse == Types.CLOB && isStringValue(inValueToUse.getClass()))) { ! ps.setString(paramIndex, inValueToUse.toString()); } ! else if (sqlTypeToUse == Types.DECIMAL || sqlTypeToUse == Types.NUMERIC) { ! if (inValueToUse instanceof BigDecimal) { ! ps.setBigDecimal(paramIndex, (BigDecimal) inValueToUse); ! } ! else if (scale != null) { ! ps.setObject(paramIndex, inValueToUse, sqlTypeToUse, scale.intValue()); ! } ! else { ! ps.setObject(paramIndex, inValueToUse, sqlTypeToUse); ! } } ! else if (sqlTypeToUse == Types.DATE) { ! if (inValueToUse instanceof java.util.Date) { ! if (inValueToUse instanceof java.sql.Date) { ! ps.setDate(paramIndex, (java.sql.Date) inValueToUse); ! } ! else { ! ps.setDate(paramIndex, new java.sql.Date(((java.util.Date) inValueToUse).getTime())); ! } ! } ! else if (inValueToUse instanceof Calendar) { ! Calendar cal = (Calendar) inValueToUse; ! ps.setDate(paramIndex, new java.sql.Date(cal.getTime().getTime()), cal); } else { ! ps.setObject(paramIndex, inValueToUse, Types.DATE); } } ! else if (sqlTypeToUse == Types.TIME) { ! if (inValueToUse instanceof java.util.Date) { ! if (inValueToUse instanceof java.sql.Time) { ! ps.setTime(paramIndex, (java.sql.Time) inValueToUse); ! } ! else { ! ps.setTime(paramIndex, new java.sql.Time(((java.util.Date) inValueToUse).getTime())); ! } ! } ! else if (inValueToUse instanceof Calendar) { ! Calendar cal = (Calendar) inValueToUse; ! ps.setTime(paramIndex, new java.sql.Time(cal.getTime().getTime()), cal); ! } ! else { ! ps.setObject(paramIndex, inValueToUse, Types.TIME); ! } } ! else if (sqlTypeToUse == Types.TIMESTAMP) { ! if (inValueToUse instanceof java.util.Date) { ! if (inValueToUse instanceof java.sql.Timestamp) { ! ps.setTimestamp(paramIndex, (java.sql.Timestamp) inValueToUse); ! } ! else { ! ps.setTimestamp(paramIndex, new java.sql.Timestamp(((java.util.Date) inValueToUse).getTime())); ! } ! } ! else if (inValueToUse instanceof Calendar) { ! Calendar cal = (Calendar) inValueToUse; ! ps.setTimestamp(paramIndex, new java.sql.Timestamp(cal.getTime().getTime()), cal); } else { ! ps.setObject(paramIndex, inValueToUse, Types.TIMESTAMP); } } ! else if (sqlTypeToUse == SqlTypeValue.TYPE_UNKNOWN) { ! if (isStringValue(inValueToUse.getClass())) { ! ps.setString(paramIndex, inValueToUse.toString()); ! } ! else if (isDateValue(inValueToUse.getClass())) { ! ps.setTimestamp(paramIndex, new java.sql.Timestamp(((java.util.Date) inValueToUse).getTime())); ! } ! else if (inValueToUse instanceof Calendar) { ! Calendar cal = (Calendar) inValueToUse; ! ps.setTimestamp(paramIndex, new java.sql.Timestamp(cal.getTime().getTime()), cal); } else { ! // Fall back to generic setObject call without SQL type specified. ! ps.setObject(paramIndex, inValueToUse); } } else { ! // Fall back to generic setObject call with SQL type specified. ! ps.setObject(paramIndex, inValueToUse, sqlTypeToUse); } } } --- 212,354 ---- if (inValueToUse == null) { ! setNull(ps, paramIndex, sqlTypeToUse, typeNameToUse); ! } ! else { ! setValue(ps, paramIndex, sqlTypeToUse, typeNameToUse, scale, inValueToUse); ! } ! } ! ! private static void setNull(PreparedStatement ps, int paramIndex, int sqlType, String typeName) throws SQLException { ! if (sqlType == SqlTypeValue.TYPE_UNKNOWN) { ! boolean useSetObject = false; ! sqlType = Types.NULL; ! try { ! DatabaseMetaData dbmd = ps.getConnection().getMetaData(); ! String databaseProductName = dbmd.getDatabaseProductName(); ! String jdbcDriverName = dbmd.getDriverName(); ! if (databaseProductName.startsWith("Informix") || ! jdbcDriverName.startsWith("Microsoft SQL Server")) { ! useSetObject = true; } ! else if (databaseProductName.startsWith("DB2") || ! jdbcDriverName.startsWith("jConnect") || ! jdbcDriverName.startsWith("SQLServer")|| ! jdbcDriverName.startsWith("Apache Derby Embedded")) { ! sqlType = Types.VARCHAR; } } ! catch (Throwable ex) { ! logger.debug("Could not check database or driver name", ex); ! } ! if (useSetObject) { ! ps.setObject(paramIndex, null); } else { ! ps.setNull(paramIndex, sqlType); } } + else if (typeName != null) { + ps.setNull(paramIndex, sqlType, typeName); + } + else { + ps.setNull(paramIndex, sqlType); + } + } ! private static void setValue(PreparedStatement ps, int paramIndex, int sqlType, String typeName, ! Integer scale, Object inValue) throws SQLException { ! ! if (inValue instanceof SqlTypeValue) { ! ((SqlTypeValue) inValue).setTypeValue(ps, paramIndex, sqlType, typeName); ! } ! else if (inValue instanceof SqlValue) { ! ((SqlValue) inValue).setValue(ps, paramIndex); ! } ! else if (sqlType == Types.VARCHAR || sqlType == Types.LONGVARCHAR || ! (sqlType == Types.CLOB && isStringValue(inValue.getClass()))) { ! ps.setString(paramIndex, inValue.toString()); ! } ! else if (sqlType == Types.DECIMAL || sqlType == Types.NUMERIC) { ! if (inValue instanceof BigDecimal) { ! ps.setBigDecimal(paramIndex, (BigDecimal) inValue); } ! else if (scale != null) { ! ps.setObject(paramIndex, inValue, sqlType, scale.intValue()); } ! else { ! ps.setObject(paramIndex, inValue, sqlType); } ! } ! else if (sqlType == Types.DATE) { ! if (inValue instanceof java.util.Date) { ! if (inValue instanceof java.sql.Date) { ! ps.setDate(paramIndex, (java.sql.Date) inValue); } else { ! ps.setDate(paramIndex, new java.sql.Date(((java.util.Date) inValue).getTime())); } } ! else if (inValue instanceof Calendar) { ! Calendar cal = (Calendar) inValue; ! ps.setDate(paramIndex, new java.sql.Date(cal.getTime().getTime()), cal); } ! else { ! ps.setObject(paramIndex, inValue, Types.DATE); ! } ! } ! else if (sqlType == Types.TIME) { ! if (inValue instanceof java.util.Date) { ! if (inValue instanceof java.sql.Time) { ! ps.setTime(paramIndex, (java.sql.Time) inValue); } else { ! ps.setTime(paramIndex, new java.sql.Time(((java.util.Date) inValue).getTime())); } } ! else if (inValue instanceof Calendar) { ! Calendar cal = (Calendar) inValue; ! ps.setTime(paramIndex, new java.sql.Time(cal.getTime().getTime()), cal); ! } ! else { ! ps.setObject(paramIndex, inValue, Types.TIME); ! } ! } ! else if (sqlType == Types.TIMESTAMP) { ! if (inValue instanceof java.util.Date) { ! if (inValue instanceof java.sql.Timestamp) { ! ps.setTimestamp(paramIndex, (java.sql.Timestamp) inValue); } else { ! ps.setTimestamp(paramIndex, new java.sql.Timestamp(((java.util.Date) inValue).getTime())); } } + else if (inValue instanceof Calendar) { + Calendar cal = (Calendar) inValue; + ps.setTimestamp(paramIndex, new java.sql.Timestamp(cal.getTime().getTime()), cal); + } else { ! ps.setObject(paramIndex, inValue, Types.TIMESTAMP); } } + else if (sqlType == SqlTypeValue.TYPE_UNKNOWN) { + if (isStringValue(inValue.getClass())) { + ps.setString(paramIndex, inValue.toString()); + } + else if (isDateValue(inValue.getClass())) { + ps.setTimestamp(paramIndex, new java.sql.Timestamp(((java.util.Date) inValue).getTime())); + } + else if (inValue instanceof Calendar) { + Calendar cal = (Calendar) inValue; + ps.setTimestamp(paramIndex, new java.sql.Timestamp(cal.getTime().getTime()), cal); + } + else { + // Fall back to generic setObject call without SQL type specified. + ps.setObject(paramIndex, inValue); + } + } + else { + // Fall back to generic setObject call with SQL type specified. + ps.setObject(paramIndex, inValue, sqlType); + } } *************** *** 386,389 **** --- 400,406 ---- ((DisposableSqlTypeValue) inValue).cleanup(); } + else if (inValue instanceof SqlValue) { + ((SqlValue) inValue).cleanup(); + } } } Index: DisposableSqlTypeValue.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/jdbc/core/DisposableSqlTypeValue.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DisposableSqlTypeValue.java 27 May 2005 19:50:02 -0000 1.4 --- DisposableSqlTypeValue.java 21 Oct 2008 19:55:26 -0000 1.5 *************** *** 1,4 **** /* ! * Copyright 2002-2005 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); --- 1,4 ---- /* ! * Copyright 2002-2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); *************** *** 18,22 **** /** ! * Subinterface of SqlTypeValue that adds a cleanup callback, * to be invoked after the value has been set and the corresponding * statement has been executed. --- 18,22 ---- /** ! * Subinterface of {@link SqlTypeValue} that adds a cleanup callback, * to be invoked after the value has been set and the corresponding * statement has been executed. *************** *** 31,35 **** * Clean up resources held by this type value, * for example the LobCreator in case of a SqlLobValue. ! * @see org.springframework.jdbc.core.support.SqlLobValue#cleanup */ void cleanup(); --- 31,36 ---- * Clean up resources held by this type value, * for example the LobCreator in case of a SqlLobValue. ! * @see org.springframework.jdbc.core.support.SqlLobValue#cleanup() ! * @see org.springframework.jdbc.support.SqlValue#cleanup() */ void cleanup(); |
From: Arjen J.W. P. <po...@us...> - 2008-10-21 19:11:40
|
Update of /cvsroot/springframework/spring/tiger/src/org/springframework/jmx/export/metadata In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20127/tiger/src/org/springframework/jmx/export/metadata Log Message: Directory /cvsroot/springframework/spring/tiger/src/org/springframework/jmx/export/metadata added to the repository |
From: Juergen H. <jho...@us...> - 2008-10-21 11:02:35
|
Update of /cvsroot/springframework/spring/tiger/src/org/springframework/orm/jpa/support In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10756/tiger/src/org/springframework/orm/jpa/support Modified Files: PersistenceAnnotationBeanPostProcessor.java Log Message: @PersistenceContext for default EntityManagerFactory lookup works even in an @Configurable Hibernate entity Index: PersistenceAnnotationBeanPostProcessor.java =================================================================== RCS file: /cvsroot/springframework/spring/tiger/src/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** PersistenceAnnotationBeanPostProcessor.java 31 Mar 2008 15:24:14 -0000 1.28 --- PersistenceAnnotationBeanPostProcessor.java 21 Oct 2008 11:02:19 -0000 1.29 *************** *** 501,516 **** throws NoSuchBeanDefinitionException{ ! Map matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(this.beanFactory, EntityManagerFactory.class); ! if (matchingBeans.size() == 1) { ! Map.Entry entry = (Map.Entry) matchingBeans.entrySet().iterator().next(); ! String unitName = (String) entry.getKey(); if (this.beanFactory instanceof ConfigurableBeanFactory) { ((ConfigurableBeanFactory) this.beanFactory).registerDependentBean(unitName, requestingBeanName); } ! return (EntityManagerFactory) entry.getValue(); } else { throw new NoSuchBeanDefinitionException( ! EntityManagerFactory.class, "expected single bean but found " + matchingBeans.size()); } } --- 501,517 ---- throws NoSuchBeanDefinitionException{ ! String[] beanNames = ! BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.beanFactory, EntityManagerFactory.class); ! if (beanNames.length == 1) { ! String unitName = beanNames[0]; ! EntityManagerFactory emf = (EntityManagerFactory) this.beanFactory.getBean(unitName); if (this.beanFactory instanceof ConfigurableBeanFactory) { ((ConfigurableBeanFactory) this.beanFactory).registerDependentBean(unitName, requestingBeanName); } ! return emf; } else { throw new NoSuchBeanDefinitionException( ! EntityManagerFactory.class, "expected single bean but found " + beanNames.length); } } |
From: Juergen H. <jho...@us...> - 2008-10-21 11:02:35
|
Update of /cvsroot/springframework/spring/tiger/test/org/springframework/orm/jpa/domain In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10756/tiger/test/org/springframework/orm/jpa/domain Modified Files: Person.java Added Files: persistence-context.xml ContextualPerson.java Log Message: @PersistenceContext for default EntityManagerFactory lookup works even in an @Configurable Hibernate entity Index: Person.java =================================================================== RCS file: /cvsroot/springframework/spring/tiger/test/org/springframework/orm/jpa/domain/Person.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Person.java 6 Mar 2008 21:13:01 -0000 1.4 --- Person.java 21 Oct 2008 11:02:19 -0000 1.5 *************** *** 26,29 **** --- 26,30 ---- import javax.persistence.JoinColumn; import javax.persistence.OneToOne; + import javax.persistence.Table; import org.springframework.beans.TestBean; *************** *** 36,40 **** */ @Entity ! @Configurable("person") public class Person { --- 37,41 ---- */ @Entity ! @Configurable public class Person { *************** *** 56,60 **** private String last_name; ! public Integer getId() { return id; --- 57,61 ---- private String last_name; ! public Integer getId() { return id; --- NEW FILE: ContextualPerson.java --- /* * Copyright 2002-2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.orm.jpa.domain; import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.PersistenceContext; import org.springframework.beans.TestBean; import org.springframework.beans.factory.annotation.Configurable; /** * @author Juergen Hoeller */ @Entity @Configurable public class ContextualPerson { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Integer id; private transient TestBean testBean; // Lazy relationship to force use of instrumentation in JPA implementation. // TopLink, at least, will not instrument classes unless absolutely necessary. @OneToOne(fetch=FetchType.LAZY, cascade=CascadeType.PERSIST) @JoinColumn(name="DRIVERS_LICENSE_ID") private DriversLicense driversLicense; private String first_name; @Basic(fetch=FetchType.LAZY) private String last_name; @PersistenceContext public transient EntityManager entityManager; public Integer getId() { return id; } public void setTestBean(TestBean testBean) { this.testBean = testBean; } public TestBean getTestBean() { return testBean; } public void setFirstName(String firstName) { this.first_name = firstName; } public String getFirstName() { return this.first_name; } public void setLastName(String lastName) { this.last_name = lastName; } public String getLastName() { return this.last_name; } public void setDriversLicense(DriversLicense driversLicense) { this.driversLicense = driversLicense; } public DriversLicense getDriversLicense() { return this.driversLicense; } @Override public String toString() { return getClass().getName() + ":(" + hashCode() + ") id=" + id + "; firstName=" + first_name + "; lastName=" + last_name + "; testBean=" + testBean; } } --- NEW FILE: persistence-context.xml --- <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="Person" transaction-type="RESOURCE_LOCAL"> <class>org.springframework.orm.jpa.domain.ContextualPerson</class> <class>org.springframework.orm.jpa.domain.DriversLicense</class> <class>org.springframework.orm.jpa.domain.Person</class> <exclude-unlisted-classes/> </persistence-unit> </persistence> |
From: Juergen H. <jho...@us...> - 2008-10-21 11:02:31
|
Update of /cvsroot/springframework/spring/tiger/test/org/springframework/orm/jpa/hibernate In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10756/tiger/test/org/springframework/orm/jpa/hibernate Modified Files: hibernate-manager.xml HibernateEntityManagerFactoryIntegrationTests.java Log Message: @PersistenceContext for default EntityManagerFactory lookup works even in an @Configurable Hibernate entity Index: hibernate-manager.xml =================================================================== RCS file: /cvsroot/springframework/spring/tiger/test/org/springframework/orm/jpa/hibernate/hibernate-manager.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** hibernate-manager.xml 14 Jul 2008 12:48:28 -0000 1.10 --- hibernate-manager.xml 21 Oct 2008 11:02:19 -0000 1.11 *************** *** 1,9 **** <?xml version="1.0" encoding="UTF-8"?> ! <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> ! <beans> ! ! <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> ! <property name="persistenceXmlLocation" value="org/springframework/orm/jpa/domain/persistence.xml"/> <property name="dataSource" ref="dataSource"/> <property name="jpaVendorAdapter"> --- 1,18 ---- <?xml version="1.0" encoding="UTF-8"?> ! <beans xmlns="http://www.springframework.org/schema/beans" ! xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ! xmlns:context="http://www.springframework.org/schema/context" ! xsi:schemaLocation=" ! http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd ! http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> ! <context:load-time-weaver aspectj-weaving="on"/> ! ! <context:annotation-config/> ! ! <context:spring-configured/> ! ! <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" depends-on="org.springframework.context.config.internalBeanConfigurerAspect"> ! <property name="persistenceXmlLocation" value="org/springframework/orm/jpa/domain/persistence-context.xml"/> <property name="dataSource" ref="dataSource"/> <property name="jpaVendorAdapter"> Index: HibernateEntityManagerFactoryIntegrationTests.java =================================================================== RCS file: /cvsroot/springframework/spring/tiger/test/org/springframework/orm/jpa/hibernate/HibernateEntityManagerFactoryIntegrationTests.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** HibernateEntityManagerFactoryIntegrationTests.java 14 Jul 2008 12:48:28 -0000 1.7 --- HibernateEntityManagerFactoryIntegrationTests.java 21 Oct 2008 11:02:19 -0000 1.8 *************** *** 26,29 **** --- 26,30 ---- import org.springframework.orm.jpa.AbstractContainerEntityManagerFactoryIntegrationTests; import org.springframework.orm.jpa.EntityManagerFactoryInfo; + import org.springframework.orm.jpa.domain.ContextualPerson; import org.springframework.orm.jpa.domain.Person; *************** *** 72,74 **** --- 73,81 ---- } + public void testConfigurablePerson() { + Query q = this.sessionFactory.getCurrentSession().createQuery("select p from ContextualPerson as p"); + assertEquals(0, q.list().size()); + assertNotNull(new ContextualPerson().entityManager); + } + } |
From: Costin L. <cos...@us...> - 2008-10-21 10:36:03
|
Update of /cvsroot/springframework/spring/src/org/springframework/beans/factory/xml In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9018/src/org/springframework/beans/factory/xml Modified Files: BeanDefinitionParserDelegate.java Log Message: + break some big parsing methods into smaller pieces to allow reuse Index: BeanDefinitionParserDelegate.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** BeanDefinitionParserDelegate.java 14 Oct 2008 15:14:15 -0000 1.58 --- BeanDefinitionParserDelegate.java 21 Oct 2008 10:35:49 -0000 1.59 *************** *** 67,75 **** /** ! * Stateful delegate class used to parse XML bean definitions. ! * Intended for use by both the main parser and any extension * {@link BeanDefinitionParser BeanDefinitionParsers} or * {@link BeanDefinitionDecorator BeanDefinitionDecorators}. ! * * @author Rob Harrop * @author Juergen Hoeller --- 67,75 ---- /** ! * Stateful delegate class used to parse XML bean definitions. Intended for use ! * by both the main parser and any extension * {@link BeanDefinitionParser BeanDefinitionParsers} or * {@link BeanDefinitionDecorator BeanDefinitionDecorators}. ! * * @author Rob Harrop * @author Juergen Hoeller *************** *** 87,92 **** /** ! * Value of a T/F attribute that represents true. ! * Anything else represents false. Case seNsItive. */ public static final String TRUE_VALUE = "true"; --- 87,92 ---- /** ! * Value of a T/F attribute that represents true. Anything else represents ! * false. Case seNsItive. */ public static final String TRUE_VALUE = "true"; *************** *** 228,232 **** public static final String DEFAULT_DESTROY_METHOD_ATTRIBUTE = "default-destroy-method"; - protected final Log logger = LogFactory.getLog(getClass()); --- 228,231 ---- *************** *** 238,242 **** /** ! * Stores all used bean names so we can enforce uniqueness on a per file basis. */ private final Set usedNames = new HashSet(); --- 237,242 ---- /** ! * Stores all used bean names so we can enforce uniqueness on a per file ! * basis. */ private final Set usedNames = new HashSet(); *************** *** 244,249 **** /** ! * Create a new BeanDefinitionParserDelegate associated with the ! * supplied {@link XmlReaderContext}. */ public BeanDefinitionParserDelegate(XmlReaderContext readerContext) { --- 244,249 ---- /** ! * Create a new BeanDefinitionParserDelegate associated with the supplied ! * {@link XmlReaderContext}. */ public BeanDefinitionParserDelegate(XmlReaderContext readerContext) { *************** *** 259,266 **** } - /** ! * Invoke the {@link org.springframework.beans.factory.parsing.SourceExtractor} to pull the ! * source metadata from the supplied {@link Element}. */ protected Object extractSource(Element ele) { --- 259,266 ---- } /** ! * Invoke the ! * {@link org.springframework.beans.factory.parsing.SourceExtractor} to pull ! * the source metadata from the supplied {@link Element}. */ protected Object extractSource(Element ele) { *************** *** 289,296 **** } - /** * Initialize the default lazy-init, autowire, dependency check settings, * init-method, destroy-method and merge settings. * @see #getDefaults() */ --- 289,296 ---- } /** * Initialize the default lazy-init, autowire, dependency check settings, * init-method, destroy-method and merge settings. + * * @see #getDefaults() */ *************** *** 325,330 **** /** ! * Return the default settings for bean definitions as indicated within ! * the attributes of the top-level <code><beans/></code> element. */ public BeanDefinitionDefaults getBeanDefinitionDefaults() { --- 325,330 ---- /** ! * Return the default settings for bean definitions as indicated within the ! * attributes of the top-level <code><beans/></code> element. */ public BeanDefinitionDefaults getBeanDefinitionDefaults() { *************** *** 349,356 **** } - /** ! * Parses the supplied <code><bean></code> element. May return <code>null</code> ! * if there were errors during parse. Errors are reported to the * {@link org.springframework.beans.factory.parsing.ProblemReporter}. */ --- 349,356 ---- } /** ! * Parses the supplied <code><bean></code> element. May return ! * <code>null</code> if there were errors during parse. Errors are ! * reported to the * {@link org.springframework.beans.factory.parsing.ProblemReporter}. */ *************** *** 360,365 **** /** ! * Parses the supplied <code><bean></code> element. May return <code>null</code> ! * if there were errors during parse. Errors are reported to the * {@link org.springframework.beans.factory.parsing.ProblemReporter}. */ --- 360,366 ---- /** ! * Parses the supplied <code><bean></code> element. May return ! * <code>null</code> if there were errors during parse. Errors are ! * reported to the * {@link org.springframework.beans.factory.parsing.ProblemReporter}. */ *************** *** 378,383 **** beanName = (String) aliases.remove(0); if (logger.isDebugEnabled()) { ! logger.debug("No XML 'id' specified - using '" + beanName + ! "' as bean name and " + aliases + " as aliases"); } } --- 379,384 ---- beanName = (String) aliases.remove(0); if (logger.isDebugEnabled()) { ! logger.debug("No XML 'id' specified - using '" + beanName + "' as bean name and " + aliases ! + " as aliases"); } } *************** *** 392,397 **** try { if (containingBean != null) { ! beanName = BeanDefinitionReaderUtils.generateBeanName( ! beanDefinition, this.readerContext.getRegistry(), true); } else { --- 393,398 ---- try { if (containingBean != null) { ! beanName = BeanDefinitionReaderUtils.generateBeanName(beanDefinition, ! this.readerContext.getRegistry(), true); } else { *************** *** 401,413 **** // This is expected for Spring 1.2/2.0 backwards compatibility. String beanClassName = beanDefinition.getBeanClassName(); ! if (beanClassName != null && ! beanName.startsWith(beanClassName) && beanName.length() > beanClassName.length() && ! !this.readerContext.getRegistry().isBeanNameInUse(beanClassName)) { aliases.add(beanClassName); } } if (logger.isDebugEnabled()) { ! logger.debug("Neither XML 'id' nor 'name' specified - " + ! "using generated bean name [" + beanName + "]"); } } --- 402,414 ---- // This is expected for Spring 1.2/2.0 backwards compatibility. String beanClassName = beanDefinition.getBeanClassName(); ! if (beanClassName != null && beanName.startsWith(beanClassName) ! && beanName.length() > beanClassName.length() ! && !this.readerContext.getRegistry().isBeanNameInUse(beanClassName)) { aliases.add(beanClassName); } } if (logger.isDebugEnabled()) { ! logger.debug("Neither XML 'id' nor 'name' specified - " + "using generated bean name [" ! + beanName + "]"); } } *************** *** 425,429 **** /** ! * Validate that the specified bean name and aliases have not been used already. */ protected void checkNameUniqueness(String beanName, List aliases, Element beanElement) { --- 426,431 ---- /** ! * Validate that the specified bean name and aliases have not been used ! * already. */ protected void checkNameUniqueness(String beanName, List aliases, Element beanElement) { *************** *** 445,453 **** /** ! * Parse the bean definition itself, without regard to name or aliases. May return ! * <code>null</code> if problems occured during the parse of the bean definition. */ ! public AbstractBeanDefinition parseBeanDefinitionElement( ! Element ele, String beanName, BeanDefinition containingBean) { this.parseState.push(new BeanEntry(beanName)); --- 447,455 ---- /** ! * Parse the bean definition itself, without regard to name or aliases. May ! * return <code>null</code> if problems occured during the parse of the ! * bean definition. */ ! public AbstractBeanDefinition parseBeanDefinitionElement(Element ele, String beanName, BeanDefinition containingBean) { this.parseState.push(new BeanEntry(beanName)); *************** *** 465,555 **** AbstractBeanDefinition bd = createBeanDefinition(className, parent); ! if (ele.hasAttribute(SCOPE_ATTRIBUTE)) { ! // Spring 2.x "scope" attribute ! bd.setScope(ele.getAttribute(SCOPE_ATTRIBUTE)); ! if (ele.hasAttribute(SINGLETON_ATTRIBUTE)) { ! error("Specify either 'scope' or 'singleton', not both", ele); ! } ! } ! else if (ele.hasAttribute(SINGLETON_ATTRIBUTE)) { ! // Spring 1.x "singleton" attribute ! bd.setScope(TRUE_VALUE.equals(ele.getAttribute(SINGLETON_ATTRIBUTE)) ? ! BeanDefinition.SCOPE_SINGLETON : BeanDefinition.SCOPE_PROTOTYPE); ! } ! else if (containingBean != null) { ! // Take default from containing bean in case of an inner bean definition. ! bd.setScope(containingBean.getScope()); ! } ! ! if (ele.hasAttribute(ABSTRACT_ATTRIBUTE)) { ! bd.setAbstract(TRUE_VALUE.equals(ele.getAttribute(ABSTRACT_ATTRIBUTE))); ! } ! ! String lazyInit = ele.getAttribute(LAZY_INIT_ATTRIBUTE); ! if (DEFAULT_VALUE.equals(lazyInit) && bd.isSingleton()) { ! // Just apply default to singletons, as lazy-init has no meaning for prototypes. ! lazyInit = this.defaults.getLazyInit(); ! } ! bd.setLazyInit(TRUE_VALUE.equals(lazyInit)); ! ! String autowire = ele.getAttribute(AUTOWIRE_ATTRIBUTE); ! bd.setAutowireMode(getAutowireMode(autowire)); ! ! String dependencyCheck = ele.getAttribute(DEPENDENCY_CHECK_ATTRIBUTE); ! bd.setDependencyCheck(getDependencyCheck(dependencyCheck)); ! ! if (ele.hasAttribute(DEPENDS_ON_ATTRIBUTE)) { ! String dependsOn = ele.getAttribute(DEPENDS_ON_ATTRIBUTE); ! bd.setDependsOn(StringUtils.tokenizeToStringArray(dependsOn, BEAN_NAME_DELIMITERS)); ! } ! ! String autowireCandidate = ele.getAttribute(AUTOWIRE_CANDIDATE_ATTRIBUTE); ! if ("".equals(autowireCandidate) || DEFAULT_VALUE.equals(autowireCandidate)) { ! String candidatePattern = this.defaults.getAutowireCandidates(); ! if (candidatePattern != null) { ! String[] patterns = StringUtils.commaDelimitedListToStringArray(candidatePattern); ! bd.setAutowireCandidate(PatternMatchUtils.simpleMatch(patterns, beanName)); ! } ! } ! else { ! bd.setAutowireCandidate(TRUE_VALUE.equals(autowireCandidate)); ! } ! ! if (ele.hasAttribute(PRIMARY_ATTRIBUTE)) { ! bd.setPrimary(TRUE_VALUE.equals(ele.getAttribute(PRIMARY_ATTRIBUTE))); ! } ! ! if (ele.hasAttribute(INIT_METHOD_ATTRIBUTE)) { ! String initMethodName = ele.getAttribute(INIT_METHOD_ATTRIBUTE); ! if (!"".equals(initMethodName)) { ! bd.setInitMethodName(initMethodName); ! } ! } ! else { ! if (this.defaults.getInitMethod() != null) { ! bd.setInitMethodName(this.defaults.getInitMethod()); ! bd.setEnforceInitMethod(false); ! } ! } ! ! if (ele.hasAttribute(DESTROY_METHOD_ATTRIBUTE)) { ! String destroyMethodName = ele.getAttribute(DESTROY_METHOD_ATTRIBUTE); ! if (!"".equals(destroyMethodName)) { ! bd.setDestroyMethodName(destroyMethodName); ! } ! } ! else { ! if (this.defaults.getDestroyMethod() != null) { ! bd.setDestroyMethodName(this.defaults.getDestroyMethod()); ! bd.setEnforceDestroyMethod(false); ! } ! } ! ! if (ele.hasAttribute(FACTORY_METHOD_ATTRIBUTE)) { ! bd.setFactoryMethodName(ele.getAttribute(FACTORY_METHOD_ATTRIBUTE)); ! } ! if (ele.hasAttribute(FACTORY_BEAN_ATTRIBUTE)) { ! bd.setFactoryBeanName(ele.getAttribute(FACTORY_BEAN_ATTRIBUTE)); ! } bd.setDescription(DomUtils.getChildElementValueByTagName(ele, DESCRIPTION_ELEMENT)); --- 467,471 ---- AbstractBeanDefinition bd = createBeanDefinition(className, parent); ! parseBeanDefinitionAttributes(ele, beanName, containingBean, bd); bd.setDescription(DomUtils.getChildElementValueByTagName(ele, DESCRIPTION_ELEMENT)); *************** *** 585,599 **** /** * Create a bean definition for the given class name and parent name. * @param className the name of the bean class * @param parentName the name of the bean's parent bean * @return the newly created bean definition ! * @throws ClassNotFoundException if bean class resolution was attempted but failed */ protected AbstractBeanDefinition createBeanDefinition(String className, String parentName) throws ClassNotFoundException { ! return BeanDefinitionReaderUtils.createBeanDefinition( ! parentName, className, this.readerContext.getBeanClassLoader()); } --- 501,621 ---- /** + * Apply the attributes of the given bean element to the given bean + * definition. + * + * @param ele bean declaration element + * @param beanName bean name + * @param containingBean containing bean definition + * @return a bean definition initialized according to the bean element + * attributes + */ + public AbstractBeanDefinition parseBeanDefinitionAttributes(Element ele, String beanName, + BeanDefinition containingBean, AbstractBeanDefinition bd) { + + if (ele.hasAttribute(SCOPE_ATTRIBUTE)) { + // Spring 2.x "scope" attribute + bd.setScope(ele.getAttribute(SCOPE_ATTRIBUTE)); + if (ele.hasAttribute(SINGLETON_ATTRIBUTE)) { + error("Specify either 'scope' or 'singleton', not both", ele); + } + } + else if (ele.hasAttribute(SINGLETON_ATTRIBUTE)) { + // Spring 1.x "singleton" attribute + bd.setScope(TRUE_VALUE.equals(ele.getAttribute(SINGLETON_ATTRIBUTE)) ? BeanDefinition.SCOPE_SINGLETON + : BeanDefinition.SCOPE_PROTOTYPE); + } + else if (containingBean != null) { + // Take default from containing bean in case of an inner bean definition. + bd.setScope(containingBean.getScope()); + } + + if (ele.hasAttribute(ABSTRACT_ATTRIBUTE)) { + bd.setAbstract(TRUE_VALUE.equals(ele.getAttribute(ABSTRACT_ATTRIBUTE))); + } + + String lazyInit = ele.getAttribute(LAZY_INIT_ATTRIBUTE); + if (DEFAULT_VALUE.equals(lazyInit) && bd.isSingleton()) { + // Just apply default to singletons, as lazy-init has no meaning for prototypes. + lazyInit = this.defaults.getLazyInit(); + } + bd.setLazyInit(TRUE_VALUE.equals(lazyInit)); + + String autowire = ele.getAttribute(AUTOWIRE_ATTRIBUTE); + bd.setAutowireMode(getAutowireMode(autowire)); + + String dependencyCheck = ele.getAttribute(DEPENDENCY_CHECK_ATTRIBUTE); + bd.setDependencyCheck(getDependencyCheck(dependencyCheck)); + + if (ele.hasAttribute(DEPENDS_ON_ATTRIBUTE)) { + String dependsOn = ele.getAttribute(DEPENDS_ON_ATTRIBUTE); + bd.setDependsOn(StringUtils.tokenizeToStringArray(dependsOn, BEAN_NAME_DELIMITERS)); + } + + String autowireCandidate = ele.getAttribute(AUTOWIRE_CANDIDATE_ATTRIBUTE); + if ("".equals(autowireCandidate) || DEFAULT_VALUE.equals(autowireCandidate)) { + String candidatePattern = this.defaults.getAutowireCandidates(); + if (candidatePattern != null) { + String[] patterns = StringUtils.commaDelimitedListToStringArray(candidatePattern); + bd.setAutowireCandidate(PatternMatchUtils.simpleMatch(patterns, beanName)); + } + } + else { + bd.setAutowireCandidate(TRUE_VALUE.equals(autowireCandidate)); + } + + if (ele.hasAttribute(PRIMARY_ATTRIBUTE)) { + bd.setPrimary(TRUE_VALUE.equals(ele.getAttribute(PRIMARY_ATTRIBUTE))); + } + + if (ele.hasAttribute(INIT_METHOD_ATTRIBUTE)) { + String initMethodName = ele.getAttribute(INIT_METHOD_ATTRIBUTE); + if (!"".equals(initMethodName)) { + bd.setInitMethodName(initMethodName); + } + } + else { + if (this.defaults.getInitMethod() != null) { + bd.setInitMethodName(this.defaults.getInitMethod()); + bd.setEnforceInitMethod(false); + } + } + + if (ele.hasAttribute(DESTROY_METHOD_ATTRIBUTE)) { + String destroyMethodName = ele.getAttribute(DESTROY_METHOD_ATTRIBUTE); + if (!"".equals(destroyMethodName)) { + bd.setDestroyMethodName(destroyMethodName); + } + } + else { + if (this.defaults.getDestroyMethod() != null) { + bd.setDestroyMethodName(this.defaults.getDestroyMethod()); + bd.setEnforceDestroyMethod(false); + } + } + + if (ele.hasAttribute(FACTORY_METHOD_ATTRIBUTE)) { + bd.setFactoryMethodName(ele.getAttribute(FACTORY_METHOD_ATTRIBUTE)); + } + if (ele.hasAttribute(FACTORY_BEAN_ATTRIBUTE)) { + bd.setFactoryBeanName(ele.getAttribute(FACTORY_BEAN_ATTRIBUTE)); + } + + return bd; + } + + /** * Create a bean definition for the given class name and parent name. + * * @param className the name of the bean class * @param parentName the name of the bean's parent bean * @return the newly created bean definition ! * @throws ClassNotFoundException if bean class resolution was attempted but ! * failed */ protected AbstractBeanDefinition createBeanDefinition(String className, String parentName) throws ClassNotFoundException { ! return BeanDefinitionReaderUtils.createBeanDefinition(parentName, className, ! this.readerContext.getBeanClassLoader()); } *************** *** 751,755 **** this.parseState.push(new ConstructorArgumentEntry(index)); Object value = parsePropertyValue(ele, bd, null); ! ConstructorArgumentValues.ValueHolder valueHolder = new ConstructorArgumentValues.ValueHolder(value); if (StringUtils.hasLength(typeAttr)) { valueHolder.setType(typeAttr); --- 773,778 ---- this.parseState.push(new ConstructorArgumentEntry(index)); Object value = parsePropertyValue(ele, bd, null); ! ConstructorArgumentValues.ValueHolder valueHolder = new ConstructorArgumentValues.ValueHolder( ! value); if (StringUtils.hasLength(typeAttr)) { valueHolder.setType(typeAttr); *************** *** 853,863 **** /** ! * Get the value of a property element. May be a list etc. ! * Also used for constructor arguments, "propertyName" being null in this case. */ public Object parsePropertyValue(Element ele, BeanDefinition bd, String propertyName) { ! String elementName = (propertyName != null) ? ! "<property> element for property '" + propertyName + "'" : ! "<constructor-arg> element"; // Should only have one child element: ref, value, list, etc. --- 876,885 ---- /** ! * Get the value of a property element. May be a list etc. Also used for ! * constructor arguments, "propertyName" being null in this case. */ public Object parsePropertyValue(Element ele, BeanDefinition bd, String propertyName) { ! String elementName = (propertyName != null) ? "<property> element for property '" + propertyName + "'" ! : "<constructor-arg> element"; // Should only have one child element: ref, value, list, etc. *************** *** 866,871 **** for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); ! if (node instanceof Element && !DomUtils.nodeNameEquals(node, DESCRIPTION_ELEMENT) && ! !DomUtils.nodeNameEquals(node, META_ELEMENT)) { // Child element is what we're looking for. if (subElement != null) { --- 888,893 ---- for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); ! if (node instanceof Element && !DomUtils.nodeNameEquals(node, DESCRIPTION_ELEMENT) ! && !DomUtils.nodeNameEquals(node, META_ELEMENT)) { // Child element is what we're looking for. if (subElement != null) { *************** *** 880,887 **** boolean hasRefAttribute = ele.hasAttribute(REF_ATTRIBUTE); boolean hasValueAttribute = ele.hasAttribute(VALUE_ATTRIBUTE); ! if ((hasRefAttribute && hasValueAttribute) || ! ((hasRefAttribute || hasValueAttribute) && subElement != null)) { ! error(elementName + ! " is only allowed to contain either 'ref' attribute OR 'value' attribute OR sub-element", ele); } --- 902,908 ---- boolean hasRefAttribute = ele.hasAttribute(REF_ATTRIBUTE); boolean hasValueAttribute = ele.hasAttribute(VALUE_ATTRIBUTE); ! if ((hasRefAttribute && hasValueAttribute) || ((hasRefAttribute || hasValueAttribute) && subElement != null)) { ! error(elementName ! + " is only allowed to contain either 'ref' attribute OR 'value' attribute OR sub-element", ele); } *************** *** 917,920 **** --- 938,942 ---- * Parse a value, ref or collection sub-element of a property or * constructor-arg element. + * * @param ele subelement of property element; we don't know which yet * @param defaultTypeClassName the default type (class name) for any *************** *** 958,993 **** } else if (DomUtils.nodeNameEquals(ele, IDREF_ELEMENT)) { ! // A generic reference to any name of any bean. ! String refName = ele.getAttribute(BEAN_REF_ATTRIBUTE); ! if (!StringUtils.hasLength(refName)) { ! // A reference to the id of another bean in the same XML file. ! refName = ele.getAttribute(LOCAL_REF_ATTRIBUTE); ! if (!StringUtils.hasLength(refName)) { ! error("Either 'bean' or 'local' is required for <idref> element", ele); ! return null; ! } ! } ! if (!StringUtils.hasText(refName)) { ! error("<idref> element contains empty target attribute", ele); ! return null; ! } ! RuntimeBeanNameReference ref = new RuntimeBeanNameReference(refName); ! ref.setSource(extractSource(ele)); ! return ref; } else if (DomUtils.nodeNameEquals(ele, VALUE_ELEMENT)) { ! // It's a literal value. ! String value = DomUtils.getTextValue(ele); ! String typeClassName = ele.getAttribute(TYPE_ATTRIBUTE); ! if (!StringUtils.hasText(typeClassName)) { ! typeClassName = defaultTypeClassName; ! } ! try { ! return buildTypedStringValue(value, typeClassName, ele); ! } ! catch (ClassNotFoundException ex) { ! error("Type class [" + typeClassName + "] not found for <value> element", ele, ex); ! return value; ! } } else if (DomUtils.nodeNameEquals(ele, NULL_ELEMENT)) { --- 980,987 ---- } else if (DomUtils.nodeNameEquals(ele, IDREF_ELEMENT)) { ! return parseIdRefElement(ele); } else if (DomUtils.nodeNameEquals(ele, VALUE_ELEMENT)) { ! return parseValueElement(ele, defaultTypeClassName); } else if (DomUtils.nodeNameEquals(ele, NULL_ELEMENT)) { *************** *** 1017,1021 **** --- 1011,1066 ---- /** + * Return a typed String value Object for the given 'idref' element. + * + * @param ele + * @param bd + * @return + */ + public Object parseIdRefElement(Element ele) { + // A generic reference to any name of any bean. + String refName = ele.getAttribute(BEAN_REF_ATTRIBUTE); + if (!StringUtils.hasLength(refName)) { + // A reference to the id of another bean in the same XML file. + refName = ele.getAttribute(LOCAL_REF_ATTRIBUTE); + if (!StringUtils.hasLength(refName)) { + error("Either 'bean' or 'local' is required for <idref> element", ele); + return null; + } + } + if (!StringUtils.hasText(refName)) { + error("<idref> element contains empty target attribute", ele); + return null; + } + RuntimeBeanNameReference ref = new RuntimeBeanNameReference(refName); + ref.setSource(extractSource(ele)); + return ref; + } + + /** + * Return a typed String value Object for the given value element. + * + * @param ele element + * @param defaultTypeClassName type class name + * @return typed String value Object + */ + public Object parseValueElement(Element ele, String defaultTypeClassName) { + // It's a literal value. + String value = DomUtils.getTextValue(ele); + String typeClassName = ele.getAttribute(TYPE_ATTRIBUTE); + if (!StringUtils.hasText(typeClassName)) { + typeClassName = defaultTypeClassName; + } + try { + return buildTypedStringValue(value, typeClassName, ele); + } + catch (ClassNotFoundException ex) { + error("Type class [" + typeClassName + "] not found for <value> element", ele, ex); + return value; + } + } + + /** * Build a typed String value Object for the given raw value. + * * @see org.springframework.beans.factory.config.TypedStringValue */ *************** *** 1123,1134 **** boolean hasKeyAttribute = entryEle.hasAttribute(KEY_ATTRIBUTE); boolean hasKeyRefAttribute = entryEle.hasAttribute(KEY_REF_ATTRIBUTE); ! if ((hasKeyAttribute && hasKeyRefAttribute) || ! ((hasKeyAttribute || hasKeyRefAttribute)) && keyEle != null) { ! error("<entry> element is only allowed to contain either " + ! "a 'key' attribute OR a 'key-ref' attribute OR a <key> sub-element", entryEle); } if (hasKeyAttribute) { ! key = buildTypedStringValueForMap( ! entryEle.getAttribute(KEY_ATTRIBUTE), defaultKeyTypeClassName, entryEle); } else if (hasKeyRefAttribute) { --- 1168,1178 ---- boolean hasKeyAttribute = entryEle.hasAttribute(KEY_ATTRIBUTE); boolean hasKeyRefAttribute = entryEle.hasAttribute(KEY_REF_ATTRIBUTE); ! if ((hasKeyAttribute && hasKeyRefAttribute) || ((hasKeyAttribute || hasKeyRefAttribute)) && keyEle != null) { ! error("<entry> element is only allowed to contain either " ! + "a 'key' attribute OR a 'key-ref' attribute OR a <key> sub-element", entryEle); } if (hasKeyAttribute) { ! key = buildTypedStringValueForMap(entryEle.getAttribute(KEY_ATTRIBUTE), defaultKeyTypeClassName, ! entryEle); } else if (hasKeyRefAttribute) { *************** *** 1152,1163 **** boolean hasValueAttribute = entryEle.hasAttribute(VALUE_ATTRIBUTE); boolean hasValueRefAttribute = entryEle.hasAttribute(VALUE_REF_ATTRIBUTE); ! if ((hasValueAttribute && hasValueRefAttribute) || ! ((hasValueAttribute || hasValueRefAttribute)) && valueEle != null) { ! error("<entry> element is only allowed to contain either " + ! "'value' attribute OR 'value-ref' attribute OR <value> sub-element", entryEle); } if (hasValueAttribute) { ! value = buildTypedStringValueForMap( ! entryEle.getAttribute(VALUE_ATTRIBUTE), defaultValueTypeClassName, entryEle); } else if (hasValueRefAttribute) { --- 1196,1207 ---- boolean hasValueAttribute = entryEle.hasAttribute(VALUE_ATTRIBUTE); boolean hasValueRefAttribute = entryEle.hasAttribute(VALUE_REF_ATTRIBUTE); ! if ((hasValueAttribute && hasValueRefAttribute) || ((hasValueAttribute || hasValueRefAttribute)) ! && valueEle != null) { ! error("<entry> element is only allowed to contain either " ! + "'value' attribute OR 'value-ref' attribute OR <value> sub-element", entryEle); } if (hasValueAttribute) { ! value = buildTypedStringValueForMap(entryEle.getAttribute(VALUE_ATTRIBUTE), defaultValueTypeClassName, ! entryEle); } else if (hasValueRefAttribute) { *************** *** 1186,1189 **** --- 1230,1234 ---- /** * Build a typed String value Object for the given raw value. + * * @see org.springframework.beans.factory.config.TypedStringValue */ *************** *** 1274,1279 **** } ! public BeanDefinitionHolder decorateBeanDefinitionIfRequired( ! Element ele, BeanDefinitionHolder definitionHolder, BeanDefinition containingBd) { BeanDefinitionHolder finalDefinition = definitionHolder; --- 1319,1324 ---- } ! public BeanDefinitionHolder decorateBeanDefinitionIfRequired(Element ele, BeanDefinitionHolder definitionHolder, ! BeanDefinition containingBd) { BeanDefinitionHolder finalDefinition = definitionHolder; *************** *** 1297,1302 **** } ! private BeanDefinitionHolder decorateIfRequired( ! Node node, BeanDefinitionHolder originalDef, BeanDefinition containingBd) { String namespaceUri = node.getNamespaceURI(); --- 1342,1347 ---- } ! private BeanDefinitionHolder decorateIfRequired(Node node, BeanDefinitionHolder originalDef, ! BeanDefinition containingBd) { String namespaceUri = node.getNamespaceURI(); *************** *** 1326,1341 **** BeanDefinition innerDefinition = parseCustomElement(ele, containingBd); if (innerDefinition == null) { ! error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " + ! "This tag cannot be used nested inside <property>.", ele); return null; } ! String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR + ! ObjectUtils.getIdentityHexString(innerDefinition); if (logger.isDebugEnabled()) { ! logger.debug("Using generated bean name [" + id + ! "] for nested custom element '" + ele.getNodeName() + "'"); } return new BeanDefinitionHolder(innerDefinition, id); } - } --- 1371,1384 ---- BeanDefinition innerDefinition = parseCustomElement(ele, containingBd); if (innerDefinition == null) { ! error("Incorrect usage of element '" + ele.getNodeName() + "' in a nested manner. " ! + "This tag cannot be used nested inside <property>.", ele); return null; } ! String id = ele.getNodeName() + BeanDefinitionReaderUtils.GENERATED_BEAN_NAME_SEPARATOR ! + ObjectUtils.getIdentityHexString(innerDefinition); if (logger.isDebugEnabled()) { ! logger.debug("Using generated bean name [" + id + "] for nested custom element '" + ele.getNodeName() + "'"); } return new BeanDefinitionHolder(innerDefinition, id); } } |
From: Arjen J.W. P. <po...@us...> - 2008-10-21 10:15:59
|
Update of /cvsroot/springframework/spring/src/org/springframework/context/support In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7622/src/org/springframework/context/support Modified Files: AbstractApplicationContext.java Log Message: Improved logging of MVC: - Added log messages for successful handling of requests - Reduced some debug statements to trace Index: AbstractApplicationContext.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/context/support/AbstractApplicationContext.java,v retrieving revision 1.123 retrieving revision 1.124 diff -C2 -d -r1.123 -r1.124 *** AbstractApplicationContext.java 29 May 2008 22:34:28 -0000 1.123 --- AbstractApplicationContext.java 21 Oct 2008 10:15:42 -0000 1.124 *************** *** 31,35 **** import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.springframework.beans.BeanUtils; import org.springframework.beans.BeansException; --- 31,34 ---- *************** *** 270,275 **** public void publishEvent(ApplicationEvent event) { Assert.notNull(event, "Event must not be null"); ! if (logger.isDebugEnabled()) { ! logger.debug("Publishing event in context [" + getId() + "]: " + event); } getApplicationEventMulticaster().multicastEvent(event); --- 269,274 ---- public void publishEvent(ApplicationEvent event) { Assert.notNull(event, "Event must not be null"); ! if (logger.isTraceEnabled()) { ! logger.trace("Publishing event in context [" + getId() + "]: " + event); } getApplicationEventMulticaster().multicastEvent(event); |
From: Arjen J.W. P. <po...@us...> - 2008-10-21 10:15:50
|
Update of /cvsroot/springframework/spring/src/org/springframework/web/servlet/view In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7622/src/org/springframework/web/servlet/view Modified Files: AbstractCachingViewResolver.java AbstractView.java Log Message: Improved logging of MVC: - Added log messages for successful handling of requests - Reduced some debug statements to trace Index: AbstractView.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/web/servlet/view/AbstractView.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** AbstractView.java 5 May 2008 11:59:31 -0000 1.36 --- AbstractView.java 21 Oct 2008 10:15:42 -0000 1.37 *************** *** 25,29 **** import java.util.Properties; import java.util.StringTokenizer; - import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; --- 25,28 ---- *************** *** 238,243 **** */ public void render(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { ! if (logger.isDebugEnabled()) { ! logger.debug("Rendering view with name '" + this.beanName + "' with model " + model + " and static attributes " + this.staticAttributes); } --- 237,242 ---- */ public void render(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { ! if (logger.isTraceEnabled()) { ! logger.trace("Rendering view with name '" + this.beanName + "' with model " + model + " and static attributes " + this.staticAttributes); } Index: AbstractCachingViewResolver.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/web/servlet/view/AbstractCachingViewResolver.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** AbstractCachingViewResolver.java 11 Apr 2007 17:43:01 -0000 1.30 --- AbstractCachingViewResolver.java 21 Oct 2008 10:15:42 -0000 1.31 *************** *** 78,83 **** view = createView(viewName, locale); this.viewCache.put(cacheKey, view); ! if (logger.isDebugEnabled()) { ! logger.debug("Cached view [" + cacheKey + "]"); } } --- 78,83 ---- view = createView(viewName, locale); this.viewCache.put(cacheKey, view); ! if (logger.isTraceEnabled()) { ! logger.trace("Cached view [" + cacheKey + "]"); } } |
From: Arjen J.W. P. <po...@us...> - 2008-10-21 10:15:50
|
Update of /cvsroot/springframework/spring/src/org/springframework/web/servlet In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7622/src/org/springframework/web/servlet Modified Files: DispatcherServlet.java HandlerExecutionChain.java Log Message: Improved logging of MVC: - Added log messages for successful handling of requests - Reduced some debug statements to trace Index: HandlerExecutionChain.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/web/servlet/HandlerExecutionChain.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** HandlerExecutionChain.java 23 Jul 2007 11:17:35 -0000 1.8 --- HandlerExecutionChain.java 21 Oct 2008 10:15:42 -0000 1.9 *************** *** 114,116 **** --- 114,122 ---- } + /** + * Delegates to the handler's <code>toString()</code>. + */ + public String toString() { + return String.valueOf(handler); + } } Index: DispatcherServlet.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/web/servlet/DispatcherServlet.java,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** DispatcherServlet.java 3 Jul 2008 14:02:53 -0000 1.102 --- DispatcherServlet.java 21 Oct 2008 10:15:42 -0000 1.103 *************** *** 29,33 **** import java.util.Properties; import java.util.Set; - import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; --- 29,32 ---- *************** *** 36,40 **** import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactoryUtils; --- 35,38 ---- *************** *** 781,786 **** if (logger.isDebugEnabled()) { String requestUri = new UrlPathHelper().getRequestUri(request); ! logger.debug( ! "DispatcherServlet with name '" + getServletName() + "' received request for [" + requestUri + "]"); } --- 779,784 ---- if (logger.isDebugEnabled()) { String requestUri = new UrlPathHelper().getRequestUri(request); ! logger.debug("DispatcherServlet with name '" + getServletName() + ! "' processing request for [" + requestUri + "]"); } *************** *** 842,847 **** RequestContextHolder.setRequestAttributes(requestAttributes, this.threadContextInheritable); ! if (logger.isDebugEnabled()) { ! logger.debug("Bound request context to thread: " + request); } --- 840,845 ---- RequestContextHolder.setRequestAttributes(requestAttributes, this.threadContextInheritable); ! if (logger.isTraceEnabled()) { ! logger.trace("Bound request context to thread: " + request); } *************** *** 942,947 **** // Clear request attributes. requestAttributes.requestCompleted(); ! if (logger.isDebugEnabled()) { ! logger.debug("Cleared thread-bound request context: " + request); } } --- 940,945 ---- // Clear request attributes. requestAttributes.requestCompleted(); ! if (logger.isTraceEnabled()) { ! logger.trace("Cleared thread-bound request context: " + request); } } *************** *** 953,956 **** --- 951,959 ---- */ protected long getLastModified(HttpServletRequest request) { + if (logger.isDebugEnabled()) { + String requestUri = new UrlPathHelper().getRequestUri(request); + logger.debug("DispatcherServlet with name '" + getServletName() + + "' determining Last-Modified value for [" + requestUri + "]"); + } try { HandlerExecutionChain mappedHandler = getHandler(request, true); *************** *** 1048,1053 **** while (it.hasNext()) { HandlerMapping hm = (HandlerMapping) it.next(); ! if (logger.isDebugEnabled()) { ! logger.debug("Testing handler map [" + hm + "] in DispatcherServlet with name '" + getServletName() + "'"); } --- 1051,1056 ---- while (it.hasNext()) { HandlerMapping hm = (HandlerMapping) it.next(); ! if (logger.isTraceEnabled()) { ! logger.trace("Testing handler map [" + hm + "] in DispatcherServlet with name '" + getServletName() + "'"); } *************** *** 1088,1093 **** while (it.hasNext()) { HandlerAdapter ha = (HandlerAdapter) it.next(); ! if (logger.isDebugEnabled()) { ! logger.debug("Testing handler adapter [" + ha + "]"); } if (ha.supports(handler)) { --- 1091,1096 ---- while (it.hasNext()) { HandlerAdapter ha = (HandlerAdapter) it.next(); ! if (logger.isTraceEnabled()) { ! logger.trace("Testing handler adapter [" + ha + "]"); } if (ha.supports(handler)) { |
From: Arjen J.W. P. <po...@us...> - 2008-10-21 10:15:50
|
Update of /cvsroot/springframework/spring/src/org/springframework/web/servlet/handler In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7622/src/org/springframework/web/servlet/handler Modified Files: AbstractUrlHandlerMapping.java Log Message: Improved logging of MVC: - Added log messages for successful handling of requests - Reduced some debug statements to trace Index: AbstractUrlHandlerMapping.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** AbstractUrlHandlerMapping.java 19 Feb 2008 21:59:47 -0000 1.44 --- AbstractUrlHandlerMapping.java 21 Oct 2008 10:15:42 -0000 1.45 *************** *** 21,25 **** import java.util.LinkedHashMap; import java.util.Map; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; --- 21,24 ---- *************** *** 158,164 **** protected Object getHandlerInternal(HttpServletRequest request) throws Exception { String lookupPath = this.urlPathHelper.getLookupPathForRequest(request); - if (logger.isDebugEnabled()) { - logger.debug("Looking up handler for [" + lookupPath + "]"); - } Object handler = lookupHandler(lookupPath, request); if (handler == null) { --- 157,160 ---- *************** *** 177,180 **** --- 173,182 ---- } } + if (handler != null && logger.isDebugEnabled()) { + logger.debug("Mapping [" + lookupPath + "] to handler '" + handler + "'"); + } + else if (handler == null && logger.isTraceEnabled()) { + logger.trace("No handler mapping found for [" + lookupPath + "]"); + } return handler; } |
From: Juergen H. <jho...@us...> - 2008-10-20 22:10:42
|
Update of /cvsroot/springframework/spring/tiger/src/org/springframework/orm/jpa In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12809/tiger/src/org/springframework/orm/jpa Modified Files: SharedEntityManagerCreator.java Log Message: @PersistenceContext of type TRANSACTION allows returned Query objects to be parameterized and executed as well Index: SharedEntityManagerCreator.java =================================================================== RCS file: /cvsroot/springframework/spring/tiger/src/org/springframework/orm/jpa/SharedEntityManagerCreator.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SharedEntityManagerCreator.java 29 May 2008 00:35:13 -0000 1.9 --- SharedEntityManagerCreator.java 20 Oct 2008 22:10:36 -0000 1.10 *************** *** 25,28 **** --- 25,29 ---- import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; + import javax.persistence.Query; import org.apache.commons.logging.Log; *************** *** 195,199 **** // Invoke method on current EntityManager. try { ! return method.invoke(target, args); } catch (InvocationTargetException ex) { --- 196,206 ---- // Invoke method on current EntityManager. try { ! Object result = method.invoke(target, args); ! if (isNewEm && result instanceof Query) { ! result = Proxy.newProxyInstance(Query.class.getClassLoader(), new Class[] {Query.class}, ! new DeferredQueryInvocationHandler((Query) result, target)); ! isNewEm = false; ! } ! return result; } catch (InvocationTargetException ex) { *************** *** 208,210 **** --- 215,261 ---- } + + /** + * Invocation handler that handles deferred Query objects created by + * non-transactional createQuery invocations on a shared EntityManager. + */ + private static class DeferredQueryInvocationHandler implements InvocationHandler { + + private final Query target; + + private final EntityManager em; + + private DeferredQueryInvocationHandler(Query target, EntityManager em) { + this.target = target; + this.em = em; + } + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + // Invocation on Query interface coming in... + + if (method.getName().equals("equals")) { + // Only consider equal when proxies are identical. + return (proxy == args[0]); + } + else if (method.getName().equals("hashCode")) { + // Use hashCode of EntityManager proxy. + return hashCode(); + } + + // Invoke method on actual Query object. + try { + return method.invoke(this.target, args); + } + catch (InvocationTargetException ex) { + throw ex.getTargetException(); + } + finally { + if (method.getName().equals("getResultList") || method.getName().equals("getSingleResult") || + method.getName().equals("executeUpdate")) { + EntityManagerFactoryUtils.closeEntityManager(this.em); + } + } + } + } + } |
From: Juergen H. <jho...@us...> - 2008-10-20 22:10:42
|
Update of /cvsroot/springframework/spring/tiger/test/org/springframework/orm/jpa In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12809/tiger/test/org/springframework/orm/jpa Modified Files: AbstractContainerEntityManagerFactoryIntegrationTests.java Log Message: @PersistenceContext of type TRANSACTION allows returned Query objects to be parameterized and executed as well Index: AbstractContainerEntityManagerFactoryIntegrationTests.java =================================================================== RCS file: /cvsroot/springframework/spring/tiger/test/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AbstractContainerEntityManagerFactoryIntegrationTests.java 14 Jul 2008 12:48:28 -0000 1.8 --- AbstractContainerEntityManagerFactoryIntegrationTests.java 20 Oct 2008 22:10:36 -0000 1.9 *************** *** 22,25 **** --- 22,27 ---- import javax.persistence.EntityManager; import javax.persistence.EntityNotFoundException; + import javax.persistence.FlushModeType; + import javax.persistence.NoResultException; import javax.persistence.Query; *************** *** 30,34 **** import org.springframework.test.annotation.Repeat; import org.springframework.test.annotation.Timed; - import org.springframework.transaction.annotation.Transactional; /** --- 32,35 ---- *************** *** 41,45 **** public abstract class AbstractContainerEntityManagerFactoryIntegrationTests extends AbstractEntityManagerFactoryIntegrationTests { ! @NotTransactional public void testEntityManagerFactoryImplementsEntityManagerFactoryInfo() { --- 42,46 ---- public abstract class AbstractContainerEntityManagerFactoryIntegrationTests extends AbstractEntityManagerFactoryIntegrationTests { ! @NotTransactional public void testEntityManagerFactoryImplementsEntityManagerFactoryInfo() { *************** *** 57,66 **** 0, countRowsInTable("person")); } ! @Repeat(5) public void testJdbcTx1() throws Exception { testJdbcTx2(); } ! @Timed(millis=273) public void testJdbcTx2() throws InterruptedException { --- 58,67 ---- 0, countRowsInTable("person")); } ! @Repeat(5) public void testJdbcTx1() throws Exception { testJdbcTx2(); } ! @Timed(millis=273) public void testJdbcTx2() throws InterruptedException { *************** *** 70,75 **** executeSqlScript("/sql/insertPerson.sql", false); } ! ! @Transactional(readOnly=true) public void testEntityManagerProxyIsProxy() { assertTrue(Proxy.isProxyClass(sharedEntityManager.getClass())); --- 71,76 ---- executeSqlScript("/sql/insertPerson.sql", false); } ! ! //@NotTransactional public void testEntityManagerProxyIsProxy() { assertTrue(Proxy.isProxyClass(sharedEntityManager.getClass())); *************** *** 88,92 **** query.executeUpdate(); } ! @ExpectedException(EntityNotFoundException.class) public void testGetReferenceWhenNoRow() { --- 89,93 ---- query.executeUpdate(); } ! @ExpectedException(EntityNotFoundException.class) public void testGetReferenceWhenNoRow() { *************** *** 191,194 **** --- 192,257 ---- List<Person> people = q.getResultList(); assertEquals(0, people.size()); + try { + assertNull(q.getSingleResult()); + fail("Should have thrown NoResultException"); + } + catch (NoResultException ex) { + // expected + } + } + + @NotTransactional + public void testQueryNoPersonsNotTransactional() { + EntityManager em = entityManagerFactory.createEntityManager(); + Query q = em.createQuery("select p from Person as p"); + List<Person> people = q.getResultList(); + assertEquals(0, people.size()); + try { + assertNull(q.getSingleResult()); + fail("Should have thrown NoResultException"); + } + catch (NoResultException ex) { + // expected + } + } + + public void testQueryNoPersonsShared() { + EntityManager em = SharedEntityManagerCreator.createSharedEntityManager(entityManagerFactory); + Query q = em.createQuery("select p from Person as p"); + q.setFlushMode(FlushModeType.AUTO); + List<Person> people = q.getResultList(); + try { + assertNull(q.getSingleResult()); + fail("Should have thrown NoResultException"); + } + catch (NoResultException ex) { + // expected + } + } + + @NotTransactional + public void testQueryNoPersonsSharedNotTransactional() { + EntityManager em = SharedEntityManagerCreator.createSharedEntityManager(entityManagerFactory); + Query q = em.createQuery("select p from Person as p"); + q.setFlushMode(FlushModeType.AUTO); + List<Person> people = q.getResultList(); + assertEquals(0, people.size()); + try { + assertNull(q.getSingleResult()); + fail("Should have thrown IllegalStateException"); + } + catch (Exception ex) { + // IllegalStateException expected, but PersistenceException thrown by Hibernate + assertTrue(ex.getMessage().indexOf("closed") != -1); + } + q = em.createQuery("select p from Person as p"); + q.setFlushMode(FlushModeType.AUTO); + try { + assertNull(q.getSingleResult()); + fail("Should have thrown NoResultException"); + } + catch (NoResultException ex) { + // expected + } } |
From: Juergen H. <jho...@us...> - 2008-10-20 21:08:31
|
Update of /cvsroot/springframework/spring/tiger/test/org/springframework/transaction/annotation In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7683/tiger/test/org/springframework/transaction/annotation Modified Files: AnnotationTransactionNamespaceHandlerTests.java annotationTransactionNamespaceHandlerTests.xml Log Message: added test for JMX export in combination with @Transactional Index: AnnotationTransactionNamespaceHandlerTests.java =================================================================== RCS file: /cvsroot/springframework/spring/tiger/test/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AnnotationTransactionNamespaceHandlerTests.java 29 May 2008 17:29:12 -0000 1.7 --- AnnotationTransactionNamespaceHandlerTests.java 20 Oct 2008 21:08:22 -0000 1.8 *************** *** 17,29 **** package org.springframework.transaction.annotation; import java.util.Collection; import java.util.Map; import junit.framework.TestCase; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.generic.GenericBeanFactoryAccessor; ! import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.stereotype.Service; import org.springframework.transaction.CallCountingTransactionManager; --- 17,35 ---- package org.springframework.transaction.annotation; + import java.lang.management.ManagementFactory; import java.util.Collection; import java.util.Map; + import javax.management.MBeanServer; + import javax.management.ObjectName; + import junit.framework.TestCase; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.generic.GenericBeanFactoryAccessor; ! import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; + import org.springframework.jmx.export.annotation.ManagedOperation; + import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.stereotype.Service; import org.springframework.transaction.CallCountingTransactionManager; *************** *** 35,39 **** public class AnnotationTransactionNamespaceHandlerTests extends TestCase { ! private ApplicationContext context; public void setUp() { --- 41,45 ---- public class AnnotationTransactionNamespaceHandlerTests extends TestCase { ! private ConfigurableApplicationContext context; public void setUp() { *************** *** 42,45 **** --- 48,55 ---- } + protected void tearDown() { + this.context.close(); + } + public void testIsProxy() throws Exception { TransactionalTestBean bean = getTestBean(); *************** *** 84,87 **** --- 94,103 ---- } + public void testMBeanExportAlsoWorks() throws Exception { + MBeanServer server = ManagementFactory.getPlatformMBeanServer(); + assertEquals("done", + server.invoke(ObjectName.getInstance("test:type=TestBean"), "doSomething", new Object[0], new String[0])); + } + private TransactionalTestBean getTestBean() { return (TransactionalTestBean) context.getBean("testBean"); *************** *** 90,93 **** --- 106,110 ---- @Service + @ManagedResource("test:type=TestBean") public static class TransactionalTestBean { *************** *** 99,103 **** @Transactional public void saveFoo() { - } --- 116,119 ---- *************** *** 107,111 **** } ! public void doSomething() { } --- 123,129 ---- } ! @ManagedOperation ! public String doSomething() { ! return "done"; } Index: annotationTransactionNamespaceHandlerTests.xml =================================================================== RCS file: /cvsroot/springframework/spring/tiger/test/org/springframework/transaction/annotation/annotationTransactionNamespaceHandlerTests.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** annotationTransactionNamespaceHandlerTests.xml 9 Sep 2006 22:40:27 -0000 1.4 --- annotationTransactionNamespaceHandlerTests.xml 20 Oct 2008 21:08:22 -0000 1.5 *************** *** 3,9 **** --- 3,11 ---- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" + xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> *************** *** 15,17 **** class="org.springframework.transaction.annotation.AnnotationTransactionNamespaceHandlerTests$TransactionalTestBean"/> ! </beans> \ No newline at end of file --- 17,21 ---- class="org.springframework.transaction.annotation.AnnotationTransactionNamespaceHandlerTests$TransactionalTestBean"/> ! <context:mbean-export/> ! ! </beans> |
From: Juergen H. <jho...@us...> - 2008-10-20 20:52:36
|
Update of /cvsroot/springframework/spring/docs/reference/src In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv6171/docs/reference/src Modified Files: jmx.xml Log Message: added warning on JMX annotations with JDK proxies Index: jmx.xml =================================================================== RCS file: /cvsroot/springframework/spring/docs/reference/src/jmx.xml,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** jmx.xml 21 Jul 2008 13:36:52 -0000 1.40 --- jmx.xml 20 Oct 2008 20:52:20 -0000 1.41 *************** *** 643,651 **** <para>As you can see little has changed, other than the basic syntax of ! the metadata definitions. Behind the scenes this approach is a little ! slower at startup because the JDK 5.0 annotations are converted into the ! classes used by Commons Attributes. However, this is only a one-off cost ! and JDK 5.0 annotations give you the added (and valuable) benefit of ! compile-time checking.</para> <programlisting><![CDATA[<beans> --- 643,647 ---- <para>As you can see little has changed, other than the basic syntax of ! the metadata definitions.</para> <programlisting><![CDATA[<beans> *************** *** 961,965 **** <section id="jmx-interface-java"> ! <title>Defining Management interfaces using Java interfaces</title> <para>In addition to the --- 957,961 ---- <section id="jmx-interface-java"> ! <title>Defining management interfaces using Java interfaces</title> <para>In addition to the *************** *** 1244,1247 **** --- 1240,1252 ---- <programlisting><![CDATA[<context:mbean-export server="myMBeanServer" default-domain="myDomain"/>]]></programlisting>. + <note> + <para>Do not use interface-based AOP proxies in combination with autodetection of + JMX annotations in your bean classes. Interface-based proxies 'hide' the target class, + which also hides the JMX managed resource annotations. Hence, use target-class proxies + in that case: through setting the 'proxy-target-class' flag on <literal><aop:config/></literal>, + <literal><tx:annotation-driven/></literal>, etc. Otherwise, your JMX beans + might be silently ignored at startup...</para> + </note> + </section> </section> |
From: Arjen J.W. P. <po...@us...> - 2008-10-20 19:44:34
|
Update of /cvsroot/springframework/spring/src/org/springframework/context/config In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv739/src/org/springframework/context/config Modified Files: spring-context-2.5.xsd Log Message: SPR-5203 Index: spring-context-2.5.xsd =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/context/config/spring-context-2.5.xsd,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** spring-context-2.5.xsd 17 Oct 2008 16:39:10 -0000 1.16 --- spring-context-2.5.xsd 20 Oct 2008 19:44:27 -0000 1.17 *************** *** 1,11 **** <?xml version="1.0" encoding="UTF-8"?> ! <xsd:schema xmlns="http://www.springframework.org/schema/context" ! xmlns:xsd="http://www.w3.org/2001/XMLSchema" ! xmlns:beans="http://www.springframework.org/schema/beans" ! xmlns:tool="http://www.springframework.org/schema/tool" ! targetNamespace="http://www.springframework.org/schema/context" ! elementFormDefault="qualified" ! attributeFormDefault="unqualified"> <xsd:import namespace="http://www.springframework.org/schema/beans"/> --- 1,9 ---- <?xml version="1.0" encoding="UTF-8"?> ! <xsd:schema xmlns="http://www.springframework.org/schema/context" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ! xmlns:beans="http://www.springframework.org/schema/beans" ! xmlns:tool="http://www.springframework.org/schema/tool" ! targetNamespace="http://www.springframework.org/schema/context" elementFormDefault="qualified" ! attributeFormDefault="unqualified"> <xsd:import namespace="http://www.springframework.org/schema/beans"/> *************** *** 68,72 **** </xsd:annotation> <xsd:complexType> ! <xsd:attribute name="location" type="xsd:string" use="required"> <xsd:annotation> <xsd:documentation><![CDATA[ --- 66,70 ---- </xsd:annotation> <xsd:complexType> ! <xsd:attribute name="location" type="xsd:string"> <xsd:annotation> <xsd:documentation><![CDATA[ *************** *** 128,132 **** <xsd:element name="include-filter" type="filterType" minOccurs="0" maxOccurs="unbounded"> <xsd:annotation> ! <xsd:documentation><![CDATA[ Controls which eligible types to include for component scanning. ]]></xsd:documentation> --- 126,130 ---- <xsd:element name="include-filter" type="filterType" minOccurs="0" maxOccurs="unbounded"> <xsd:annotation> ! <xsd:documentation><![CDATA[ Controls which eligible types to include for component scanning. ]]></xsd:documentation> *************** *** 293,297 **** <xsd:element name="spring-configured"> <xsd:annotation> ! <xsd:documentation source="java:org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect"><![CDATA[ Signals the current application context to apply dependency injection to non-managed classes that are instantiated outside of the Spring bean --- 291,296 ---- <xsd:element name="spring-configured"> <xsd:annotation> ! <xsd:documentation source="java:org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect"> ! <![CDATA[ Signals the current application context to apply dependency injection to non-managed classes that are instantiated outside of the Spring bean *************** *** 389,394 **** <xsd:complexType name="filterType"> <xsd:attribute name="type" use="required"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ Controls the type of filtering to apply to the expression. --- 388,393 ---- <xsd:complexType name="filterType"> <xsd:attribute name="type" use="required"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ Controls the type of filtering to apply to the expression. *************** *** 402,424 **** Hence, it needs to be specified per concrete bean definition. ]]></xsd:documentation> ! </xsd:annotation> ! <xsd:simpleType> <xsd:restriction base="xsd:string"> ! <xsd:enumeration value="annotation"/> ! <xsd:enumeration value="assignable"/> ! <xsd:enumeration value="aspectj"/> ! <xsd:enumeration value="regex"/> ! <xsd:enumeration value="custom"/> </xsd:restriction> </xsd:simpleType> </xsd:attribute> <xsd:attribute name="expression" type="xsd:string" use="required"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ Indicates the filter expression, the type of which is indicated by "type". ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:attribute> ! </xsd:complexType> </xsd:schema> --- 401,423 ---- Hence, it needs to be specified per concrete bean definition. ]]></xsd:documentation> ! </xsd:annotation> ! <xsd:simpleType> <xsd:restriction base="xsd:string"> ! <xsd:enumeration value="annotation"/> ! <xsd:enumeration value="assignable"/> ! <xsd:enumeration value="aspectj"/> ! <xsd:enumeration value="regex"/> ! <xsd:enumeration value="custom"/> </xsd:restriction> </xsd:simpleType> </xsd:attribute> <xsd:attribute name="expression" type="xsd:string" use="required"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ Indicates the filter expression, the type of which is indicated by "type". ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:attribute> ! </xsd:complexType> </xsd:schema> |
From: Arjen J.W. P. <po...@us...> - 2008-10-20 19:44:34
|
Update of /cvsroot/springframework/spring/test/org/springframework/context/config In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv739/test/org/springframework/context/config Added Files: contextNamespaceHandlerTests.xml ContextNamespaceHandlerTests.java Log Message: SPR-5203 --- NEW FILE: contextNamespaceHandlerTests.xml --- <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd"> <util:properties id="placeholderProps"> <prop key="foo">bar</prop> </util:properties> <context:property-placeholder properties-ref="placeholderProps"/> <bean id="string" class="java.lang.String"> <constructor-arg value="${foo}"/> </bean> <util:properties id="overrideProps"> <prop key="date.minutes">42</prop> </util:properties> <context:property-override properties-ref="overrideProps"/> <bean id="date" class="java.util.Date"> <property name="minutes" value="10"/> </bean> </beans> --- NEW FILE: ContextNamespaceHandlerTests.java --- /* * Copyright 2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.context.config; import java.util.Date; import java.util.Map; import junit.framework.TestCase; import org.springframework.beans.factory.config.PropertyOverrideConfigurer; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; /** * @author Arjen Poutsma * @since 2.5.6 */ public class ContextNamespaceHandlerTests extends TestCase { private ApplicationContext applicationContext; protected void setUp() throws Exception { applicationContext = new ClassPathXmlApplicationContext("contextNamespaceHandlerTests.xml", getClass()); } public void testPropertyPlaceholder() throws Exception { Map beans = applicationContext.getBeansOfType(PropertyPlaceholderConfigurer.class); assertFalse("No PropertyPlaceHolderConfigurer found", beans.isEmpty()); String s = (String) applicationContext.getBean("string"); assertEquals("No properties replaced", "bar", s); } public void testPropertyOverride() throws Exception { Map beans = applicationContext.getBeansOfType(PropertyOverrideConfigurer.class); assertFalse("No PropertyOverrideConfigurer found", beans.isEmpty()); Date date = (Date) applicationContext.getBean("date"); assertEquals("No properties overriden", 42, date.getMinutes()); } } |
From: Juergen H. <jho...@us...> - 2008-10-20 14:58:41
|
Update of /cvsroot/springframework/spring/src/org/springframework/web/servlet/view In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9637/src/org/springframework/web/servlet/view Modified Files: RedirectView.java Log Message: added notes on Portlet redirects Index: RedirectView.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/web/servlet/view/RedirectView.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** RedirectView.java 2 Jul 2008 10:22:36 -0000 1.31 --- RedirectView.java 20 Oct 2008 14:58:31 -0000 1.32 *************** *** 50,56 **** * with the flag on, they are considered relative to the web application root. * Since most web applications will never know or care what their context path ! * actually is, they are much better off setting this flag to true, and ! * submitting paths which are to be considered relative to the web application ! * root. * * @author Rod Johnson --- 50,62 ---- * with the flag on, they are considered relative to the web application root. * Since most web applications will never know or care what their context path ! * actually is, they are much better off setting this flag to true, and submitting ! * paths which are to be considered relative to the web application root. ! * ! * <p><b>NOTE when using this redirect view in a Portlet environment:</b> Make sure ! * that your controller respects the Portlet <code>sendRedirect</code> constraints. ! * When e.g. using {@link org.springframework.web.portlet.mvc.SimpleFormController}, ! * make sure to set your controller's ! * {@link org.springframework.web.portlet.mvc.AbstractFormController#setRedirectAction "redirectAction"} ! * property to "true", in order to make the controller base class behave accordingly. * * @author Rod Johnson |
From: Juergen H. <jho...@us...> - 2008-10-20 14:58:40
|
Update of /cvsroot/springframework/spring/src/org/springframework/web/portlet/mvc In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9637/src/org/springframework/web/portlet/mvc Modified Files: AbstractFormController.java Log Message: added notes on Portlet redirects Index: AbstractFormController.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/web/portlet/mvc/AbstractFormController.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** AbstractFormController.java 17 Jul 2008 15:30:48 -0000 1.10 --- AbstractFormController.java 20 Oct 2008 14:58:31 -0000 1.11 *************** *** 325,329 **** * {@link ActionResponse#setRenderParameter} and * {@link ActionResponse#setRenderParameters}. ! * @param redirectAction true if ActionResponse#sendRedirect is expected to be called * @see ActionResponse#sendRedirect */ --- 325,330 ---- * {@link ActionResponse#setRenderParameter} and * {@link ActionResponse#setRenderParameters}. ! * <p><b>NOTE:</b> Call this at initialization time of your controller: ! * either in the constructor or in the bean definition for your controller. * @see ActionResponse#sendRedirect */ *************** *** 343,347 **** * Specify the list of parameters that should be passed forward * from the action phase to the render phase whenever the form is ! * rerendered or when {@link #passRenderParameters} is called. * @see #passRenderParameters */ --- 344,348 ---- * Specify the list of parameters that should be passed forward * from the action phase to the render phase whenever the form is ! * re-rendered or when {@link #passRenderParameters} is called. * @see #passRenderParameters */ |
From: Juergen H. <jho...@us...> - 2008-10-20 14:26:12
|
Update of /cvsroot/springframework/spring/src/org/springframework/transaction/jta In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv6973/src/org/springframework/transaction/jta Modified Files: JotmFactoryBean.java Log Message: JotmFactoryBean sets "defaultTimeout" value as actual JOTM default (even if no transaction timeout specified at all) Index: JotmFactoryBean.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/transaction/jta/JotmFactoryBean.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** JotmFactoryBean.java 31 Dec 2006 19:55:43 -0000 1.14 --- JotmFactoryBean.java 20 Oct 2008 14:25:58 -0000 1.15 *************** *** 1,4 **** /* ! * Copyright 2002-2006 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); --- 1,4 ---- /* ! * Copyright 2002-2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); *************** *** 18,21 **** --- 18,22 ---- import javax.naming.NamingException; + import javax.transaction.SystemException; import org.objectweb.jotm.Current; *************** *** 26,31 **** /** ! * FactoryBean that retrieves the JTA UserTransaction/TransactionManager for ! * ObjectWeb's <a href="http://jotm.objectweb.org">JOTM</a>. Will retrieve * an already active JOTM instance if found (e.g. if running in JOnAS), * else create a new local JOTM instance. --- 27,32 ---- /** ! * {@link FactoryBean} that retrieves the JTA UserTransaction/TransactionManager ! * for ObjectWeb's <a href="http://jotm.objectweb.org">JOTM</a>. Will retrieve * an already active JOTM instance if found (e.g. if running in JOnAS), * else create a new local JOTM instance. *************** *** 105,110 **** --- 106,120 ---- public void setDefaultTimeout(int defaultTimeout) { this.jotmCurrent.setDefaultTimeout(defaultTimeout); + // The following is a JOTM oddity: should be used for demarcation transaction only, + // but is required here in order to actually get rid of JOTM's default (60 seconds). + try { + this.jotmCurrent.setTransactionTimeout(defaultTimeout); + } + catch (SystemException ex) { + // should never happen + } } + /** * Return the JOTM instance created by this factory bean, if any. *************** *** 116,120 **** } - public Object getObject() { return this.jotmCurrent; --- 126,129 ---- |
From: Juergen H. <jho...@us...> - 2008-10-20 14:02:52
|
Update of /cvsroot/springframework/spring In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4917 Modified Files: changelog.txt Log Message: SchedulerFactoryBean etc Index: changelog.txt =================================================================== RCS file: /cvsroot/springframework/spring/changelog.txt,v retrieving revision 1.736 retrieving revision 1.737 diff -C2 -d -r1.736 -r1.737 *** changelog.txt 16 Oct 2008 19:28:11 -0000 1.736 --- changelog.txt 20 Oct 2008 14:02:43 -0000 1.737 *************** *** 4,8 **** ! Changes in version 2.5.6 (2008-10-20) ------------------------------------- --- 4,8 ---- ! Changes in version 2.5.6 (2008-10-22) ------------------------------------- *************** *** 119,122 **** --- 119,127 ---- Package org.springframework.scheduling * SchedulerFactoryBean populates scheduler context first before satisfying SchedulerContextAware on a given JobFactory + * SchedulerFactoryBean uses bean name as default scheduler name (when "schedulerName" property not explicitly specified) + * SchedulerFactoryBean does not accept a pre-registered Scheduler instance in the Quartz SchedulerRepository anymore + * SchedulerFactoryBean does not expose the Spring-created/managed Scheduler to the Quartz SchedulerRepository anymore + * added "exposeSchedulerInRepository" flag to SchedulerFactoryBean, for explicit exposure to the SchedulerRepository + * introduced SchedulerAccessorBean for registering jobs/triggers/listeners on an existing Quartz Scheduler instance * ScheduledExecutorFactoryBean uses Runnable decorator for logging exceptions that lead to termination of execution *************** *** 139,142 **** --- 144,148 ---- * Servlet/PortletContextResource accept path with leading "/../" part as well (as accepted by most servlet containers) * DispatcherServlet removes error-view-driven servlet request attributes after rendering (for Tomcat compatibility) + * exposed "getParamName()" method on LocaleChangeInterceptor and ThemeChangeInterceptor * added "cacheSecondsForSessionAttributeHandlers" property to Servlet/Portlet AnnotationMethodHandlerAdapter * AnnotationMethodHandlerAdapter exposes special ModelMap that removes BindingResult if target attribute gets replaced |
Update of /cvsroot/springframework/spring/test/org/springframework/scheduling/quartz In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4699/test/org/springframework/scheduling/quartz Modified Files: QuartzSupportTests.java multipleSchedulers.xml Added Files: schedulerRepositoryExposure.xml schedulerAccessorBean.xml Log Message: use bean name as default scheduler name (when "schedulerName" property not explicitly specified); do not accept a pre-registered Scheduler instance in the Quartz SchedulerRepository anymore; do not expose the Spring-created/managed Scheduler to the Quartz SchedulerRepository anymore; added "exposeSchedulerInRepository" flag for explicit exposure to the SchedulerRepository; introduced SchedulerAccessorBean for registering jobs/triggers/listeners on an existing Quartz Scheduler instance --- NEW FILE: schedulerAccessorBean.xml --- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <beans> <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"/> <bean class="org.springframework.scheduling.quartz.SchedulerAccessorBean"> <property name="scheduler" ref="scheduler"/> <property name="triggers"> <list> <ref local="exportTrigger"/> <ref local="importTrigger"/> </list> </property> </bean> <bean id="exportTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"> <property name="jobDetail"> <bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="exportService"/> <property name="targetMethod" value="doExport"/> </bean> </property> <property name="repeatInterval" value="1000"/> <property name="repeatCount" value="1"/> </bean> <bean id="importTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"> <property name="jobDetail"> <bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="importService"/> <property name="targetMethod" value="doImport"/> </bean> </property> <property name="repeatInterval" value="1000"/> <property name="repeatCount" value="1"/> </bean> <bean id="exportService" class="org.springframework.scheduling.quartz.QuartzTestBean"/> <bean id="importService" class="org.springframework.scheduling.quartz.QuartzTestBean"/> </beans> --- NEW FILE: schedulerRepositoryExposure.xml --- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <beans> <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="schedulerName" value="myScheduler"/> <property name="exposeSchedulerInRepository" value="true"/> </bean> <bean class="org.springframework.scheduling.quartz.SchedulerAccessorBean"> <property name="schedulerName" value="myScheduler"/> <property name="triggers"> <list> <ref local="exportTrigger"/> <ref local="importTrigger"/> </list> </property> </bean> <bean id="exportTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"> <property name="jobDetail"> <bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="exportService"/> <property name="targetMethod" value="doExport"/> </bean> </property> <property name="repeatInterval" value="1000"/> <property name="repeatCount" value="1"/> </bean> <bean id="importTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"> <property name="jobDetail"> <bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="importService"/> <property name="targetMethod" value="doImport"/> </bean> </property> <property name="repeatInterval" value="1000"/> <property name="repeatCount" value="1"/> </bean> <bean id="exportService" class="org.springframework.scheduling.quartz.QuartzTestBean"/> <bean id="importService" class="org.springframework.scheduling.quartz.QuartzTestBean"/> </beans> Index: QuartzSupportTests.java =================================================================== RCS file: /cvsroot/springframework/spring/test/org/springframework/scheduling/quartz/QuartzSupportTests.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** QuartzSupportTests.java 7 May 2008 22:43:59 -0000 1.16 --- QuartzSupportTests.java 20 Oct 2008 14:00:46 -0000 1.17 *************** *** 40,43 **** --- 40,44 ---- import org.quartz.Trigger; import org.quartz.TriggerListener; + import org.quartz.impl.SchedulerRepository; import org.quartz.spi.JobFactory; *************** *** 891,895 **** Scheduler scheduler2 = (Scheduler) ctx.getBean("scheduler2"); assertNotSame(scheduler1, scheduler2); ! assertFalse(scheduler1.getSchedulerName().equals(scheduler2.getSchedulerName())); } finally { --- 892,897 ---- Scheduler scheduler2 = (Scheduler) ctx.getBean("scheduler2"); assertNotSame(scheduler1, scheduler2); ! assertEquals("quartz1", scheduler1.getSchedulerName()); ! assertEquals("quartz2", scheduler2.getSchedulerName()); } finally { *************** *** 916,919 **** --- 918,946 ---- } + public void testSchedulerAccessorBean() throws InterruptedException { + ClassPathXmlApplicationContext ctx = + new ClassPathXmlApplicationContext("/org/springframework/scheduling/quartz/schedulerAccessorBean.xml"); + Thread.sleep(3000); + try { + QuartzTestBean exportService = (QuartzTestBean) ctx.getBean("exportService"); + QuartzTestBean importService = (QuartzTestBean) ctx.getBean("importService"); + + assertEquals("doImport called exportService", 0, exportService.getImportCount()); + assertEquals("doExport not called on exportService", 2, exportService.getExportCount()); + assertEquals("doImport not called on importService", 2, importService.getImportCount()); + assertEquals("doExport called on importService", 0, importService.getExportCount()); + } + finally { + ctx.close(); + } + } + + public void testSchedulerRepositoryExposure() throws InterruptedException { + ClassPathXmlApplicationContext ctx = + new ClassPathXmlApplicationContext("/org/springframework/scheduling/quartz/schedulerRepositoryExposure.xml"); + assertSame(SchedulerRepository.getInstance().lookup("myScheduler"), ctx.getBean("scheduler")); + ctx.close(); + } + private static class TestSchedulerListener implements SchedulerListener { Index: multipleSchedulers.xml =================================================================== RCS file: /cvsroot/springframework/spring/test/org/springframework/scheduling/quartz/multipleSchedulers.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** multipleSchedulers.xml 20 Aug 2006 19:08:42 -0000 1.3 --- multipleSchedulers.xml 20 Oct 2008 14:00:46 -0000 1.4 *************** *** 5,13 **** <bean id="scheduler1" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> ! <property name="schedulerName"><value>quartz1</value></property> </bean> <bean id="scheduler2" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> ! <property name="schedulerName"><value>quartz2</value></property> </bean> --- 5,13 ---- <bean id="scheduler1" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> ! <property name="schedulerName" value="quartz1"/> </bean> <bean id="scheduler2" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> ! <property name="schedulerName" value="quartz2"/> </bean> |
From: Juergen H. <jho...@us...> - 2008-10-17 16:39:14
|
Update of /cvsroot/springframework/spring/src/org/springframework/context/config In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20319/src/org/springframework/context/config Modified Files: spring-context-2.5.xsd Log Message: removed scoped-proxy default value again in order to let the parser handle scope-resolver versus scoped-proxy Index: spring-context-2.5.xsd =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/context/config/spring-context-2.5.xsd,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** spring-context-2.5.xsd 14 Oct 2008 15:23:38 -0000 1.15 --- spring-context-2.5.xsd 17 Oct 2008 16:39:10 -0000 1.16 *************** *** 46,50 **** <xsd:attribute name="properties-ref" type="xsd:string"> <xsd:annotation> ! <xsd:documentation source="java:java.util.Properties"><![CDATA[ The bean name of a Java Properties object that will be used for property substitution. If neither location nor properties-ref is specified, placeholders will be resolved against system properties. --- 46,50 ---- <xsd:attribute name="properties-ref" type="xsd:string"> <xsd:annotation> ! <xsd:documentation source="java:java.util.Properties"><![CDATA[ The bean name of a Java Properties object that will be used for property substitution. If neither location nor properties-ref is specified, placeholders will be resolved against system properties. *************** *** 77,87 **** </xsd:annotation> </xsd:attribute> ! <xsd:attribute name="properties-ref" type="xsd:string"> ! <xsd:annotation> ! <xsd:documentation source="java:java.util.Properties"><![CDATA[ ! The bean name of a Java Properties object that will be used for property overrides. ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:attribute> </xsd:complexType> </xsd:element> --- 77,87 ---- </xsd:annotation> </xsd:attribute> ! <xsd:attribute name="properties-ref" type="xsd:string"> ! <xsd:annotation> ! <xsd:documentation source="java:java.util.Properties"><![CDATA[ ! The bean name of a Java Properties object that will be used for property overrides. ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:attribute> </xsd:complexType> </xsd:element> *************** *** 127,208 **** <xsd:sequence> <xsd:element name="include-filter" type="filterType" minOccurs="0" maxOccurs="unbounded"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! Controls which eligible types to include for component scanning. ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:element> ! <xsd:element name="exclude-filter" type="filterType" minOccurs="0" maxOccurs="unbounded"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! Controls which eligible types to exclude for component scanning. ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:element> ! </xsd:sequence> <xsd:attribute name="base-package" type="xsd:string" use="required"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! The comma-separated list of packages to scan for annotated components. ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:attribute> ! <xsd:attribute name="resource-pattern" type="xsd:string"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! Controls the class files eligible for component detection. Defaults to "**/*.class", the recommended value. ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:attribute> ! <xsd:attribute name="use-default-filters" type="xsd:boolean" default="true"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! Indicates whether automatic detection of classes annotated with @Component, @Repository, @Service, or @Controller ! should be enabled. Default is "true". ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:attribute> ! <xsd:attribute name="annotation-config" type="xsd:boolean" default="true"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! Indicates whether the implicit AutowiredAnnotationBeanPostProcessor and CommonAnnotationBeanPostProcessor should ! be enabled. Default is "true". ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:attribute> ! <xsd:attribute name="name-generator" type="xsd:string"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ The fully-qualified classname of the BeanNameGenerator to be used for naming detected components. ! ]]></xsd:documentation> ! <xsd:appinfo> ! <tool:annotation> ! <tool:expected-type type="java.lang.Class"/> ! <tool:assignable-to type="org.springframework.beans.factory.support.BeanNameGenerator"/> ! </tool:annotation> ! </xsd:appinfo> ! </xsd:annotation> ! </xsd:attribute> ! <xsd:attribute name="scope-resolver" type="xsd:string"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! The fully-qualified classname of the ScopeMetadataResolver to be used for resolving the scope of detected components. ! ]]></xsd:documentation> ! <xsd:appinfo> ! <tool:annotation> ! <tool:expected-type type="java.lang.Class"/> ! <tool:assignable-to type="org.springframework.context.annotation.ScopeMetadataResolver"/> ! </tool:annotation> ! </xsd:appinfo> ! </xsd:annotation> ! </xsd:attribute> ! <xsd:attribute name="scoped-proxy" default="no"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! Indicates whether proxies should be generated for detected components, which may be necessary when using certain ! non-singleton scopes. The default is "no". ! ]]></xsd:documentation> ! </xsd:annotation> ! <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="no"/> --- 127,208 ---- <xsd:sequence> <xsd:element name="include-filter" type="filterType" minOccurs="0" maxOccurs="unbounded"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! Controls which eligible types to include for component scanning. ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:element> ! <xsd:element name="exclude-filter" type="filterType" minOccurs="0" maxOccurs="unbounded"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! Controls which eligible types to exclude for component scanning. ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:element> ! </xsd:sequence> <xsd:attribute name="base-package" type="xsd:string" use="required"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! The comma-separated list of packages to scan for annotated components. ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:attribute> ! <xsd:attribute name="resource-pattern" type="xsd:string"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! Controls the class files eligible for component detection. Defaults to "**/*.class", the recommended value. ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:attribute> ! <xsd:attribute name="use-default-filters" type="xsd:boolean" default="true"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! Indicates whether automatic detection of classes annotated with @Component, @Repository, @Service, or @Controller ! should be enabled. Default is "true". ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:attribute> ! <xsd:attribute name="annotation-config" type="xsd:boolean" default="true"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! Indicates whether the implicit AutowiredAnnotationBeanPostProcessor and CommonAnnotationBeanPostProcessor should ! be enabled. Default is "true". ! ]]></xsd:documentation> ! </xsd:annotation> ! </xsd:attribute> ! <xsd:attribute name="name-generator" type="xsd:string"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ The fully-qualified classname of the BeanNameGenerator to be used for naming detected components. ! ]]></xsd:documentation> ! <xsd:appinfo> ! <tool:annotation> ! <tool:expected-type type="java.lang.Class"/> ! <tool:assignable-to type="org.springframework.beans.factory.support.BeanNameGenerator"/> ! </tool:annotation> ! </xsd:appinfo> ! </xsd:annotation> ! </xsd:attribute> ! <xsd:attribute name="scope-resolver" type="xsd:string"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! The fully-qualified class name of the ScopeMetadataResolver to be used for resolving the scope of detected components. ! ]]></xsd:documentation> ! <xsd:appinfo> ! <tool:annotation> ! <tool:expected-type type="java.lang.Class"/> ! <tool:assignable-to type="org.springframework.context.annotation.ScopeMetadataResolver"/> ! </tool:annotation> ! </xsd:appinfo> ! </xsd:annotation> ! </xsd:attribute> ! <xsd:attribute name="scoped-proxy"> ! <xsd:annotation> ! <xsd:documentation><![CDATA[ ! Indicates whether proxies should be generated for detected components, which may be necessary when using certain ! non-singleton scopes in a proxy-style fashion. Default is to generate no such proxies. ! ]]></xsd:documentation> ! </xsd:annotation> ! <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="no"/> |
From: Juergen H. <jho...@us...> - 2008-10-17 15:59:57
|
Update of /cvsroot/springframework/spring/lib/quartz In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16881/lib/quartz Added Files: quartz-all-1.6.1.jar Removed Files: quartz-all-1.6.1-RC3.jar Log Message: updated to Quartz 1.6.1 GA --- quartz-all-1.6.1-RC3.jar DELETED --- --- NEW FILE: quartz-all-1.6.1.jar --- (This appears to be a binary file; contents omitted.) |