@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { Collection<Class<?>> remotingServices = new HashSet<Class<?>>(); remotingServices.addAll(getIncludeClasses()); String[] basePackages = getBasePackages(); if (basePackages != null) remotingServices.addAll(ClassScanner.scanAnnotated(basePackages, Remoting.class)); Collection<Class<?>> excludeRemotingServices = getExcludeClasses(); for (Class<?> remotingService : remotingServices) { if (!remotingService.isInterface() || excludeRemotingServices.contains(remotingService)) continue; String beanName = StringUtils.uncapitalize(remotingService.getSimpleName()); if (registry.containsBeanDefinition(beanName)) { logger.info( "Skip bean {} which implemented by {}", beanName, registry.getBeanDefinition(beanName).getBeanClassName()); continue; } RootBeanDefinition beanDefinition = new RootBeanDefinition(HttpInvokerClient.class); beanDefinition.setTargetType(remotingService); beanDefinition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_NAME); MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.addPropertyValue("serviceInterface", remotingService.getName()); beanDefinition.setPropertyValues(propertyValues); registry.registerBeanDefinition(beanName, beanDefinition); logger.info("Registered bean {} for remoting service", beanName); } }
/** 页面命名空间 */ public String getPageNamespace() { if (isQuirksMode()) return getContextPath() + this.getActionPathPrefix() + "/" + StringUtils.uncapitalize(getEntityConfigName()); else return getActionNamespace(); }
public void setRepositories(Collection<CrudRepository> repositories) { for (CrudRepository repository : repositories) { Class<?> repoClass = AopUtils.getTargetClass(repository); Field infoField = ReflectionUtils.findField(repoClass, "entityInformation"); ReflectionUtils.makeAccessible(infoField); Method m = ReflectionUtils.findMethod(repository.getClass(), "getTargetSource"); ReflectionUtils.makeAccessible(m); try { SingletonTargetSource targetRepo = (SingletonTargetSource) m.invoke(repository); EntityInformation entityInfo = (EntityInformation) infoField.get(targetRepo.getTarget()); Class<?>[] intfs = repository.getClass().getInterfaces(); String name = StringUtils.uncapitalize(intfs[0].getSimpleName().replaceAll("Repository", "")); this.repositories.put( entityInfo.getJavaType(), new RepositoryCacheEntry(name, repository, entityInfo, null)); } catch (Throwable t) { throw new IllegalStateException(t); } } }
/** * Retorna um objeto registrado no Spring de determinada classe <B>IMPORTANTE:</B> Inicialmente, o * objeto será obtido a partir do nome simples da classe com a primeira letra minúscula. Se não * for encontrado, será procurado pelo tipo da classe. */ @SuppressWarnings("unchecked") public static <E> E getObject(Class<E> clazz) { E bean = null; String beanName = StringUtils.uncapitalize(clazz.getSimpleName()); DefaultListableBeanFactory beanFactory = getBeanFactory(); try { bean = (E) beanFactory.getBean(beanName); } catch (NoSuchBeanDefinitionException ex) { try { bean = beanFactory.getBean(clazz); } catch (NoSuchBeanDefinitionException ex2) { throw new NoSuchBeanDefinitionException( beanName, "And, no unique bean of type [" + clazz.getName() + "] is defined: Cannot find bean " + clazz.getName() + " by class neither by name."); } } return bean; }
static String typeKey(TypeInformation<?> type) { return StringUtils.uncapitalize(type.getActualType().getType().getSimpleName()); }
/** * Returns the default path to be used if the path is not configured manually. * * @param type must not be {@literal null}. * @return */ protected String getDefaultPathFor(Class<?> type) { return StringUtils.uncapitalize(type.getSimpleName()); }
/** 对话框的标题 */ protected String getPageTitle() { return this.getText(StringUtils.uncapitalize(getEntityConfigName()) + ".title"); }