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;
|
package org.baeldung.web;
|
||||||
|
|
||||||
public interface IBeanA {
|
public interface IServiceA {
|
||||||
//
|
//
|
||||||
}
|
}
|
24
spring-all/src/main/java/org/baeldung/web/ServiceA.java
Normal file
24
spring-all/src/main/java/org/baeldung/web/ServiceA.java
Normal file
@ -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;
|
package org.baeldung.web;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@Component
|
@Service
|
||||||
@Transactional
|
@Transactional
|
||||||
public class BeanB {
|
public class ServiceB {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BeanA beanA;
|
private IServiceA serviceA;
|
||||||
|
|
||||||
public BeanB() {
|
public ServiceB() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
public void testB() {
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
32
spring-all/src/main/java/org/baeldung/web/Setup.java
Normal file
32
spring-all/src/main/java/org/baeldung/web/Setup.java
Normal file
@ -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…
x
Reference in New Issue
Block a user