Resolution: None. I no longer extend the original parent.
Original:
Is there a way to annotate the inherited set method final? I am extending a class that has a set finalthat I would like @Autowirewith Spring. The parent class is from the library and cannot be changed.
The workaround I found is to write a proxy method, but this seems like more work than necessary.
public abstract class SqlMapClientDaoSupport ... {
public final void setSqlMapClient(SqlMapClient smc) {
...
}
}
@Component
public class AccountDao extends SqlMapClientDaoSupport {
@Autowire
public final void setSqlMapClientWorkaround(SqlMapClient smc) {
super.setSqlMapClient(smc);
}
}
1:. , :
DAO Ibatis/Spring
. DAO
, bean.
, applicationContext.xml.
<bean id="accountDAO"
class="com.example.proj.dao.h2.AccountDAOImpl"
p:sqlMapClient-ref="sqlMapClient" />
<bean id="companyDAO"
class="com.example.proj.dao.h2.CompanyDAOImpl"
p:sqlMapClient-ref="sqlMapClient" />
DAO
, / botch.
<context:component-scan base-package="com.example.proj.dao.h2" />
,
/, . ,
- .
2: SqlMapClientDaoSupport, AccountDao - POJO, , . @Autowire .