One thing to ask yourself would be: how would you unit test this?
Having dependencies like you mention sounds like it would make it difficult to do so. Although unit testing isn't the only consideration when creating an architecture. Spring tends to strive for statically defined simple dependency relationships between its objects, partially to improve testability.
However your problem is solvable:
Code:
interface daoCallbackB {
public void callback1(Object someargument);
}
interface daoB {
public void methodB1(daoCallbackB cb);
}
interface daoA {
public void method1();
public void method2();
}
public class daoAImpl implements daoCallbackB, daoA {
public void method1() { do stuff; }
public void method2() { do stuff; }
public void callback1(Object someargument) {
do stuff on someargument;
}
}
public class daoBImpl implements daoB {
public void methodB1(daoCallbackB cb) {
// daoB stuff
Object someargument;
cb.callback1(someargument);
// more daoB stuff
}
public class someService {
setDaoA(daoA a) { ... }
setDaoB(daoB b) { ... }
doSomeService() {
b.methodB1(a);
}
}
Basically I'm using a callback to do the method injection you are looking for.