List of usage examples for org.springframework.beans.factory BeanDefinitionStoreException BeanDefinitionStoreException
public BeanDefinitionStoreException(@Nullable String resourceDescription, String msg)
From source file:egovframework.rte.fdl.property.impl.EgovPropertyServiceImpl.java
/** * ? resources //from w w w . j a v a2 s . c om * @param location * ? * @param encoding * Encoding * @throws Exception */ private void loadPropertyResources(String location, String encoding) throws Exception { if (resourceLoader instanceof ResourcePatternResolver) { try { Resource[] resources = ((ResourcePatternResolver) resourceLoader).getResources(location); loadPropertyLoop(resources, encoding); } catch (IOException ex) { throw new BeanDefinitionStoreException( "Could not resolve Properties resource pattern [" + location + "]", ex); } } else { Resource resource = resourceLoader.getResource(location); loadPropertyRes(resource, encoding); } }
From source file:com.mtgi.analytics.aop.config.v11.BtManagerBeanDefinitionParser.java
protected void activateAopProxies(ParserContext context, Element source) { try {/*from w ww .ja v a 2 s .com*/ aopRegistration.invoke(null, context, source); } catch (Exception e) { throw new BeanDefinitionStoreException( "Error activating AOP proxies while parsing bt:manager definition", e); } }
From source file:org.apache.camel.spring.handler.CamelNamespaceHandler.java
protected Object parseUsingJaxb(Element element, ParserContext parserContext, Binder<Node> binder) { try {/*from w w w .ja va 2s . com*/ return binder.unmarshal(element); } catch (JAXBException e) { throw new BeanDefinitionStoreException("Failed to parse JAXB element", e); } }
From source file:org.springframework.beans.factory.access.SingletonBeanFactoryLocator.java
/** * Actually creates definition in the form of a BeanFactory, given a resource name * which supports standard Spring resource prefixes ('classpath:', 'classpath*:', etc.) * This is split out as a separate method so that subclasses can override the actual * type used (to be an ApplicationContext, for example). * <p>The default implementation simply builds a * {@link org.springframework.beans.factory.support.DefaultListableBeanFactory} * and populates it using an/*from w w w .j a v a 2 s . c om*/ * {@link org.springframework.beans.factory.xml.XmlBeanDefinitionReader}. * <p>This method should not instantiate any singletons. That function is performed * by {@link #initializeDefinition initializeDefinition()}, which should also be * overridden if this method is. * @param resourceLocation the resource location for this factory group * @param factoryKey the bean name of the factory to obtain * @return the corresponding BeanFactory reference */ protected BeanFactory createDefinition(String resourceLocation, String factoryKey) { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory); ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(); try { Resource[] configResources = resourcePatternResolver.getResources(resourceLocation); if (configResources.length == 0) { throw new FatalBeanException("Unable to find resource for specified definition. " + "Group resource name [" + this.resourceLocation + "], factory key [" + factoryKey + "]"); } reader.loadBeanDefinitions(configResources); } catch (IOException ex) { throw new BeanDefinitionStoreException( "Error accessing bean definition resource [" + this.resourceLocation + "]", ex); } catch (BeanDefinitionStoreException ex) { throw new FatalBeanException("Unable to load group definition: " + "group resource name [" + this.resourceLocation + "], factory key [" + factoryKey + "]", ex); } return factory; }
From source file:org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.java
/** * Parse an "import" element and load the bean definitions * from the given resource into the bean factory. *///from w w w . j av a 2 s. c o m protected void importBeanDefinitionResource(Element ele) throws BeanDefinitionStoreException { String location = ele.getAttribute(RESOURCE_ATTRIBUTE); // Resolve system properties: e.g. "${user.dir}" location = SystemPropertyUtils.resolvePlaceholders(location); if (ResourcePatternUtils.isUrl(location)) { int importCount = getBeanDefinitionReader().loadBeanDefinitions(location); if (logger.isDebugEnabled()) { logger.debug("Imported " + importCount + " bean definitions from URL location [" + location + "]"); } } else { // No URL -> considering resource location as relative to the current file. try { Resource relativeResource = getResource().createRelative(location); int importCount = getBeanDefinitionReader().loadBeanDefinitions(relativeResource); if (logger.isDebugEnabled()) { logger.debug("Imported " + importCount + " bean definitions from relative location [" + location + "]"); } } catch (IOException ex) { throw new BeanDefinitionStoreException( "Invalid relative resource location [" + location + "] to import bean definitions from", ex); } } }
From source file:org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.java
private Set<BeanDefinition> addCandidateComponentsFromIndex(CandidateComponentsIndex index, String basePackage) {/*from www . j av a 2 s .co m*/ Set<BeanDefinition> candidates = new LinkedHashSet<>(); try { Set<String> types = new HashSet<>(); for (TypeFilter filter : this.includeFilters) { String stereotype = extractStereotype(filter); if (stereotype == null) { throw new IllegalArgumentException("Failed to extract stereotype from " + filter); } types.addAll(index.getCandidateTypes(basePackage, stereotype)); } boolean traceEnabled = logger.isTraceEnabled(); boolean debugEnabled = logger.isDebugEnabled(); for (String type : types) { MetadataReader metadataReader = getMetadataReaderFactory().getMetadataReader(type); if (isCandidateComponent(metadataReader)) { AnnotatedGenericBeanDefinition sbd = new AnnotatedGenericBeanDefinition( metadataReader.getAnnotationMetadata()); if (isCandidateComponent(sbd)) { if (debugEnabled) { logger.debug("Using candidate component class from index: " + type); } candidates.add(sbd); } else { if (debugEnabled) { logger.debug("Ignored because not a concrete top-level class: " + type); } } } else { if (traceEnabled) { logger.trace("Ignored because matching an exclude filter: " + type); } } } } catch (IOException ex) { throw new BeanDefinitionStoreException("I/O failure during classpath scanning", ex); } return candidates; }
From source file:org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.java
private Set<BeanDefinition> scanCandidateComponents(String basePackage) { Set<BeanDefinition> candidates = new LinkedHashSet<>(); try {/* w w w .ja v a2 s . co m*/ String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resolveBasePackage(basePackage) + '/' + this.resourcePattern; Resource[] resources = getResourcePatternResolver().getResources(packageSearchPath); boolean traceEnabled = logger.isTraceEnabled(); boolean debugEnabled = logger.isDebugEnabled(); for (Resource resource : resources) { if (traceEnabled) { logger.trace("Scanning " + resource); } if (resource.isReadable()) { try { MetadataReader metadataReader = getMetadataReaderFactory().getMetadataReader(resource); if (isCandidateComponent(metadataReader)) { ScannedGenericBeanDefinition sbd = new ScannedGenericBeanDefinition(metadataReader); sbd.setResource(resource); sbd.setSource(resource); if (isCandidateComponent(sbd)) { if (debugEnabled) { logger.debug("Identified candidate component class: " + resource); } candidates.add(sbd); } else { if (debugEnabled) { logger.debug("Ignored because not a concrete top-level class: " + resource); } } } else { if (traceEnabled) { logger.trace("Ignored because not matching any filter: " + resource); } } } catch (Throwable ex) { throw new BeanDefinitionStoreException( "Failed to read candidate component class: " + resource, ex); } } else { if (traceEnabled) { logger.trace("Ignored because not readable: " + resource); } } } } catch (IOException ex) { throw new BeanDefinitionStoreException("I/O failure during classpath scanning", ex); } return candidates; }
From source file:org.springframework.context.annotation.ConfigurationClassParser.java
public void parse(Set<BeanDefinitionHolder> configCandidates) { this.deferredImportSelectors = new LinkedList<>(); for (BeanDefinitionHolder holder : configCandidates) { BeanDefinition bd = holder.getBeanDefinition(); try {//from www. j ava 2s .co m if (bd instanceof AnnotatedBeanDefinition) { parse(((AnnotatedBeanDefinition) bd).getMetadata(), holder.getBeanName()); } else if (bd instanceof AbstractBeanDefinition && ((AbstractBeanDefinition) bd).hasBeanClass()) { parse(((AbstractBeanDefinition) bd).getBeanClass(), holder.getBeanName()); } else { parse(bd.getBeanClassName(), holder.getBeanName()); } } catch (BeanDefinitionStoreException ex) { throw ex; } catch (Throwable ex) { throw new BeanDefinitionStoreException( "Failed to parse configuration class [" + bd.getBeanClassName() + "]", ex); } } processDeferredImportSelectors(); }
From source file:org.springframework.context.annotation.ConfigurationClassParser.java
private void processDeferredImportSelectors() { List<DeferredImportSelectorHolder> deferredImports = this.deferredImportSelectors; this.deferredImportSelectors = null; if (deferredImports == null) { return;/* w w w.j av a 2 s . com*/ } Collections.sort(deferredImports, DEFERRED_IMPORT_COMPARATOR); for (DeferredImportSelectorHolder deferredImport : deferredImports) { ConfigurationClass configClass = deferredImport.getConfigurationClass(); try { String[] imports = deferredImport.getImportSelector().selectImports(configClass.getMetadata()); processImports(configClass, asSourceClass(configClass), asSourceClasses(imports), false); } catch (BeanDefinitionStoreException ex) { throw ex; } catch (Throwable ex) { throw new BeanDefinitionStoreException( "Failed to process import candidates for configuration class [" + configClass.getMetadata().getClassName() + "]", ex); } } }