• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BeanFactoryAnnotationUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils的典型用法代码示例。如果您正苦于以下问题:Java BeanFactoryAnnotationUtils类的具体用法?Java BeanFactoryAnnotationUtils怎么用?Java BeanFactoryAnnotationUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BeanFactoryAnnotationUtils类属于org.springframework.beans.factory.annotation包,在下文中一共展示了BeanFactoryAnnotationUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: determineTransactionManager

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
/**
 * Determine the specific transaction manager to use for the given transaction.
 */
protected PlatformTransactionManager determineTransactionManager(TransactionAttribute txAttr) {
	if (this.transactionManager != null || this.beanFactory == null || txAttr == null) {
		return this.transactionManager;
	}
	String qualifier = txAttr.getQualifier();
	if (StringUtils.hasLength(qualifier)) {
		return BeanFactoryAnnotationUtils.qualifiedBeanOfType(this.beanFactory, PlatformTransactionManager.class, qualifier);
	}
	else if (this.transactionManagerBeanName != null) {
		return this.beanFactory.getBean(this.transactionManagerBeanName, PlatformTransactionManager.class);
	}
	else {
		return this.beanFactory.getBean(PlatformTransactionManager.class);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:TransactionAspectSupport.java


示例2: determineAsyncExecutor

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
/**
 * Determine the specific executor to use when executing the given method.
 * @return the executor to use (or {@code null}, but just if no default executor has been set)
 */
protected AsyncTaskExecutor determineAsyncExecutor(Method method) {
	AsyncTaskExecutor executor = this.executors.get(method);
	if (executor == null) {
		Executor executorToUse = this.defaultExecutor;
		String qualifier = getExecutorQualifier(method);
		if (StringUtils.hasLength(qualifier)) {
			Assert.notNull(this.beanFactory, "BeanFactory must be set on " + getClass().getSimpleName() +
					" to access qualified executor '" + qualifier + "'");
			executorToUse = BeanFactoryAnnotationUtils.qualifiedBeanOfType(
					this.beanFactory, Executor.class, qualifier);
		}
		else if (executorToUse == null) {
			return null;
		}
		executor = (executorToUse instanceof AsyncTaskExecutor ?
				(AsyncTaskExecutor) executorToUse : new TaskExecutorAdapter(executorToUse));
		this.executors.put(method, executor);
	}
	return executor;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:AsyncExecutionAspectSupport.java


示例3: determineAsyncExecutor

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
/**
 * Determine the specific executor to use when executing the given method.
 * Should preferably return an {@link AsyncListenableTaskExecutor} implementation.
 * @return the executor to use (or {@code null}, but just if no default executor has been set)
 */
protected AsyncTaskExecutor determineAsyncExecutor(Method method) {
	AsyncTaskExecutor executor = this.executors.get(method);
	if (executor == null) {
		Executor executorToUse = this.defaultExecutor;
		String qualifier = getExecutorQualifier(method);
		if (StringUtils.hasLength(qualifier)) {
			if (this.beanFactory == null) {
				throw new IllegalStateException("BeanFactory must be set on " + getClass().getSimpleName() +
						" to access qualified executor '" + qualifier + "'");
			}
			executorToUse = BeanFactoryAnnotationUtils.qualifiedBeanOfType(
					this.beanFactory, Executor.class, qualifier);
		}
		else if (executorToUse == null) {
			return null;
		}
		executor = (executorToUse instanceof AsyncListenableTaskExecutor ?
				(AsyncListenableTaskExecutor) executorToUse : new TaskExecutorAdapter(executorToUse));
		this.executors.put(method, executor);
	}
	return executor;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:28,代码来源:AsyncExecutionAspectSupport.java


示例4: getTransactionManager

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
/**
 * Get the {@linkplain PlatformTransactionManager transaction manager} to use
 * for the supplied {@linkplain TestContext test context} and {@code qualifier}.
 * <p>Delegates to {@link #getTransactionManager(TestContext)} if the
 * supplied {@code qualifier} is {@code null} or empty.
 * @param testContext the test context for which the transaction manager
 * should be retrieved
 * @param qualifier the qualifier for selecting between multiple bean matches;
 * may be {@code null} or empty
 * @return the transaction manager to use, or {@code null} if not found
 * @throws BeansException if an error occurs while retrieving the transaction manager
 * @see #getTransactionManager(TestContext)
 */
protected PlatformTransactionManager getTransactionManager(TestContext testContext, String qualifier) {
	// look up by type and qualifier from @Transactional
	if (StringUtils.hasText(qualifier)) {
		try {
			// Use autowire-capable factory in order to support extended qualifier
			// matching (only exposed on the internal BeanFactory, not on the
			// ApplicationContext).
			BeanFactory bf = testContext.getApplicationContext().getAutowireCapableBeanFactory();

			return BeanFactoryAnnotationUtils.qualifiedBeanOfType(bf, PlatformTransactionManager.class, qualifier);
		}
		catch (RuntimeException ex) {
			if (logger.isWarnEnabled()) {
				logger.warn(
					String.format(
						"Caught exception while retrieving transaction manager with qualifier '%s' for test context %s",
						qualifier, testContext), ex);
			}
			throw ex;
		}
	}

	// else
	return getTransactionManager(testContext);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:39,代码来源:TransactionalTestExecutionListener.java


示例5: getJsonPayload

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
private String getJsonPayload(Device device, byte[] payloadBytes) throws BusinessException {

        DeviceModel.ContentType contentType = device.getDeviceModel().getContentType();
        if (contentType == null) {
            contentType = DeviceModel.ContentType.APPLICATION_JSON;
        }

        JsonConverter jsonConverter = BeanFactoryAnnotationUtils.qualifiedBeanOfType(beans, JsonConverter.class, contentType.getValue());
        ServiceResponse<String> jsonConverterResponse = jsonConverter.toJson(payloadBytes);

        if (jsonConverterResponse.isOk()) {
            return jsonConverterResponse.getResult();
        } else {
            throw new BusinessException(Messages.INVALID_PAYLOAD.getCode());
        }

    }
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:18,代码来源:DeviceEventProcessor.java


示例6: getTransactionManager

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
/**
 * Get the {@link PlatformTransactionManager transaction manager} to use
 * for the supplied {@link TestContext test context} and {@code qualifier}.
 * <p>Delegates to {@link #getTransactionManager(TestContext)} if the
 * supplied {@code qualifier} is {@code null} or empty.
 * @param testContext the test context for which the transaction manager
 * should be retrieved
 * @param qualifier the qualifier for selecting between multiple bean matches;
 * may be {@code null} or empty
 * @return the transaction manager to use, or {@code null} if not found
 * @throws BeansException if an error occurs while retrieving the transaction manager
 * @see #getTransactionManager(TestContext)
 */
protected final PlatformTransactionManager getTransactionManager(TestContext testContext, String qualifier) {
	// look up by type and qualifier from @Transactional
	if (StringUtils.hasText(qualifier)) {
		try {
			// Use autowire-capable factory in order to support extended qualifier
			// matching (only exposed on the internal BeanFactory, not on the
			// ApplicationContext).
			BeanFactory bf = testContext.getApplicationContext().getAutowireCapableBeanFactory();

			return BeanFactoryAnnotationUtils.qualifiedBeanOfType(bf, PlatformTransactionManager.class, qualifier);
		} catch (RuntimeException ex) {
			if (logger.isWarnEnabled()) {
				logger.warn("Caught exception while retrieving transaction manager for test context " + testContext
						+ " and qualifier [" + qualifier + "]", ex);
			}
			throw ex;
		}
	}

	// else
	return getTransactionManager(testContext);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:36,代码来源:TransactionalTestExecutionListener.java


示例7: determineQualifiedTransactionManager

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
private PlatformTransactionManager determineQualifiedTransactionManager(String qualifier) {
	PlatformTransactionManager txManager = this.transactionManagerCache.get(qualifier);
	if (txManager == null) {
		txManager = BeanFactoryAnnotationUtils.qualifiedBeanOfType(
				this.beanFactory, PlatformTransactionManager.class, qualifier);
		this.transactionManagerCache.putIfAbsent(qualifier, txManager);
	}
	return txManager;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:TransactionAspectSupport.java


示例8: getJsonPayload

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
private ServiceResponse<byte[]> getJsonPayload(Device device, String payloadJson) {

        DeviceModel.ContentType contentType = DeviceModel.ContentType.APPLICATION_JSON;
        if (device.getDeviceModel() != null &&
            device.getDeviceModel().getContentType() != null) {
            contentType = device.getDeviceModel().getContentType();
        }

        JsonConverter jsonConverter = BeanFactoryAnnotationUtils.qualifiedBeanOfType(beans, JsonConverter.class, contentType.getValue());
        ServiceResponse<byte[]> jsonConverterResponse = jsonConverter.fromJson(payloadJson);

        return jsonConverterResponse;

    }
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:15,代码来源:EventPublisherDevice.java


示例9: doSearch

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
private Object doSearch(Class<?> classType) {
	try {
		return BeanFactoryAnnotationUtils.qualifiedBeanOfType(beanFactory, classType, QUALIFIER_NAME);
	} catch (NoSuchBeanDefinitionException e) {
		return null;
	}
}
 
开发者ID:ljtfreitas,项目名称:java-restify,代码行数:8,代码来源:HystrixFallbackBeanFactory.java


示例10: findQualifiedExecutor

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
/**
 * Retrieve a target executor for the given qualifier.
 * @param qualifier the qualifier to resolve
 * @return the target executor, or {@code null} if none available
 * @since 4.2.6
 * @see #getExecutorQualifier(Method)
 */
protected Executor findQualifiedExecutor(BeanFactory beanFactory, String qualifier) {
	if (beanFactory == null) {
		throw new IllegalStateException("BeanFactory must be set on " + getClass().getSimpleName() +
				" to access qualified executor '" + qualifier + "'");
	}
	return BeanFactoryAnnotationUtils.qualifiedBeanOfType(beanFactory, Executor.class, qualifier);
}
 
开发者ID:txazo,项目名称:spring,代码行数:15,代码来源:AsyncExecutionAspectSupport.java


示例11: determineQualifiedTransactionManager

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
private PlatformTransactionManager determineQualifiedTransactionManager(String qualifier) {
	PlatformTransactionManager txManager = this.transactionManagerCache.get(qualifier);
	if (txManager == null) {
		txManager = BeanFactoryAnnotationUtils.qualifiedBeanOfType(
				this.beanFactory, PlatformTransactionManager.class, qualifier);
		this.transactionManagerCache.putIfAbsent(qualifier, txManager);
	}

	return txManager;
}
 
开发者ID:gsgsdtc,项目名称:ldtm,代码行数:11,代码来源:AnnotationLdtmAttributeSource.java


示例12: getBean

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
/**
 * Return a bean with the specified name and type. Used to resolve services that are referenced by name in a
 * {@link CacheOperation}.
 * 
 * @param beanName the name of the bean, as defined by the operation
 * @param expectedType type type for the bean
 * @return the bean matching that name
 * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException if such bean does not exist
 * @see CacheOperation#keyGenerator
 * @see CacheOperation#cacheManager
 * @see CacheOperation#cacheResolver
 */
protected <T> T getBean(String beanName, Class<T> expectedType) {
  return BeanFactoryAnnotationUtils.qualifiedBeanOfType(applicationContext, expectedType, beanName);
}
 
开发者ID:nickevin,项目名称:Qihua,代码行数:16,代码来源:CacheAspectSupport.java


示例13: getBean

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
/**
 * Return a bean with the specified name and type. Used to resolve services that
 * are referenced by name in a {@link CacheOperation}.
 * @param beanName the name of the bean, as defined by the operation
 * @param expectedType type type for the bean
 * @return the bean matching that name
 * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException if such bean does not exist
 * @see CacheOperation#keyGenerator
 * @see CacheOperation#cacheManager
 * @see CacheOperation#cacheResolver
 */
protected <T> T getBean(String beanName, Class<T> expectedType) {
	return BeanFactoryAnnotationUtils.qualifiedBeanOfType(this.applicationContext, expectedType, beanName);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:CacheAspectSupport.java


示例14: getBean

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
/**
 * Return a bean with the specified name and type. Used to resolve services that
 * are referenced by name in a {@link CacheOperation}.
 * @param beanName the name of the bean, as defined by the operation
 * @param expectedType type for the bean
 * @return the bean matching that name
 * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException if such bean does not exist
 * @see CacheOperation#keyGenerator
 * @see CacheOperation#cacheManager
 * @see CacheOperation#cacheResolver
 */
protected <T> T getBean(String beanName, Class<T> expectedType) {
	return BeanFactoryAnnotationUtils.qualifiedBeanOfType(this.beanFactory, expectedType, beanName);
}
 
开发者ID:txazo,项目名称:spring,代码行数:15,代码来源:CacheAspectSupport.java


示例15: getTransactionManager

import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; //导入依赖的package包/类
/**
 * Obtain a PlatformTransactionManager from the given BeanFactory, matching the given qualifier.
 * @param beanFactory the BeanFactory to get the {@code PlatformTransactionManager} bean from
 * @param qualifier the qualifier for selecting between multiple {@code PlatformTransactionManager} matches
 * @return the chosen {@code PlatformTransactionManager} (never {@code null})
 * @throws IllegalStateException if no matching {@code PlatformTransactionManager} bean found
 * @deprecated as of Spring 3.1.2 in favor of
 * {@link BeanFactoryAnnotationUtils#qualifiedBeanOfType(BeanFactory, Class, String)}
 */
@Deprecated
public static PlatformTransactionManager getTransactionManager(BeanFactory beanFactory, String qualifier) {
	return BeanFactoryAnnotationUtils.qualifiedBeanOfType(beanFactory, PlatformTransactionManager.class, qualifier);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:TransactionAspectUtils.java



注:本文中的org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CMStateSet类代码示例发布时间:2022-05-23
下一篇:
Java PInputEvent类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap