Created
July 9, 2015 13:36
-
-
Save Kotlin-Native/cdfe04ccc481576c880b to your computer and use it in GitHub Desktop.
SpringBean
This file contains hidden or 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
| public class SpringBean implements Bean<Object> { | |
| private String beanName; | |
| private Class<?> beanClass; | |
| private Set<Type> beanTypes; | |
| private Set<Annotation> qualifiers; | |
| private Set<Class<? extends Annotation>> stereotypes; | |
| private ConfigurableBeanFactory beanFactory; | |
| public SpringBean(String beanName, | |
| Class<?> beanClass, | |
| Set<Type> beanTypes, | |
| Set<Annotation> qualifiers, | |
| Set<Class<? extends Annotation>> stereotypes, | |
| ConfigurableBeanFactory beanFactory) { | |
| this.beanName = beanName; | |
| this.beanClass = beanClass; | |
| this.beanTypes = Collections.unmodifiableSet(beanTypes); | |
| this.qualifiers = Collections.unmodifiableSet(qualifiers); | |
| this.stereotypes = Collections.unmodifiableSet(stereotypes); | |
| this.beanFactory = beanFactory; | |
| } | |
| public String getName() { | |
| return beanName; | |
| } | |
| public Class<?> getBeanClass() { | |
| return beanClass; | |
| } | |
| public Set<Type> getTypes() { | |
| return beanTypes; | |
| } | |
| public Set<Annotation> getQualifiers() { | |
| return qualifiers; | |
| } | |
| public Set<Class<? extends Annotation>> getStereotypes() { | |
| return stereotypes; | |
| } | |
| public Class<? extends Annotation> getScope() { | |
| return Dependent.class; | |
| } | |
| public Set<InjectionPoint> getInjectionPoints() { | |
| return Collections.emptySet(); | |
| } | |
| public boolean isAlternative() { | |
| return false; | |
| } | |
| public boolean isNullable() { | |
| return true; | |
| } | |
| public Object create(CreationalContext<Object> creationalContext) { | |
| return beanFactory.getBean(beanName); | |
| } | |
| public void destroy(Object beanInstance, | |
| CreationalContext<Object> creationalContext) { | |
| beanFactory.destroyBean(beanName, beanInstance); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment