org.springframework.beans.FatalBeanException Java Examples
The following examples show how to use
org.springframework.beans.FatalBeanException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JedisRedisClient.java From SampleCode with MIT License | 6 votes |
public static void LogError(Exception ex) { if (ex instanceof JedisConnectionException) { Throwable cause = ex.getCause(); if (cause != null && cause instanceof SocketTimeoutException) Logging.write("T"); else Logging.write("C"); } else if (ex instanceof JedisBusyException) { Logging.write("B"); } else if (ex instanceof JedisException) { Logging.write("E"); } else if (ex instanceof IOException){ Logging.write("C"); } else { Logging.logException(ex); throw new FatalBeanException(ex.getMessage(), ex); // unexpected exception type, so abort test for investigation } }
Example #2
Source File: BeanUtils.java From SuperBoot with MIT License | 6 votes |
/** * 复制实体属性到map * * @param source * @param target * @throws BeansException */ public static void copyProperties(Object source, Map target) throws BeansException { PropertyDescriptor[] sourcePds = getPropertyDescriptors(source.getClass()); for (PropertyDescriptor sourcePd : sourcePds) { Method readMethod = sourcePd.getReadMethod(); if (null != readMethod) { try { if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers())) { readMethod.setAccessible(true); } Object value = readMethod.invoke(source); target.put(sourcePd.getName(), value); } catch (Throwable ex) { throw new FatalBeanException( "Could not copy property '" + sourcePd.getName() + "' from source to target", ex); } } } }
Example #3
Source File: Jackson2ObjectMapperBuilder.java From java-technology-stack with MIT License | 6 votes |
private void configureFeature(ObjectMapper objectMapper, Object feature, boolean enabled) { if (feature instanceof JsonParser.Feature) { objectMapper.configure((JsonParser.Feature) feature, enabled); } else if (feature instanceof JsonGenerator.Feature) { objectMapper.configure((JsonGenerator.Feature) feature, enabled); } else if (feature instanceof SerializationFeature) { objectMapper.configure((SerializationFeature) feature, enabled); } else if (feature instanceof DeserializationFeature) { objectMapper.configure((DeserializationFeature) feature, enabled); } else if (feature instanceof MapperFeature) { objectMapper.configure((MapperFeature) feature, enabled); } else { throw new FatalBeanException("Unknown feature class: " + feature.getClass().getName()); } }
Example #4
Source File: BeanUtils.java From SuperBoot with MIT License | 6 votes |
/** * 复制Map属性 * * @param source * @param target * @throws BeansException */ public static void copyProperties(Map source, Object target) throws BeansException { Iterator<Map.Entry> s = source.entrySet().iterator(); //获取目标对象所有属性 PropertyDescriptor[] targetPds = getPropertyDescriptors(target.getClass()); for (PropertyDescriptor targetPd : targetPds) { //获取目标对象属性写方法 Method writeMethod = targetPd.getWriteMethod(); if (null != writeMethod) { try { while (s.hasNext()) { Map.Entry en = s.next(); if (en.getKey().equals(targetPd.getName())) { //如果方法访问权限不足,设置方法允许访问权限 if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers())) { writeMethod.setAccessible(true); } writeMethod.invoke(target, new Object[]{en.getValue()}); } } } catch (Throwable var15) { throw new FatalBeanException("Could not copy property \'" + targetPd.getName() + "\' from source to target", var15); } } } }
Example #5
Source File: PrefixPropertyCondition.java From loc-framework with MIT License | 6 votes |
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { String prefix = (String) attribute(metadata, "prefix"); Class<?> value = (Class<?>) attribute(metadata, "value"); ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment(); try { new Binder(ConfigurationPropertySources.from(environment.getPropertySources())) .bind(prefix, Bindable.of(value)) .orElseThrow( () -> new FatalBeanException("Could not bind DataSourceSettings properties")); return new ConditionOutcome(true, String.format("Map property [%s] is not empty", prefix)); } catch (Exception e) { //ignore } return new ConditionOutcome(false, String.format("Map property [%s] is empty", prefix)); }
Example #6
Source File: InitializerManager.java From entando-core with GNU Lesser General Public License v3.0 | 6 votes |
public void executePostInitProcesses() throws BeansException { SystemInstallationReport report = null; try { report = this.extractReport(); List<Component> components = this.getComponentManager().getCurrentComponents(); for (Component component : components) { executeComponentPostInitProcesses(component, report); } } catch (Throwable t) { logger.error("Error while executing post processes", t); throw new FatalBeanException("Error while executing post processes", t); } finally { if (null != report && report.isUpdated()) { this.saveReport(report); } } }
Example #7
Source File: SimpleUrlHandlerMappingTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void handlerBeanNotFound() throws Exception { MockServletContext sc = new MockServletContext(""); XmlWebApplicationContext root = new XmlWebApplicationContext(); root.setServletContext(sc); root.setConfigLocations(new String[] {"/org/springframework/web/servlet/handler/map1.xml"}); root.refresh(); XmlWebApplicationContext wac = new XmlWebApplicationContext(); wac.setParent(root); wac.setServletContext(sc); wac.setNamespace("map2err"); wac.setConfigLocations(new String[] {"/org/springframework/web/servlet/handler/map2err.xml"}); try { wac.refresh(); fail("Should have thrown NoSuchBeanDefinitionException"); } catch (FatalBeanException ex) { NoSuchBeanDefinitionException nestedEx = (NoSuchBeanDefinitionException) ex.getCause(); assertEquals("mainControlle", nestedEx.getBeanName()); } }
Example #8
Source File: Jackson2ObjectMapperBuilder.java From spring4-understanding with Apache License 2.0 | 6 votes |
private void configureFeature(ObjectMapper objectMapper, Object feature, boolean enabled) { if (feature instanceof JsonParser.Feature) { objectMapper.configure((JsonParser.Feature) feature, enabled); } else if (feature instanceof JsonGenerator.Feature) { objectMapper.configure((JsonGenerator.Feature) feature, enabled); } else if (feature instanceof SerializationFeature) { objectMapper.configure((SerializationFeature) feature, enabled); } else if (feature instanceof DeserializationFeature) { objectMapper.configure((DeserializationFeature) feature, enabled); } else if (feature instanceof MapperFeature) { objectMapper.configure((MapperFeature) feature, enabled); } else { throw new FatalBeanException("Unknown feature class: " + feature.getClass().getName()); } }
Example #9
Source File: SingletonBeanFactoryLocator.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public void release() throws FatalBeanException { synchronized (bfgInstancesByKey) { BeanFactory savedRef = this.groupContextRef; if (savedRef != null) { this.groupContextRef = null; BeanFactoryGroup bfg = bfgInstancesByObj.get(savedRef); if (bfg != null) { bfg.refCount--; if (bfg.refCount == 0) { destroyDefinition(savedRef, resourceLocation); bfgInstancesByKey.remove(resourceLocation); bfgInstancesByObj.remove(savedRef); } } else { // This should be impossible. logger.warn("Tried to release a SingletonBeanFactoryLocator group definition " + "more times than it has actually been used. Resource name [" + resourceLocation + "]"); } } } }
Example #10
Source File: QuotaBeanFactoryPostProcessor.java From james-project with Apache License 2.0 | 6 votes |
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { ConfigurationProvider confProvider = beanFactory.getBean(ConfigurationProvider.class); try { HierarchicalConfiguration<ImmutableNode> config = confProvider.getConfiguration("quota"); String quotaRootResolver = config.configurationAt(QUOTA_ROOT_RESOLVER_BEAN).getString(PROVIDER, DEFAULT_IMPLEMENTATION); String currentQuotaManager = config.configurationAt(CURRENT_QUOTA_MANAGER_BEAN).getString(PROVIDER, "none"); String maxQuotaManager = config.configurationAt(MAX_QUOTA_MANAGER).getString(PROVIDER, FAKE_IMPLEMENTATION); String quotaManager = config.configurationAt(QUOTA_MANAGER_BEAN).getString(PROVIDER, FAKE_IMPLEMENTATION); String quotaUpdater = config.configurationAt(UPDATES_BEAN).getString(PROVIDER, FAKE_IMPLEMENTATION); BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; registerAliasForQuotaRootResolver(quotaRootResolver, registry); registerAliasForCurrentQuotaManager(currentQuotaManager, registry); registerAliasForMaxQuotaManager(maxQuotaManager, registry); registerAliasForQuotaManager(quotaManager, registry); registerAliasForQuotaUpdater(quotaUpdater, registry); } catch (ConfigurationException e) { throw new FatalBeanException("Unable to configure Quota system", e); } }
Example #11
Source File: Jackson2ObjectMapperBuilder.java From lams with GNU General Public License v2.0 | 6 votes |
private void configureFeature(ObjectMapper objectMapper, Object feature, boolean enabled) { if (feature instanceof JsonParser.Feature) { objectMapper.configure((JsonParser.Feature) feature, enabled); } else if (feature instanceof JsonGenerator.Feature) { objectMapper.configure((JsonGenerator.Feature) feature, enabled); } else if (feature instanceof SerializationFeature) { objectMapper.configure((SerializationFeature) feature, enabled); } else if (feature instanceof DeserializationFeature) { objectMapper.configure((DeserializationFeature) feature, enabled); } else if (feature instanceof MapperFeature) { objectMapper.configure((MapperFeature) feature, enabled); } else { throw new FatalBeanException("Unknown feature class: " + feature.getClass().getName()); } }
Example #12
Source File: Jackson2ObjectMapperBuilder.java From spring-analysis-note with MIT License | 6 votes |
private void configureFeature(ObjectMapper objectMapper, Object feature, boolean enabled) { if (feature instanceof JsonParser.Feature) { objectMapper.configure((JsonParser.Feature) feature, enabled); } else if (feature instanceof JsonGenerator.Feature) { objectMapper.configure((JsonGenerator.Feature) feature, enabled); } else if (feature instanceof SerializationFeature) { objectMapper.configure((SerializationFeature) feature, enabled); } else if (feature instanceof DeserializationFeature) { objectMapper.configure((DeserializationFeature) feature, enabled); } else if (feature instanceof MapperFeature) { objectMapper.configure((MapperFeature) feature, enabled); } else { throw new FatalBeanException("Unknown feature class: " + feature.getClass().getName()); } }
Example #13
Source File: SimpleUrlHandlerMappingTests.java From spring-analysis-note with MIT License | 6 votes |
@Test @SuppressWarnings("resource") public void handlerBeanNotFound() { MockServletContext sc = new MockServletContext(""); XmlWebApplicationContext root = new XmlWebApplicationContext(); root.setServletContext(sc); root.setConfigLocations("/org/springframework/web/servlet/handler/map1.xml"); root.refresh(); XmlWebApplicationContext wac = new XmlWebApplicationContext(); wac.setParent(root); wac.setServletContext(sc); wac.setNamespace("map2err"); wac.setConfigLocations("/org/springframework/web/servlet/handler/map2err.xml"); try { wac.refresh(); fail("Should have thrown NoSuchBeanDefinitionException"); } catch (FatalBeanException ex) { NoSuchBeanDefinitionException nestedEx = (NoSuchBeanDefinitionException) ex.getCause(); assertEquals("mainControlle", nestedEx.getBeanName()); } }
Example #14
Source File: AbstractLifecycleBeanPostProcessor.java From james-project with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public final Object postProcessAfterInitialization(Object bean, String name) throws BeansException { try { Class<T> lClass = getLifeCycleInterface(); if (lClass.isInstance(bean)) { // Check if the bean is registered in the context. // If not it was created by the container and so there is no // need to execute the callback. if (factory.containsBeanDefinition(name)) { executeLifecycleMethodAfterInit((T) bean, name); } } } catch (Exception e) { throw new FatalBeanException("Unable to execute lifecycle method on bean" + name, e); } return bean; }
Example #15
Source File: CompensableParticipantRegistrant.java From ByteTCC with GNU Lesser General Public License v3.0 | 6 votes |
public void afterSingletonsInstantiated() { org.bytesoft.bytetcc.TransactionCoordinator transactionCoordinator = // this.beanFactory.getBean(org.bytesoft.bytetcc.TransactionCoordinator.class); org.bytesoft.bytetcc.supports.dubbo.CompensableBeanRegistry beanRegistry = // this.beanFactory.getBean(org.bytesoft.bytetcc.supports.dubbo.CompensableBeanRegistry.class); org.bytesoft.bytetcc.CompensableCoordinator compensableCoordinator = // this.beanFactory.getBean(org.bytesoft.bytetcc.CompensableCoordinator.class); if (compensableCoordinator == null) { throw new FatalBeanException("No configuration of class org.bytesoft.bytetcc.CompensableCoordinator was found."); } else if (transactionCoordinator == null) { throw new FatalBeanException("No configuration of class org.bytesoft.bytetcc.TransactionCoordinator was found."); } else if (beanRegistry == null) { throw new FatalBeanException( "No configuration of class org.bytesoft.bytetcc.supports.dubbo.CompensableBeanRegistry was found."); } this.initializeForProvider(transactionCoordinator); }
Example #16
Source File: RedisInstance.java From SampleCode with MIT License | 6 votes |
public static void loadFromFile(Path filePath) { try( BufferedReader reader = new BufferedReader(new FileReader(filePath.toString()))) { String line; while ((line = reader.readLine()) != null) { if (line.length() > 0) { String[] tokens = line.split(":", 3); map.put(tokens[0], new RedisInstance(tokens[1], tokens[2])); } } } catch( IOException ex){ Logging.writeLine("Error while reading file %s", filePath); Logging.logException(ex); throw new FatalBeanException(ex.getMessage()); } }
Example #17
Source File: AbstractLifecycleBeanPostProcessor.java From james-project with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public final Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { try { Class<T> lClass = getLifeCycleInterface(); if (lClass.isInstance(bean)) { // Check if the bean is registered in the context. // If not it was created by the container and so there // is no need to execute the callback. if (factory.containsBeanDefinition(name)) { executeLifecycleMethodBeforeInit((T) bean, name); } } } catch (Exception e) { throw new FatalBeanException("Unable to execute lifecycle method on bean" + name, e); } return bean; }
Example #18
Source File: DefaultNamespaceHandlerResolver.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Locate the {@link NamespaceHandler} for the supplied namespace URI * from the configured mappings. * @param namespaceUri the relevant namespace URI * @return the located {@link NamespaceHandler}, or {@code null} if none found */ @Override public NamespaceHandler resolve(String namespaceUri) { Map<String, Object> handlerMappings = getHandlerMappings(); Object handlerOrClassName = handlerMappings.get(namespaceUri); if (handlerOrClassName == null) { return null; } else if (handlerOrClassName instanceof NamespaceHandler) { return (NamespaceHandler) handlerOrClassName; } else { String className = (String) handlerOrClassName; try { Class<?> handlerClass = ClassUtils.forName(className, this.classLoader); if (!NamespaceHandler.class.isAssignableFrom(handlerClass)) { throw new FatalBeanException("Class [" + className + "] for namespace [" + namespaceUri + "] does not implement the [" + NamespaceHandler.class.getName() + "] interface"); } NamespaceHandler namespaceHandler = (NamespaceHandler) BeanUtils.instantiateClass(handlerClass); namespaceHandler.init(); handlerMappings.put(namespaceUri, namespaceHandler); return namespaceHandler; } catch (ClassNotFoundException ex) { throw new FatalBeanException("NamespaceHandler class [" + className + "] for namespace [" + namespaceUri + "] not found", ex); } catch (LinkageError err) { throw new FatalBeanException("Invalid NamespaceHandler class [" + className + "] for namespace [" + namespaceUri + "]: problem with handler class file or dependent class", err); } } }
Example #19
Source File: QuotaBeanFactoryPostProcessor.java From james-project with Apache License 2.0 | 5 votes |
private void registerAliasForCurrentQuotaManager(String currentQuotaManager, BeanDefinitionRegistry registry) { if (currentQuotaManager.equalsIgnoreCase(IN_MEMORY_IMPLEMENTATION)) { registry.registerAlias("inMemoryCurrentQuotaManager", CURRENT_QUOTA_MANAGER_BEAN); } else if (currentQuotaManager.equalsIgnoreCase(JPA_IMPLEMENTATION)) { registry.registerAlias("jpaCurrentQuotaManager", CURRENT_QUOTA_MANAGER_BEAN); } else if (! currentQuotaManager.equalsIgnoreCase("none")) { throw new FatalBeanException("Unreadable value for Current Quota Manager : " + currentQuotaManager); } }
Example #20
Source File: TransactionConfigDefinitionValidator.java From ByteTCC with GNU Lesser General Public License v3.0 | 5 votes |
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { String[] beanNameArray = beanFactory.getBeanDefinitionNames(); for (int i = 0; i < beanNameArray.length; i++) { String beanName = beanNameArray[i]; BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName); String beanClassName = beanDef.getBeanClassName(); if (org.springframework.transaction.interceptor.TransactionProxyFactoryBean.class.getName().equals(beanClassName)) { throw new FatalBeanException(String.format( "Declaring transactions by configuration is not supported yet, please use annotations to declare transactions(beanId= %s).", beanName)); } if (org.springframework.transaction.interceptor.TransactionInterceptor.class.getName().equals(beanClassName)) { boolean errorExists = true; MutablePropertyValues mpv = beanDef.getPropertyValues(); PropertyValue pv = mpv.getPropertyValue("transactionAttributeSource"); Object value = pv == null ? null : pv.getValue(); if (value != null && RuntimeBeanReference.class.isInstance(value)) { RuntimeBeanReference reference = (RuntimeBeanReference) value; BeanDefinition refBeanDef = beanFactory.getBeanDefinition(reference.getBeanName()); String refBeanClassName = refBeanDef.getBeanClassName(); errorExists = AnnotationTransactionAttributeSource.class.getName().equals(refBeanClassName) == false; } if (errorExists) { throw new FatalBeanException(String.format( "Declaring transactions by configuration is not supported yet, please use annotations to declare transactions(beanId= %s).", beanName)); } // end-if (errorExists) } } // end-for (int i = 0; i < beanNameArray.length; i++) }
Example #21
Source File: DefaultNamespaceHandlerResolver.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Locate the {@link NamespaceHandler} for the supplied namespace URI * from the configured mappings. * @param namespaceUri the relevant namespace URI * @return the located {@link NamespaceHandler}, or {@code null} if none found */ @Override public NamespaceHandler resolve(String namespaceUri) { Map<String, Object> handlerMappings = getHandlerMappings(); Object handlerOrClassName = handlerMappings.get(namespaceUri); if (handlerOrClassName == null) { return null; } else if (handlerOrClassName instanceof NamespaceHandler) { return (NamespaceHandler) handlerOrClassName; } else { String className = (String) handlerOrClassName; try { Class<?> handlerClass = ClassUtils.forName(className, this.classLoader); if (!NamespaceHandler.class.isAssignableFrom(handlerClass)) { throw new FatalBeanException("Class [" + className + "] for namespace [" + namespaceUri + "] does not implement the [" + NamespaceHandler.class.getName() + "] interface"); } NamespaceHandler namespaceHandler = (NamespaceHandler) BeanUtils.instantiateClass(handlerClass); namespaceHandler.init(); handlerMappings.put(namespaceUri, namespaceHandler); return namespaceHandler; } catch (ClassNotFoundException ex) { throw new FatalBeanException("NamespaceHandler class [" + className + "] for namespace [" + namespaceUri + "] not found", ex); } catch (LinkageError err) { throw new FatalBeanException("Invalid NamespaceHandler class [" + className + "] for namespace [" + namespaceUri + "]: problem with handler class file or dependent class", err); } } }
Example #22
Source File: BeanInfoTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public PropertyDescriptor[] getPropertyDescriptors() { try { PropertyDescriptor pd = new PropertyDescriptor("value", ValueBean.class); pd.setPropertyEditorClass(MyNumberEditor.class); return new PropertyDescriptor[] {pd}; } catch (IntrospectionException ex) { throw new FatalBeanException("Couldn't create PropertyDescriptor", ex); } }
Example #23
Source File: ServiceLocatorFactoryBean.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { if (!(beanFactory instanceof ListableBeanFactory)) { throw new FatalBeanException( "ServiceLocatorFactoryBean needs to run in a BeanFactory that is a ListableBeanFactory"); } this.beanFactory = (ListableBeanFactory) beanFactory; }
Example #24
Source File: ServiceLocatorFactoryBeanTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testRequiresListableBeanFactoryAndChokesOnAnythingElse() throws Exception { BeanFactory beanFactory = mock(BeanFactory.class); try { ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean(); factory.setBeanFactory(beanFactory); } catch (FatalBeanException ex) { // expected } }
Example #25
Source File: DefaultNamespaceHandlerResolver.java From blog_demos with Apache License 2.0 | 5 votes |
/** * Locate the {@link NamespaceHandler} for the supplied namespace URI * from the configured mappings. * @param namespaceUri the relevant namespace URI * @return the located {@link NamespaceHandler}, or {@code null} if none found */ @Override public NamespaceHandler resolve(String namespaceUri) { Map<String, Object> handlerMappings = getHandlerMappings(); Object handlerOrClassName = handlerMappings.get(namespaceUri); if (handlerOrClassName == null) { return null; } else if (handlerOrClassName instanceof NamespaceHandler) { return (NamespaceHandler) handlerOrClassName; } else { String className = (String) handlerOrClassName; try { Class<?> handlerClass = ClassUtils.forName(className, this.classLoader); if (!NamespaceHandler.class.isAssignableFrom(handlerClass)) { throw new FatalBeanException("Class [" + className + "] for namespace [" + namespaceUri + "] does not implement the [" + NamespaceHandler.class.getName() + "] interface"); } NamespaceHandler namespaceHandler = (NamespaceHandler) BeanUtils.instantiateClass(handlerClass); namespaceHandler.init(); handlerMappings.put(namespaceUri, namespaceHandler); return namespaceHandler; } catch (ClassNotFoundException ex) { throw new FatalBeanException("NamespaceHandler class [" + className + "] for namespace [" + namespaceUri + "] not found", ex); } catch (LinkageError err) { throw new FatalBeanException("Invalid NamespaceHandler class [" + className + "] for namespace [" + namespaceUri + "]: problem with handler class file or dependent class", err); } } }
Example #26
Source File: QuotaBeanFactoryPostProcessor.java From james-project with Apache License 2.0 | 5 votes |
private void registerAliasForQuotaRootResolver(String quotaRootResolver, BeanDefinitionRegistry registry) { if (quotaRootResolver.equals(DEFAULT_IMPLEMENTATION)) { registry.registerAlias("defaultQuotaRootResolver", QUOTA_ROOT_RESOLVER_BEAN); } else { throw new FatalBeanException("Unreadable value for QUOTA ROOT resolver : " + quotaRootResolver); } }
Example #27
Source File: ComponentScanBeanDefinitionParser.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") protected TypeFilter createTypeFilter(Element element, ClassLoader classLoader, ParserContext parserContext) { String filterType = element.getAttribute(FILTER_TYPE_ATTRIBUTE); String expression = element.getAttribute(FILTER_EXPRESSION_ATTRIBUTE); expression = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(expression); try { if ("annotation".equals(filterType)) { return new AnnotationTypeFilter((Class<Annotation>) classLoader.loadClass(expression)); } else if ("assignable".equals(filterType)) { return new AssignableTypeFilter(classLoader.loadClass(expression)); } else if ("aspectj".equals(filterType)) { return new AspectJTypeFilter(expression, classLoader); } else if ("regex".equals(filterType)) { return new RegexPatternTypeFilter(Pattern.compile(expression)); } else if ("custom".equals(filterType)) { Class<?> filterClass = classLoader.loadClass(expression); if (!TypeFilter.class.isAssignableFrom(filterClass)) { throw new IllegalArgumentException( "Class is not assignable to [" + TypeFilter.class.getName() + "]: " + expression); } return (TypeFilter) BeanUtils.instantiateClass(filterClass); } else { throw new IllegalArgumentException("Unsupported filter type: " + filterType); } } catch (ClassNotFoundException ex) { throw new FatalBeanException("Type filter class not found: " + expression, ex); } }
Example #28
Source File: TransactionParticipantRegistrant.java From ByteJTA with GNU Lesser General Public License v3.0 | 5 votes |
public void afterSingletonsInstantiated() { TransactionCoordinator transactionCoordinator = this.beanFactory.getBean(TransactionCoordinator.class); TransactionBeanRegistry beanRegistry = this.beanFactory.getBean(TransactionBeanRegistry.class); if (transactionCoordinator == null) { throw new FatalBeanException("No configuration of class org.bytesoft.bytejta.TransactionCoordinator was found."); } else if (beanRegistry == null) { throw new FatalBeanException( "No configuration of class org.bytesoft.bytejta.supports.dubbo.TransactionBeanRegistry was found."); } this.initializeForProvider(transactionCoordinator); this.initializeForConsumer(beanRegistry); }
Example #29
Source File: QuotaBeanFactoryPostProcessor.java From james-project with Apache License 2.0 | 5 votes |
private void registerAliasForQuotaManager(String quotaManager, BeanDefinitionRegistry registry) { if (quotaManager.equalsIgnoreCase(FAKE_IMPLEMENTATION)) { registry.registerAlias("noQuotaManager", QUOTA_MANAGER_BEAN); } else if (quotaManager.equalsIgnoreCase("store")) { registry.registerAlias("storeQuotaManager", QUOTA_MANAGER_BEAN); } else { throw new FatalBeanException("Unreadable value for Quota Manager : " + quotaManager); } }
Example #30
Source File: ServiceLocatorFactoryBean.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { if (!(beanFactory instanceof ListableBeanFactory)) { throw new FatalBeanException( "ServiceLocatorFactoryBean needs to run in a BeanFactory that is a ListableBeanFactory"); } this.beanFactory = (ListableBeanFactory) beanFactory; }