bean work

This commit is contained in:
eugenp 2013-05-25 01:14:38 +03:00
parent 343a743229
commit f5990cb42b
5 changed files with 68 additions and 20 deletions

View File

@ -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();
}
}

View File

@ -1,5 +1,5 @@
package org.baeldung.web;
public interface IBeanA {
public interface IServiceA {
//
}

View 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();
}
}

View File

@ -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();
}
}

View 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) {
//
}
}
}