<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=memelet" rel="nofollow">Barry Kaplan</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-1149?redirect=false" rel="nofollow">SPR-1149</a></strong> and commented</p>
<p dir="auto">FactoryBean's are excluded from implementing a whole host of post processor interfaces (due to the fact that getBeansOfType et all exclude FactoryBeans from their results). When building a set of spring beans for an existing product/library the use of FactoryBean is often required. Also it is often required to perform post processing for these library beans.</p>
<p dir="auto">A concrete example is drools-spring. The class WorkingMemoryFactoryBean constructs a drools WorkingMemory instance. This /must/ be done via FactoryBean due to restrictions on the drools api. Drools defines an interface WorkingMemoryListener. I would like for WorkingMemoryFactoryBean to declare a property 'autoAddListeners' which will scan the BeanFactory for instances of WorkingMemoryListener and add it the WorkingMemory created by the FactoryBean.</p>
<p dir="auto">The above is not possible with 1.2.2 or 1.2.3-dev, because WorkingMemoryFactoryBean cannot implement any post processor interfaces (not BeanPostProcessor, BeanFactoryPostProcessor, nor ApplicationListener). This requires a seperate bean to be defined in the context just to search for WorkingMemory beans. This is noise. The cleanest and most encapsulated place for this behavior is in the WorkingMemoryFactoryBean.</p>
<p dir="auto">There are lots of other examples. I having a similar troubles with my spring integration for the quickfixj project.</p>
<p dir="auto">I can't see any technical reason why FactoryBean's need to be excluded in this way. Maybe it was because at some in the past creating the FactoryBean instance always trigger the call of getObject. But this does not seem to be the case anywmore. Is there some reason I am not aware of?</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 1.2.2</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398058638" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/5847" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/5847/hovercard" href="https://github.com/spring-projects/spring-framework/issues/5847">#5847</a> Allow for getBeanNameOfType to return FacotryBeans (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=jbrisbin" rel="nofollow">Jon Brisbin</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-2835?redirect=false" rel="nofollow">SPR-2835</a></strong> and commented</p>
<p dir="auto">Whenever I use the Spring classes for JDBC access to an AS400 stored procedure, the call to getString() generates a "Function sequence error".</p>
<p dir="auto">I have a CallableStatementCreator that does a prepareCall() and sets the parameters, including an output parameter. I also have a CallableStatementCallback that handles getting the value of the output parameter, but no matter what I've tried, I keep getting a "Function sequence error" when I do a getString() on the callable statement, after the execute.</p>
<p dir="auto">This problem does not exist when called through normal JDBC, only when using Spring callbacks and JdbcTemplate to call the output parameters from an AS400 stored procedure call.</p>
<p dir="auto">Java test class to duplicate the problem:</p>
<p dir="auto">import java.io.PrintWriter;<br>
import java.sql.CallableStatement;<br>
import java.sql.Connection;<br>
import java.sql.DriverManager;<br>
import java.sql.ParameterMetaData;<br>
import java.sql.ResultSet;<br>
import java.sql.SQLException;<br>
import java.sql.Types;</p>
<p dir="auto">import javax.sql.DataSource;</p>
<p dir="auto">import org.dom4j.Document;<br>
import org.dom4j.DocumentFactory;<br>
import org.dom4j.Element;<br>
import org.springframework.dao.DataAccessException;<br>
import org.springframework.jdbc.core.CallableStatementCal lback;<br>
import org.springframework.jdbc.core.CallableStatementCre ator;<br>
import org.springframework.jdbc.core.JdbcTemplate;</p>
<p dir="auto">public class Main<br>
{</p>
<p dir="auto">/**</p>
<ul dir="auto">
<li><code class="notranslate">@param</code> args<br>
*/<br>
public static void main( String[] arg )<br>
{<br>
try {<br>
Class.forName( "com.ibm.as400.access.AS400JDBCDriver" );<br>
final Connection conn = DriverManager.getConnection( "jdbc:as400://HOSTNAME", "USER", "PASSWORD" );<br>
JdbcTemplate jdbcTmpl = new JdbcTemplate( new DataSource()<br>
{</li>
</ul>
<p dir="auto">public Connection getConnection() throws SQLException<br>
{<br>
return conn;<br>
}</p>
<p dir="auto">public Connection getConnection( String username, String password ) throws SQLException<br>
{<br>
return conn;<br>
}</p>
<p dir="auto">public int getLoginTimeout() throws SQLException<br>
{<br>
return 0;<br>
}</p>
<p dir="auto">public PrintWriter getLogWriter() throws SQLException<br>
{<br>
return new PrintWriter( System.out );<br>
}</p>
<p dir="auto">public void setLoginTimeout( int seconds ) throws SQLException<br>
{}</p>
<p dir="auto">public void setLogWriter( PrintWriter out ) throws SQLException<br>
{}</p>
<p dir="auto">} );</p>
<p dir="auto">CallableStatementCreator csc = new CallableStatementCreator()<br>
{</p>
<p dir="auto">public CallableStatement createCallableStatement( Connection conn ) throws SQLException<br>
{<br>
CallableStatement cs = conn.prepareCall( "call weblib.sptest(?,?)",<br>
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );<br>
cs.setString( 1, "TEST" );<br>
cs.registerOutParameter( 2, Types.VARCHAR );<br>
return cs;<br>
}</p>
<p dir="auto">};<br>
CallableStatementCallback csCallback = new CallableStatementCallback()<br>
{</p>
<p dir="auto">public Object doInCallableStatement( CallableStatement cs ) throws SQLException, DataAccessException<br>
{<br>
Document d = DocumentFactory.getInstance().createDocument();<br>
Element root = d.addElement( "root" );<br>
ParameterMetaData pm = cs.getParameterMetaData();<br>
for ( int j = 1; j &lt;= pm.getParameterCount(); j++ ) {<br>
System.out.println( "Parameter #" + String.valueOf( j ) );<br>
System.out.println( "Type: " + pm.getParameterTypeName( j ) );<br>
if ( ( pm.getParameterMode( j ) == ParameterMetaData.parameterModeOut )<br>
|| ( pm.getParameterMode( j ) == ParameterMetaData.parameterModeInOut ) ) {<br>
System.out.println( "Value=" + cs.getString( j ) );<br>
}<br>
}<br>
return root;<br>
}</p>
<p dir="auto">};</p>
<p dir="auto">jdbcTmpl.execute( csc, csCallback );</p>
<p dir="auto">try {<br>
conn.close();<br>
} catch ( Throwable t ) {}<br>
} catch ( Throwable t ) {<br>
t.printStackTrace();<br>
}<br>
}</p>
<p dir="auto">static void p( String msg )<br>
{<br>
System.out.println( msg );<br>
}</p>
<p dir="auto">}</p>
<p dir="auto">SQL definition on the 400:</p>
<p dir="auto">DROP PROCEDURE weblib/sptest;<br>
CREATE PROCEDURE weblib/sptest<br>
(IN input char(10),<br>
OUT output CHAR(10))<br>
LANGUAGE RPGLE<br>
EXTERNAL NAME WEBLIB/WB0011<br>
PARAMETER STYLE GENERAL;</p>
<p dir="auto">RPG code:</p>
<p dir="auto">C *ENTRY PLIST<br>
C PARM IN 10<br>
C PARM RTN 10<br>
C*<br>
C EVAL RTN = 'TEST'<br>
C*<br>
C* END OF PROGRAM<br>
C SETON LR<br>
C RETURN</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.0 final</p>