bean work
This commit is contained in:
parent
343a743229
commit
f5990cb42b
|
@ -1,14 +0,0 @@
|
|||
package org.baeldung.web;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Component
|
||||
@Transactional
|
||||
public class BeanA {
|
||||
|
||||
public BeanA() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
package org.baeldung.web;
|
||||
|
||||
public interface IBeanA {
|
||||
public interface IServiceA {
|
||||
//
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.baeldung.web;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class ServiceA implements IServiceA {
|
||||
|
||||
@Autowired
|
||||
private ServiceB serviceB;
|
||||
|
||||
public ServiceA() {
|
||||
super();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public void testA() {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,18 +1,24 @@
|
|||
package org.baeldung.web;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Component
|
||||
@Service
|
||||
@Transactional
|
||||
public class BeanB {
|
||||
public class ServiceB {
|
||||
|
||||
@Autowired
|
||||
private BeanA beanA;
|
||||
private IServiceA serviceA;
|
||||
|
||||
public BeanB() {
|
||||
public ServiceB() {
|
||||
super();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public void testB() {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package org.baeldung.web;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Setup implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
private boolean setupDone;
|
||||
|
||||
@Autowired
|
||||
IServiceA serviceA;
|
||||
|
||||
@Autowired
|
||||
ServiceB serviceB;
|
||||
|
||||
public Setup() {
|
||||
super();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@Override
|
||||
public final void onApplicationEvent(final ContextRefreshedEvent event) {
|
||||
if (!setupDone) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue