mirror of
https://github.com/OtusTeam/Spring.git
synced 2026-05-30 10:50:42 +00:00
2023-01 spring-06-bean-scopes-and-lifecycle updated
This commit is contained in:
+7
-5
@@ -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;
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@ package ru.otus.example.beansscopesdemo.services;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service("PrototypeGreetingService")
|
||||
@Service("prototypeGreetingService")
|
||||
public class PrototypeGreetingServiceImpl extends AbstractGreetingServiceImpl {
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@ package ru.otus.example.beansscopesdemo.services;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service("RequestGreetingService")
|
||||
@Service("requestGreetingService")
|
||||
public class RequestGreetingServiceImpl extends AbstractGreetingServiceImpl {
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@ package ru.otus.example.beansscopesdemo.services;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service("SessionGreetingService")
|
||||
@Service("sessionGreetingService")
|
||||
public class SessionGreetingServiceImpl extends AbstractGreetingServiceImpl {
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@ package ru.otus.example.beansscopesdemo.services;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service("SingletonGreetingService")
|
||||
@Service("singletonGreetingService")
|
||||
public class SingletonGreetingServiceImpl extends AbstractGreetingServiceImpl {
|
||||
}
|
||||
|
||||
+7
-5
@@ -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;
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user