private void serviceIdContextInit() { namedContextFactory.destroy(); // initializer each spring context for service id MigrateProxyManager.getServicesId().forEach(serviceId -> namedContextFactory .getInstance(serviceId, ILoadBalancer.class)); }
@SuppressWarnings("unchecked") private ObjectProvider<T> delegate() { if (this.provider == null) { provider = this.clientFactory.getProvider(name, type); } return provider; } }
public <T> T getInstance(String name, Class<T> type) { AnnotationConfigApplicationContext context = getContext(name); if (BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context, type).length > 0) { return context.getBean(type); } return null; }
public <T> T getInstance(String name, Class<?> clazz, Class<?>... generics) { ResolvableType type = ResolvableType.forClassWithGenerics(clazz, generics); return getInstance(name, type); }
protected AnnotationConfigApplicationContext getContext(String name) { if (!this.contexts.containsKey(name)) { synchronized (this.contexts) { if (!this.contexts.containsKey(name)) { this.contexts.put(name, createContext(name)); } } } return this.contexts.get(name); }
protected AnnotationConfigApplicationContext createContext(String name) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); if (this.configurations.containsKey(name)) { for (Class<?> configuration : this.configurations.get(name) .getConfiguration()) { context.register(configuration); } } for (Map.Entry<String, C> entry : this.configurations.entrySet()) { if (entry.getKey().startsWith("default.")) { for (Class<?> configuration : entry.getValue().getConfiguration()) { context.register(configuration); } } } context.register(PropertyPlaceholderAutoConfiguration.class, this.defaultConfigType); context.getEnvironment().getPropertySources().addFirst(new MapPropertySource( this.propertySourceName, Collections.<String, Object> singletonMap(this.propertyName, name))); if (this.parent != null) { // Uses Environment from parent as well as beans context.setParent(this.parent); } context.setDisplayName(generateDisplayName(name)); context.refresh(); return context; }
public <T> ObjectProvider<T> getProvider(String name, Class<T> type) { AnnotationConfigApplicationContext context = getContext(name); return context.getBeanProvider(type); }
public <T> T getInstance(String name, Class<?> clazz, Class<?>... generics) { ResolvableType type = ResolvableType.forClassWithGenerics(clazz, generics); return getInstance(name, type); }
protected AnnotationConfigApplicationContext getContext(String name) { if (!this.contexts.containsKey(name)) { synchronized (this.contexts) { if (!this.contexts.containsKey(name)) { this.contexts.put(name, createContext(name)); } } } return this.contexts.get(name); }
protected AnnotationConfigApplicationContext createContext(String name) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); if (this.configurations.containsKey(name)) { for (Class<?> configuration : this.configurations.get(name) .getConfiguration()) { context.register(configuration); } } for (Map.Entry<String, C> entry : this.configurations.entrySet()) { if (entry.getKey().startsWith("default.")) { for (Class<?> configuration : entry.getValue().getConfiguration()) { context.register(configuration); } } } context.register(PropertyPlaceholderAutoConfiguration.class, this.defaultConfigType); context.getEnvironment().getPropertySources().addFirst(new MapPropertySource( this.propertySourceName, Collections.<String, Object> singletonMap(this.propertyName, name))); if (this.parent != null) { // Uses Environment from parent as well as beans context.setParent(this.parent); } context.setDisplayName(generateDisplayName(name)); context.refresh(); return context; }
@SuppressWarnings("unchecked") public <T> T getInstance(String name, ResolvableType type) { AnnotationConfigApplicationContext context = getContext(name); String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context, type); if (beanNames.length > 0) { for (String beanName : beanNames) { if (context.isTypeMatch(beanName, type)) { return (T) context.getBean(beanName); } } } return null; }
@Override public <C> C getInstance(String name, Class<C> type) { C instance = super.getInstance(name, type); if (instance != null) { return instance; } IClientConfig config = getInstance(name, IClientConfig.class); return instantiateWithConfig(getContext(name), type, config); }
@SuppressWarnings("unchecked") private ObjectProvider<T> delegate() { if (this.provider == null) { provider = this.clientFactory.getProvider(name, type); } return provider; } }
public <T> Map<String, T> getInstances(String name, Class<T> type) { AnnotationConfigApplicationContext context = getContext(name); if (BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context, type).length > 0) { return BeanFactoryUtils.beansOfTypeIncludingAncestors(context, type); } return null; }
@Override protected AnnotationConfigApplicationContext getContext(String name) { return super.getContext(name); }
public <T> T getInstance(String name, Class<T> type) { AnnotationConfigApplicationContext context = getContext(name); if (BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context, type).length > 0) { return context.getBean(type); } return null; }
public <T> ObjectProvider<T> getProvider(String name, Class<T> type) { AnnotationConfigApplicationContext context = getContext(name); return context.getBeanProvider(type); }
public <T> Map<String, T> getInstances(String name, Class<T> type) { AnnotationConfigApplicationContext context = getContext(name); if (BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context, type).length > 0) { return BeanFactoryUtils.beansOfTypeIncludingAncestors(context, type); } return null; }
@SuppressWarnings("unchecked") public <T> T getInstance(String name, ResolvableType type) { AnnotationConfigApplicationContext context = getContext(name); String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context, type); if (beanNames.length > 0) { for (String beanName : beanNames) { if (context.isTypeMatch(beanName, type)) { return (T) context.getBean(beanName); } } } return null; }