-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
293 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...x-bean/src/main/java/com/tvd12/ezyfox/bean/impl/EzyConfigurationFieldSingletonLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.tvd12.ezyfox.bean.impl; | ||
|
||
import com.tvd12.ezyfox.bean.EzyBeanContext; | ||
import com.tvd12.ezyfox.reflect.EzyField; | ||
import com.tvd12.ezyfox.reflect.EzyMethod; | ||
|
||
import java.util.Map; | ||
|
||
public class EzyConfigurationFieldSingletonLoader | ||
extends EzyByFieldSingletonLoader { | ||
|
||
public EzyConfigurationFieldSingletonLoader( | ||
String beanName, | ||
EzyField field, | ||
Object configurator, | ||
Map<Class<?>, EzyMethod> methodsByType | ||
) { | ||
super( | ||
beanName, | ||
field, | ||
configurator, | ||
methodsByType | ||
); | ||
} | ||
|
||
@SuppressWarnings("rawtypes") | ||
@Override | ||
protected Object getOrCreateSingleton( | ||
EzyBeanContext context, | ||
String name, | ||
Class[] parameterTypes | ||
) { | ||
Object singleton = newSingletonByConstructor( | ||
context, | ||
parameterTypes | ||
); | ||
logger.debug( | ||
"add singleton with name {} of {}, object = {}", | ||
name, | ||
singleton.getClass(), | ||
singleton | ||
); | ||
return singleton; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...-bean/src/main/java/com/tvd12/ezyfox/bean/impl/EzyConfigurationMethodSingletonLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.tvd12.ezyfox.bean.impl; | ||
|
||
import com.tvd12.ezyfox.bean.EzyBeanContext; | ||
import com.tvd12.ezyfox.reflect.EzyMethod; | ||
|
||
import java.util.Map; | ||
|
||
public class EzyConfigurationMethodSingletonLoader | ||
extends EzyByMethodSingletonLoader { | ||
|
||
public EzyConfigurationMethodSingletonLoader( | ||
String beanName, | ||
EzyMethod method, | ||
Object configurator, | ||
Map<Class<?>, EzyMethod> methodsByType | ||
) { | ||
super( | ||
beanName, | ||
method, | ||
configurator, | ||
methodsByType | ||
); | ||
} | ||
|
||
@SuppressWarnings("rawtypes") | ||
@Override | ||
protected Object getOrCreateSingleton( | ||
EzyBeanContext context, | ||
String name, | ||
Class[] parameterTypes | ||
) { | ||
Object singleton = newSingletonByConstructor( | ||
context, | ||
parameterTypes | ||
); | ||
logger.debug( | ||
"add singleton with name {} of {}, object = {}", | ||
name, | ||
singleton.getClass(), | ||
singleton | ||
); | ||
return singleton; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ean/src/test/java/com/tvd12/ezyfox/bean/v129/testing/V129DeclareTwoBeansSameTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.tvd12.ezyfox.bean.v129.testing; | ||
|
||
import com.tvd12.ezyfox.bean.EzyBeanContext; | ||
import com.tvd12.test.assertion.Asserts; | ||
import org.testng.annotations.Test; | ||
|
||
public class V129DeclareTwoBeansSameTypeTest { | ||
|
||
@Test | ||
public void test() { | ||
// given | ||
EzyBeanContext beanContext = EzyBeanContext.builder() | ||
.scan("com.tvd12.ezyfox.bean.v129.testing.config") | ||
.build(); | ||
|
||
// when | ||
// then | ||
Asserts.assertEquals( | ||
beanContext.getBean("hello", String.class), | ||
"hello" | ||
); | ||
Asserts.assertEquals( | ||
beanContext.getBean("world", String.class), | ||
"world" | ||
); | ||
Asserts.assertEquals( | ||
beanContext.getBean("foo", String.class), | ||
"foo" | ||
); | ||
Asserts.assertEquals( | ||
beanContext.getBean("bar", String.class), | ||
"bar" | ||
); | ||
} | ||
} |
Oops, something went wrong.