private void initProviderBean(String beanName, Object bean) throws Exception { Service service = this.applicationContext.findAnnotationOnBean(beanName, Service.class); ServiceBean<Object> serviceConfig = new ServiceBean<Object>(service); if ((service.interfaceClass() == null || service.interfaceClass() == void.class) && (service.interfaceName() == null || "".equals(service.interfaceName()))) { Class<?>[] interfaces = bean.getClass().getInterfaces(); if (interfaces.length > 0) { serviceConfig.setInterface(interfaces[0]); serviceConfig.setApplication(this.parseApplication(application, this.properties, environment, beanName, "application", application)); String module = service.module(); serviceConfig.setModule( this.parseModule(module, this.properties, environment, beanName, "module", module)); String[] registries = service.registry(); serviceConfig.setRegistries( this.parseRegistries(registries, this.properties, environment, beanName, "registry")); String[] protocols = service.protocol(); serviceConfig.setProtocols( this.parseProtocols(protocols, this.properties, environment, beanName, "registry")); String monitor = service.monitor(); serviceConfig.setMonitor( this.parseMonitor(monitor, this.properties, environment, beanName, "monitor", monitor)); String provider = service.provider(); serviceConfig.setProvider( this.parseProvider(provider, this.properties, environment, beanName, "provider", provider)); serviceConfig.setApplicationContext(this.applicationContext); serviceConfig.afterPropertiesSet(); serviceConfig.setRef(bean);
@Override @SuppressWarnings({"unchecked", "deprecation"}) public void afterPropertiesSet() throws Exception { if (getProvider() == null) { Map<String, ProviderConfig> providerConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProviderConfig.class, false, false); if (providerConfigMap != null && providerConfigMap.size() > 0) { setProviders(providerConfigs); setProvider(providerConfig); if (getApplication() == null && (getProvider() == null || getProvider().getApplication() == null)) { Map<String, ApplicationConfig> applicationConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ApplicationConfig.class, false, false); if (applicationConfigMap != null && applicationConfigMap.size() > 0) { setApplication(applicationConfig); if (getModule() == null && (getProvider() == null || getProvider().getModule() == null)) { Map<String, ModuleConfig> moduleConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ModuleConfig.class, false, false); if (moduleConfigMap != null && moduleConfigMap.size() > 0) { setModule(moduleConfig); if ((getRegistries() == null || getRegistries().isEmpty()) && (getProvider() == null || getProvider().getRegistries() == null || getProvider().getRegistries().isEmpty()) && (getApplication() == null || getApplication().getRegistries() == null || getApplication().getRegistries().isEmpty())) { Map<String, RegistryConfig> registryConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RegistryConfig.class, false, false); if (registryConfigMap != null && registryConfigMap.size() > 0) {
@Override public void onApplicationEvent(ContextRefreshedEvent event) { if (isDelay() && !isExported() && !isUnexported()) { if (logger.isInfoEnabled()) { logger.info("The service ready on spring started. service: " + getInterface()); } export(); } }
@SuppressWarnings({ "unchecked", "deprecation" }) public void afterPropertiesSet() throws Exception { if (getProvider() == null) { Map<String, ProviderConfig> providerConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProviderConfig.class, false, false); if (providerConfigMap != null && providerConfigMap.size() > 0) { setProviders(providerConfigs); setProvider(providerConfig); if (getApplication() == null && (getProvider() == null || getProvider().getApplication() == null)) { Map<String, ApplicationConfig> applicationConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ApplicationConfig.class, false, false); if (applicationConfigMap != null && applicationConfigMap.size() > 0) { setApplication(applicationConfig); if (getModule() == null && (getProvider() == null || getProvider().getModule() == null)) { Map<String, ModuleConfig> moduleConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ModuleConfig.class, false, false); if (moduleConfigMap != null && moduleConfigMap.size() > 0) { setModule(moduleConfig); if ((getRegistries() == null || getRegistries().size() == 0) && (getProvider() == null || getProvider().getRegistries() == null || getProvider().getRegistries().size() == 0) && (getApplication() == null || getApplication().getRegistries() == null || getApplication().getRegistries().size() == 0)) { Map<String, RegistryConfig> registryConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RegistryConfig.class, false, false); if (registryConfigMap != null && registryConfigMap.size() > 0) {
public void onApplicationEvent(ApplicationEvent event) { if (ContextRefreshedEvent.class.getName().equals(event.getClass().getName())) { if (isDelay() && ! isExported() && ! isUnexported()) { if (logger.isInfoEnabled()) { logger.info("The service ready on spring started. service: " + getInterface()); } export(); } } }
ServiceBean<Object> serviceConfig = new ServiceBean<Object>(service); serviceConfig.setRef(bean); if (void.class.equals(service.interfaceClass()) && "".equals(service.interfaceName())) { if (bean.getClass().getInterfaces().length > 0) { serviceConfig.setInterface(bean.getClass().getInterfaces()[0]); } else { throw new IllegalStateException("Failed to export remote service class " + bean.getClass().getName() + ", cause: The @Service undefined interfaceClass or interfaceName, and the service class unimplemented any interfaces."); serviceConfig.setApplicationContext(applicationContext); if (service.registry().length > 0) { List<RegistryConfig> registryConfigs = new ArrayList<RegistryConfig>(); serviceConfig.setRegistries(registryConfigs); serviceConfig.setProvider(applicationContext.getBean(service.provider(), ProviderConfig.class)); serviceConfig.setMonitor(applicationContext.getBean(service.monitor(), MonitorConfig.class)); serviceConfig.setApplication(applicationContext.getBean(service.application(), ApplicationConfig.class)); serviceConfig.setModule(applicationContext.getBean(service.module(), ModuleConfig.class)); serviceConfig.setProvider(applicationContext.getBean(service.provider(), ProviderConfig.class)); serviceConfig.setProtocols(protocolConfigs); serviceConfig.afterPropertiesSet(); } catch (RuntimeException e) {
@SuppressWarnings({ "unchecked", "deprecation" }) public void afterPropertiesSet() throws Exception { if (getProvider() == null) { Map<String, ProviderConfig> providerConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ProviderConfig.class, false, false); if (providerConfigMap != null && providerConfigMap.size() > 0) { setProviders(providerConfigs); setProvider(providerConfig); if (getApplication() == null && (getProvider() == null || getProvider().getApplication() == null)) { Map<String, ApplicationConfig> applicationConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ApplicationConfig.class, false, false); if (applicationConfigMap != null && applicationConfigMap.size() > 0) { setApplication(applicationConfig); if (getModule() == null && (getProvider() == null || getProvider().getModule() == null)) { Map<String, ModuleConfig> moduleConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, ModuleConfig.class, false, false); if (moduleConfigMap != null && moduleConfigMap.size() > 0) { setModule(moduleConfig); if ((getRegistries() == null || getRegistries().size() == 0) && (getProvider() == null || getProvider().getRegistries() == null || getProvider().getRegistries().size() == 0) && (getApplication() == null || getApplication().getRegistries() == null || getApplication().getRegistries().size() == 0)) { Map<String, RegistryConfig> registryConfigMap = applicationContext == null ? null : BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, RegistryConfig.class, false, false); if (registryConfigMap != null && registryConfigMap.size() > 0) {
public void onApplicationEvent(ApplicationEvent event) { if (ContextRefreshedEvent.class.getName().equals(event.getClass().getName())) { if (isDelay() && ! isExported() && ! isUnexported()) { if (logger.isInfoEnabled()) { logger.info("The service ready on spring started. service: " + getInterface()); } export(); } } }
ServiceBean<Object> serviceConfig = new ServiceBean<Object>(service); if (void.class.equals(service.interfaceClass()) && "".equals(service.interfaceName())) { if (bean.getClass().getInterfaces().length > 0) { serviceConfig.setInterface(bean.getClass().getInterfaces()[0]); } else { throw new IllegalStateException("Failed to export remote service class " + bean.getClass().getName() + ", cause: The @Service undefined interfaceClass or interfaceName, and the service class unimplemented any interfaces."); serviceConfig.setApplicationContext(applicationContext); if (service.registry() != null && service.registry().length > 0) { List<RegistryConfig> registryConfigs = new ArrayList<RegistryConfig>(); serviceConfig.setRegistries(registryConfigs); serviceConfig.setProvider(applicationContext.getBean(service.provider(), ProviderConfig.class)); serviceConfig.setMonitor(applicationContext.getBean(service.monitor(), MonitorConfig.class)); serviceConfig.setApplication(applicationContext.getBean(service.application(), ApplicationConfig.class)); serviceConfig.setModule(applicationContext.getBean(service.module(), ModuleConfig.class)); serviceConfig.setProvider(applicationContext.getBean(service.provider(), ProviderConfig.class)); } else { serviceConfig.setProtocols(protocolConfigs); serviceConfig.afterPropertiesSet(); } catch (RuntimeException e) {
ServiceBean<Object> serviceConfig = new ServiceBean<Object>(service); if (void.class.equals(service.interfaceClass()) && "".equals(service.interfaceName())) { if (clazz.getInterfaces().length > 0) { serviceConfig.setInterface(clazz.getInterfaces()[0]); } else { throw new IllegalStateException("Failed to export remote service class " + clazz.getName() + ", cause: The @Service undefined interfaceClass or interfaceName, and the service class unimplemented any interfaces."); serviceConfig.setApplicationContext(applicationContext); if (service.registry() != null && service.registry().length > 0) { List<RegistryConfig> registryConfigs = new ArrayList<RegistryConfig>(); serviceConfig.setRegistries(registryConfigs); serviceConfig.setProvider((ProviderConfig)applicationContext.getBean(service.provider(),ProviderConfig.class)); serviceConfig.setMonitor((MonitorConfig)applicationContext.getBean(service.monitor(), MonitorConfig.class)); serviceConfig.setApplication((ApplicationConfig)applicationContext.getBean(service.application(), ApplicationConfig.class)); serviceConfig.setModule((ModuleConfig)applicationContext.getBean(service.module(), ModuleConfig.class)); serviceConfig.setProvider((ProviderConfig)applicationContext.getBean(service.provider(), ProviderConfig.class)); } else { serviceConfig.setProtocols(protocolConfigs); serviceConfig.afterPropertiesSet(); } catch (RuntimeException e) {
ServiceBean<Object> serviceConfig = new ServiceBean<Object>(service); if (void.class.equals(service.interfaceClass()) && "".equals(service.interfaceName())) { if (clazz.getInterfaces().length > 0) { serviceConfig.setInterface(clazz.getInterfaces()[0]); } else { throw new IllegalStateException("Failed to export remote service class " + clazz.getName() + ", cause: The @Service undefined interfaceClass or interfaceName, and the service class unimplemented any interfaces."); serviceConfig.setApplicationContext(applicationContext); if (service.registry() != null && service.registry().length > 0) { List<RegistryConfig> registryConfigs = new ArrayList<RegistryConfig>(); serviceConfig.setRegistries(registryConfigs); serviceConfig.setProvider((ProviderConfig)applicationContext.getBean(service.provider(),ProviderConfig.class)); serviceConfig.setMonitor((MonitorConfig)applicationContext.getBean(service.monitor(), MonitorConfig.class)); serviceConfig.setApplication((ApplicationConfig)applicationContext.getBean(service.application(), ApplicationConfig.class)); serviceConfig.setModule((ModuleConfig)applicationContext.getBean(service.module(), ModuleConfig.class)); serviceConfig.setProvider((ProviderConfig)applicationContext.getBean(service.provider(), ProviderConfig.class)); } else { serviceConfig.setProtocols(protocolConfigs); serviceConfig.afterPropertiesSet(); } catch (RuntimeException e) {
ServiceBean<Object> serviceConfig = new ServiceBean<Object>(service); if (void.class.equals(service.interfaceClass()) && "".equals(service.interfaceName())) { if (targetClass.getInterfaces().length > 0) { serviceConfig.setInterface(targetClass.getInterfaces()[0]); } else { throw new IllegalStateException("Failed to export remote service class " + targetClass.getName() + ", cause: The @Service undefined interfaceClass or interfaceName, and the service class unimplemented any interfaces."); serviceConfig.setApplicationContext(applicationContext); if (service.registry().length > 0) { List<RegistryConfig> registryConfigs = new ArrayList<RegistryConfig>(); serviceConfig.setRegistries(registryConfigs); serviceConfig.setProvider(applicationContext.getBean(service.provider(), ProviderConfig.class)); serviceConfig.setMonitor(applicationContext.getBean(service.monitor(), MonitorConfig.class)); serviceConfig.setApplication(applicationContext.getBean(service.application(), ApplicationConfig.class)); serviceConfig.setModule(applicationContext.getBean(service.module(), ModuleConfig.class)); serviceConfig.setProvider(applicationContext.getBean(service.provider(), ProviderConfig.class)); serviceConfig.setTimeout(Integer.parseInt(timeout)); serviceConfig.setProtocols(protocolConfigs); serviceConfig.afterPropertiesSet(); } catch (RuntimeException e) {