-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScopeAnnotation.java
More file actions
96 lines (72 loc) · 2.08 KB
/
ScopeAnnotation.java
File metadata and controls
96 lines (72 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.jspring6;
public class ScopeAnnotation {
public void ScopeAnnottionExample()
{
System.out.println("Scope Annotation Example in Java Based Config ");
}
}
/*
*
*
*
// prototype bean
// AppConfig File
@Bean
@Scope("prototype")
//@Bean(name = "comp1")
// @Bean(name={"comp1", "cpmp2","jp"})
public ConfigDesktop desktop() // Using the ConfigDesktop
// App.java File
{
ConfigDesktop dt2 = context.getBean(ConfigDesktop.class);
dt2.compile();
ConfigDesktop dt = context.getBean(ConfigDesktop.class);
dt.compile(); // here bothe bean are working with the same obj
// to get the different bean obj we have to use the @Scope anotation and prototype
*
*/
// use of the Scope Annotation
// package com.jspring6;
// import org.springframework.beans.factory.annotation.Qualifier;
// import org.springframework.context.annotation.Scope;
// import org.springframework.stereotype.Component;
// @Component
// // @primary
// @Scope("prototype")
// // @Qualifier("lap") to use the name as Bean for the autowire
// public class Desktop implements Computer {
// public Desktop()
// {
// System.out.println("Constructor ");
// }
// @Override
// public void compile(){
// System.out.println("Compiling in my Computer");
// }
// }
// Use of the Value Anotation
/*
*
*
@Component
public class AlienInterfaceConfig {
@Value("23")
private int age;
*/
// *
// // prototype bean
// // AppConfig File
// @Bean
// @Scope("prototype")
// //@Bean(name = "comp1")
// // @Bean(name={"comp1", "cpmp2","jp"})
// public ConfigDesktop desktop() // Using the ConfigDesktop
// // App.java File
// {
// ConfigDesktop dt2 = context.getBean(ConfigDesktop.class);
// dt2.compile();
// ConfigDesktop dt = context.getBean(ConfigDesktop.class);
// dt.compile(); // here bothe bean are working with the same obj
// // to get the different bean obj we have to use the @Scope anotation and prototype
// *
// */