List of usage examples for org.springframework.beans.factory.config BeanDefinition getBeanClassName
@Nullable String getBeanClassName();
From source file:org.jnap.core.persistence.factory.DaoFactoryBkp.java
private boolean isDaoDefinedForEntity(DefaultListableBeanFactory beanFactory, Class<? extends PersistentModel> entityClass) { if (alreadyDefinedDaos == null) { alreadyDefinedDaos = new HashSet<Class<? extends PersistentModel>>(); for (String beanName : beanFactory.getBeanNamesForType(Dao.class, true, false)) { BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName); final Class<?> daoType = ClassUtils.resolveClassName(beanDefinition.getBeanClassName(), DaoFactory.class.getClassLoader()); Class daoEntityClass = GenericTypeResolver.resolveTypeArgument(daoType, Dao.class); alreadyDefinedDaos.add(daoEntityClass); daoNameCache.put(daoEntityClass, beanName); }//w w w. j av a 2s . c o m } return alreadyDefinedDaos.contains(entityClass); }
From source file:com.github.philippn.springremotingautoconfigure.client.annotation.HttpInvokerProxyFactoryBeanRegistrar.java
@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { Set<String> basePackages = new HashSet<>(); for (String beanName : registry.getBeanDefinitionNames()) { BeanDefinition definition = registry.getBeanDefinition(beanName); if (definition.getBeanClassName() != null) { try { Class<?> resolvedClass = ClassUtils.forName(definition.getBeanClassName(), null); EnableHttpInvokerAutoProxy autoProxy = AnnotationUtils.findAnnotation(resolvedClass, EnableHttpInvokerAutoProxy.class); if (autoProxy != null) { if (autoProxy.basePackages().length > 0) { Collections.addAll(basePackages, autoProxy.basePackages()); } else { basePackages.add(resolvedClass.getPackage().getName()); }// w w w .jav a 2 s. c o m } } catch (ClassNotFoundException e) { throw new IllegalStateException("Unable to inspect class " + definition.getBeanClassName() + " for @EnableHttpInvokerAutoProxy annotations"); } } } ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider( false) { /* (non-Javadoc) * @see org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider#isCandidateComponent(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition) */ @Override protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) { return beanDefinition.getMetadata().isInterface() && beanDefinition.getMetadata().isIndependent(); } }; scanner.addIncludeFilter(new AnnotationTypeFilter(RemoteExport.class)); for (String basePackage : basePackages) { for (BeanDefinition definition : scanner.findCandidateComponents(basePackage)) { if (definition.getBeanClassName() != null) { try { Class<?> resolvedClass = ClassUtils.forName(definition.getBeanClassName(), null); setupProxy(resolvedClass, registry); } catch (ClassNotFoundException e) { throw new IllegalStateException("Unable to inspect class " + definition.getBeanClassName() + " for @RemoteExport annotations"); } } } } }
From source file:org.openmrs.module.kenyaemr.calculation.CalculationManager.java
/** * Refreshes registered calculation classes *//*ww w .j a v a 2s .c om*/ public synchronized void refresh() { clear(); ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider( false); scanner.addIncludeFilter(new AssignableTypeFilter(BaseEmrCalculation.class)); for (BeanDefinition bd : scanner.findCandidateComponents(CalculationManager.class.getPackage().getName())) { try { Class clazz = Class.forName(bd.getBeanClassName()); calculationClasses.put(bd.getBeanClassName(), clazz); } catch (ClassNotFoundException e) { e.printStackTrace(); } log.info("Found calculation class :" + bd.getBeanClassName()); } }
From source file:com._4dconcept.springframework.data.marklogic.config.AbstractMarklogicConfiguration.java
private Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException { String basePackage = getMappingBasePackage(); Set<Class<?>> initialEntitySet = new HashSet<>(); if (StringUtils.hasText(basePackage)) { ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider( false);/*from ww w.j a va 2s. c o m*/ componentProvider.addIncludeFilter(new AnnotationTypeFilter(Document.class)); for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) { String beanClassName = candidate.getBeanClassName(); if (beanClassName != null) { initialEntitySet.add(ClassUtils.forName(beanClassName, AbstractMarklogicConfiguration.class.getClassLoader())); } } } return initialEntitySet; }
From source file:br.com.caelum.vraptor.ioc.spring.ComponentScanner.java
@Override protected boolean checkCandidate(String beanName, BeanDefinition beanDefinition) throws IllegalStateException { if (registry.containsBeanDefinition(beanName) && registry.getBeanDefinition(beanName).getBeanClassName() .equals(beanDefinition.getBeanClassName())) { logger.warn(//from ww w . j a va2s . c o m "bean already found previously, there is probably no need to declare its package in web.xml:" + beanDefinition.getBeanClassName()); return false; } return super.checkCandidate(beanName, beanDefinition); }
From source file:org.bytesoft.bytejta.supports.dubbo.TransactionConfigPostProcessor.java
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { String[] beanNameArray = beanFactory.getBeanDefinitionNames(); String applicationBeanId = null; String registryBeanId = null; String transactionBeanId = null; for (int i = 0; i < beanNameArray.length; i++) { String beanName = beanNameArray[i]; BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName); String beanClassName = beanDef.getBeanClassName(); if (com.alibaba.dubbo.config.ApplicationConfig.class.getName().equals(beanClassName)) { if (StringUtils.isBlank(applicationBeanId)) { applicationBeanId = beanName; } else { throw new FatalBeanException("There are more than one application name was found!"); }/*w w w .j a va 2 s . c o m*/ } else if (org.bytesoft.bytejta.TransactionCoordinator.class.getName().equals(beanClassName)) { if (StringUtils.isBlank(transactionBeanId)) { transactionBeanId = beanName; } else { throw new FatalBeanException( "There are more than one org.bytesoft.bytejta.TransactionCoordinator was found!"); } } else if (org.bytesoft.bytejta.supports.dubbo.TransactionBeanRegistry.class.getName() .equals(beanClassName)) { if (StringUtils.isBlank(registryBeanId)) { registryBeanId = beanName; } else { throw new FatalBeanException( "There are more than one org.bytesoft.bytejta.supports.dubbo.TransactionBeanRegistry was found!"); } } } if (StringUtils.isBlank(applicationBeanId)) { throw new FatalBeanException("No application name was found!"); } BeanDefinition beanDef = beanFactory.getBeanDefinition(applicationBeanId); MutablePropertyValues mpv = beanDef.getPropertyValues(); PropertyValue pv = mpv.getPropertyValue("name"); if (pv == null || pv.getValue() == null || StringUtils.isBlank(String.valueOf(pv.getValue()))) { throw new FatalBeanException("No application name was found!"); } if (StringUtils.isBlank(transactionBeanId)) { throw new FatalBeanException( "No configuration of class org.bytesoft.bytejta.TransactionCoordinator was found."); } else if (registryBeanId == null) { throw new FatalBeanException( "No configuration of class org.bytesoft.bytejta.supports.dubbo.TransactionBeanRegistry was found."); } String application = String.valueOf(pv.getValue()); this.initializeForProvider(beanFactory, application, transactionBeanId); this.initializeForConsumer(beanFactory, application, registryBeanId); }
From source file:com.deq.spring.ObjectifyFactoryBean.java
protected List<Class<?>> doScan() { final List<Class<?>> classes = new ArrayList<Class<?>>(); final String[] basePackages = StringUtils.tokenizeToStringArray(basePackage, ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS); for (final String basePackage : basePackages) { if (logger.isInfoEnabled()) { logger.info("Scanning package [" + basePackage + "]"); }// ww w. ja v a 2 s. c o m final ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider( false); scanner.addIncludeFilter(new AnnotationTypeFilter(com.googlecode.objectify.annotation.Entity.class)); scanner.addIncludeFilter(new AnnotationTypeFilter(com.googlecode.objectify.annotation.Subclass.class)); scanner.addIncludeFilter(new AnnotationTypeFilter(javax.persistence.Entity.class)); final Set<BeanDefinition> candidates = scanner.findCandidateComponents(basePackage); for (final BeanDefinition candidate : candidates) { final Class<?> clazz = ClassUtils.resolveClassName(candidate.getBeanClassName(), ClassUtils.getDefaultClassLoader()); classes.add(clazz); } } return classes; }
From source file:com.kixeye.chassis.transport.websocket.WebSocketMessageMappingRegistry.java
@PostConstruct public void registerWebSocketActions() throws BeansException { String[] controllerBeanNames = beanFactory.getBeanNamesForAnnotation(WebSocketController.class); if (controllerBeanNames != null && controllerBeanNames.length > 0) { try {/* w w w . j a v a 2s.c o m*/ for (String beanName : controllerBeanNames) { BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName); Class<?> beanClass = Class.forName(beanDef.getBeanClassName()); for (Method method : beanClass.getMethods()) { ActionMapping mapping = method.getAnnotation(ActionMapping.class); if (mapping != null) { if (mapping.value() != null && mapping.value().length > 0) { Map<String, String> requirements = new HashMap<>(); if (mapping.propertyRequirements() != null) { for (ActionPropertyRequirement requirement : mapping.propertyRequirements()) { requirements.put(requirement.name(), requirement.value()); } } for (String action : mapping.value()) { logger.info("Registering destination [{}] with handler [{}].", action, method.toString()); Map<String, WebSocketActionArgumentResolver> argumentResolverBeans = beanFactory .getBeansOfType(WebSocketActionArgumentResolver.class); if (argumentResolverBeans != null && !argumentResolverBeans.isEmpty()) { logger.info( "Registering WebSocketActionArgumentResolver beans {} with action {}", Joiner.on(",").join(argumentResolverBeans.keySet(), action)); } actions.put(action, new WebSocketAction(method, requirements, argumentResolverBeans == null ? null : argumentResolverBeans.values().toArray( new WebSocketActionArgumentResolver[argumentResolverBeans .size()]))); } } } } } } catch (Exception e) { throw new FatalBeanException("Unable to configure bean", e); } } else { logger.warn("No WebSocketController beans defined."); } }
From source file:com.qubit.solution.fenixedu.integration.cgd.ui.cgdConfiguration.CgdIntegrationConfigurationController.java
@RequestMapping(value = "/update/{oid}/strategies", method = RequestMethod.GET, produces = "application/json; charset=utf-8") public @org.springframework.web.bind.annotation.ResponseBody List<String> requestAvailableStrategies( @PathVariable("oid") CgdIntegrationConfiguration cgdIntegrationConfiguration, Model model) { List<String> results = new ArrayList<String>(); ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider( false);//from www . j a v a 2 s . c o m provider.addIncludeFilter(new AssignableTypeFilter(IMemberIDAdapter.class)); for (BeanDefinition definition : provider .findCandidateComponents("/com/qubit/solution/fenixedu/integration/cgd/services/memberid")) { results.add(definition.getBeanClassName()); } return results; }
From source file:org.datamongo.jira.datamongo1064.mapper.EmbeddedObjectTypeInformationMapper.java
/** * Scans the mapping base package for classes annotated with {@link Embeddable}. * //from w w w . j a va 2s . c o m * @see #getMappingBasePackage() * @return * @throws ClassNotFoundException */ protected Map<Class<?>, String> getInitialEntitySet() throws ClassNotFoundException { String[] basePackage = this.basePackage; Map<Class<?>, String> initialEntitySet = new HashMap<Class<?>, String>(); if (basePackage != null) { for (String packageBase : basePackage) { if (StringUtils.hasText(packageBase)) { ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider( false); componentProvider.addIncludeFilter(new AnnotationTypeFilter(Embeddable.class)); for (BeanDefinition candidate : componentProvider.findCandidateComponents(packageBase)) { Class<?> forName = ClassUtils.forName(candidate.getBeanClassName(), AbstractMongoConfiguration.class.getClassLoader()); String alias = forName.getAnnotation(TypeAlias.class) != null ? forName.getAnnotation(TypeAlias.class).value() : forName.getName(); initialEntitySet.put(forName, alias); } } } } return initialEntitySet; }