2023-01 spring-06-bean-scopes-and-lifecycle updated

This commit is contained in:
stvort
2023-02-15 19:19:24 +04:00
parent cfab925004
commit 699bf2e380
10 changed files with 22 additions and 18 deletions
@@ -14,11 +14,13 @@ public class GreetingController {
private final GreetingService sessionGreetingService;
private final GreetingService requestGreetingService;
public GreetingController(@Qualifier("SingletonGreetingService") GreetingService singletonGreetingService,
@Qualifier("PrototypeGreetingService")GreetingService prototypeGreetingService1,
@Qualifier("PrototypeGreetingService")GreetingService prototypeGreetingService2,
@Qualifier("SessionGreetingService")GreetingService sessionGreetingService,
@Qualifier("RequestGreetingService")GreetingService requestGreetingService
public GreetingController(GreetingService singletonGreetingService,
@Qualifier("prototypeGreetingService")
GreetingService prototypeGreetingService1,
@Qualifier("prototypeGreetingService")
GreetingService prototypeGreetingService2,
GreetingService sessionGreetingService,
GreetingService requestGreetingService
) {
this.singletonGreetingService = singletonGreetingService;
this.prototypeGreetingService1 = prototypeGreetingService1;
@@ -2,6 +2,6 @@ package ru.otus.example.beansscopesdemo.services;
import org.springframework.stereotype.Service;
@Service("PrototypeGreetingService")
@Service("prototypeGreetingService")
public class PrototypeGreetingServiceImpl extends AbstractGreetingServiceImpl {
}
@@ -2,6 +2,6 @@ package ru.otus.example.beansscopesdemo.services;
import org.springframework.stereotype.Service;
@Service("RequestGreetingService")
@Service("requestGreetingService")
public class RequestGreetingServiceImpl extends AbstractGreetingServiceImpl {
}
@@ -2,6 +2,6 @@ package ru.otus.example.beansscopesdemo.services;
import org.springframework.stereotype.Service;
@Service("SessionGreetingService")
@Service("sessionGreetingService")
public class SessionGreetingServiceImpl extends AbstractGreetingServiceImpl {
}
@@ -2,6 +2,6 @@ package ru.otus.example.beansscopesdemo.services;
import org.springframework.stereotype.Service;
@Service("SingletonGreetingService")
@Service("singletonGreetingService")
public class SingletonGreetingServiceImpl extends AbstractGreetingServiceImpl {
}
@@ -14,11 +14,13 @@ public class GreetingController {
private final GreetingService sessionGreetingService;
private final GreetingService requestGreetingService;
public GreetingController(@Qualifier("SingletonGreetingService") GreetingService singletonGreetingService,
@Qualifier("PrototypeGreetingService")GreetingService prototypeGreetingService1,
@Qualifier("PrototypeGreetingService")GreetingService prototypeGreetingService2,
@Qualifier("SessionGreetingService")GreetingService sessionGreetingService,
@Qualifier("RequestGreetingService")GreetingService requestGreetingService
public GreetingController(GreetingService singletonGreetingService,
@Qualifier("prototypeGreetingService")
GreetingService prototypeGreetingService1,
@Qualifier("prototypeGreetingService")
GreetingService prototypeGreetingService2,
GreetingService sessionGreetingService,
GreetingService requestGreetingService
) {
this.singletonGreetingService = singletonGreetingService;
this.prototypeGreetingService1 = prototypeGreetingService1;
@@ -5,6 +5,6 @@ import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Service;
@Scope(scopeName = "prototype")
@Service("PrototypeGreetingService")
@Service("prototypeGreetingService")
public class PrototypeGreetingServiceImpl extends AbstractGreetingServiceImpl {
}
@@ -6,6 +6,6 @@ import org.springframework.stereotype.Service;
import org.springframework.web.context.WebApplicationContext;
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
@Service("RequestGreetingService")
@Service("requestGreetingService")
public class RequestGreetingServiceImpl extends AbstractGreetingServiceImpl {
}
@@ -6,6 +6,6 @@ import org.springframework.stereotype.Service;
import org.springframework.web.context.WebApplicationContext;
@Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)
@Service("SessionGreetingService")
@Service("sessionGreetingService")
public class SessionGreetingServiceImpl extends AbstractGreetingServiceImpl {
}
@@ -4,6 +4,6 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
@Scope("singleton")
@Service("SingletonGreetingService")
@Service("singletonGreetingService")
public class SingletonGreetingServiceImpl extends AbstractGreetingServiceImpl {
}