当前位置: 首页>>代码示例>>Java>>正文


Java BeanUtils.instantiateClass方法代码示例

本文整理汇总了Java中org.springframework.beans.BeanUtils.instantiateClass方法的典型用法代码示例。如果您正苦于以下问题:Java BeanUtils.instantiateClass方法的具体用法?Java BeanUtils.instantiateClass怎么用?Java BeanUtils.instantiateClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.BeanUtils的用法示例。


在下文中一共展示了BeanUtils.instantiateClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postProcessBeanFactory

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
public void postProcessBeanFactory(BundleContext bundleContext, ConfigurableListableBeanFactory beanFactory)
		throws BeansException, OsgiException {

	Bundle bundle = bundleContext.getBundle();
	try {
		// Try and load the annotation code using the bundle classloader
		Class<?> annotationBppClass = bundle.loadClass(ANNOTATION_BPP_CLASS);
		// instantiate the class
		final BeanPostProcessor annotationBeanPostProcessor = (BeanPostProcessor) BeanUtils.instantiateClass(annotationBppClass);

		// everything went okay so configure the BPP and add it to the BF
		((BeanFactoryAware) annotationBeanPostProcessor).setBeanFactory(beanFactory);
		((BeanClassLoaderAware) annotationBeanPostProcessor).setBeanClassLoader(beanFactory.getBeanClassLoader());
		((BundleContextAware) annotationBeanPostProcessor).setBundleContext(bundleContext);
		beanFactory.addBeanPostProcessor(annotationBeanPostProcessor);
	}
	catch (ClassNotFoundException exception) {
		log.info("Spring-DM annotation package could not be loaded from bundle ["
				+ OsgiStringUtils.nullSafeNameAndSymName(bundle) + "]; annotation processing disabled...");
		if (log.isDebugEnabled())
			log.debug("Cannot load annotation injection processor", exception);
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:24,代码来源:OsgiAnnotationPostProcessor.java

示例2: instantiate

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
@Override
public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner,
		final Constructor<?> ctor, Object[] args) {

	if (beanDefinition.getMethodOverrides().isEmpty()) {
		if (System.getSecurityManager() != null) {
			// use own privileged to change accessibility (when security is on)
			AccessController.doPrivileged(new PrivilegedAction<Object>() {
				@Override
				public Object run() {
					ReflectionUtils.makeAccessible(ctor);
					return null;
				}
			});
		}
		return BeanUtils.instantiateClass(ctor, args);
	}
	else {
		return instantiateWithMethodInjection(beanDefinition, beanName, owner, ctor, args);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:SimpleInstantiationStrategy.java

示例3: matches

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
public static boolean matches(ConditionContext context) {
	Class<AuthorizationServerEndpointsConfigurationBeanCondition> type = AuthorizationServerEndpointsConfigurationBeanCondition.class;
	Conditional conditional = AnnotationUtils.findAnnotation(type,
			Conditional.class);
	StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(type);
	for (Class<? extends Condition> conditionType : conditional.value()) {
		Condition condition = BeanUtils.instantiateClass(conditionType);
		if (condition.matches(context, metadata)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:14,代码来源:OAuth2ResourceServerConfiguration.java

示例4: buildView

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
/**
 * Uses the viewName and the theme associated with the service.
 * being requested and returns the appropriate view.
 * @param viewName the name of the view to be resolved
 * @return a theme-based UrlBasedView
 * @throws Exception an exception
 */
@Override
protected AbstractUrlBasedView buildView(final String viewName) throws Exception {
    final RequestContext requestContext = RequestContextHolder.getRequestContext();
    final WebApplicationService service = WebUtils.getService(requestContext);
    final RegisteredService registeredService = this.servicesManager.findServiceBy(service);

    final String themeId = service != null && registeredService != null
            && registeredService.getAccessStrategy().isServiceAccessAllowed()
            && StringUtils.hasText(registeredService.getTheme()) ? registeredService.getTheme() : defaultThemeId;

    final String themePrefix = String.format("%s/%s/ui/", pathPrefix, themeId);
    LOGGER.debug("Prefix {} set for service {} with theme {}", themePrefix, service, themeId);

    //Build up the view like the base classes do, but we need to forcefully set the prefix for each request.
    //From UrlBasedViewResolver.buildView
    final InternalResourceView view = (InternalResourceView) BeanUtils.instantiateClass(getViewClass());
    view.setUrl(themePrefix + viewName + getSuffix());
    final String contentType = getContentType();
    if (contentType != null) {
        view.setContentType(contentType);
    }
    view.setRequestContextAttribute(getRequestContextAttribute());
    view.setAttributesMap(getAttributesMap());

    //From InternalResourceViewResolver.buildView
    view.setAlwaysInclude(false);
    view.setExposeContextBeansAsAttributes(false);
    view.setPreventDispatchLoop(true);

    LOGGER.debug("View resolved: {}", view.getUrl());

    return view;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:41,代码来源:RegisteredServiceThemeBasedViewResolver.java

示例5: createWebApplicationContext

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
protected WebApplicationContext createWebApplicationContext(ServletContext sc, ApplicationContext parent)
{
	GenericWebApplicationContext wac = (GenericWebApplicationContext) BeanUtils.instantiateClass(GenericWebApplicationContext.class);

	// Assign the best possible id value.
	wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + contextPath);

	wac.setParent(parent);
	wac.setServletContext(sc);
	wac.refresh();

	return wac;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:14,代码来源:AbstractJettyComponent.java

示例6: createServiceLocatorException

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
/**
 * Create a service locator exception for the given cause.
 * Only called in case of a custom service locator exception.
 * <p>The default implementation can handle all variations of
 * message and exception arguments.
 * @param exceptionConstructor the constructor to use
 * @param cause the cause of the service lookup failure
 * @return the service locator exception to throw
 * @see #setServiceLocatorExceptionClass
 */
protected Exception createServiceLocatorException(Constructor<Exception> exceptionConstructor, BeansException cause) {
	Class<?>[] paramTypes = exceptionConstructor.getParameterTypes();
	Object[] args = new Object[paramTypes.length];
	for (int i = 0; i < paramTypes.length; i++) {
		if (paramTypes[i].equals(String.class)) {
			args[i] = cause.getMessage();
		}
		else if (paramTypes[i].isInstance(cause)) {
			args[i] = cause;
		}
	}
	return BeanUtils.instantiateClass(exceptionConstructor, args);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:ServiceLocatorFactoryBean.java

示例7: createInstance

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected Set<Object> createInstance() {
	if (this.sourceSet == null) {
		throw new IllegalArgumentException("'sourceSet' is required");
	}
	Set<Object> result = null;
	if (this.targetSetClass != null) {
		result = BeanUtils.instantiateClass(this.targetSetClass);
	}
	else {
		result = new LinkedHashSet<Object>(this.sourceSet.size());
	}
	Class<?> valueType = null;
	if (this.targetSetClass != null) {
		valueType = GenericCollectionTypeResolver.getCollectionType(this.targetSetClass);
	}
	if (valueType != null) {
		TypeConverter converter = getBeanTypeConverter();
		for (Object elem : this.sourceSet) {
			result.add(converter.convertIfNecessary(elem, valueType));
		}
	}
	else {
		result.addAll(this.sourceSet);
	}
	return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:SetFactoryBean.java

示例8: resolve

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
/**
 * 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);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:DefaultNamespaceHandlerResolver.java

示例9: createInstance

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
@Override
public T createInstance() {
    return BeanUtils.instantiateClass(mappedClass);
}
 
开发者ID:cybozu,项目名称:spring-data-jdbc-template,代码行数:5,代码来源:AbstractEntityMapper.java

示例10: createListener

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
@Override
public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException {
    return BeanUtils.instantiateClass(clazz);
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:5,代码来源:AsyncContextImpl.java

示例11: buildView

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
/**
 * Uses the viewName and the theme associated with the service.
 * being requested and returns the appropriate view.
 *
 * @param viewName the name of the view to be resolved
 * @return a theme-based UrlBasedView
 * @throws Exception an exception
 */
@Override
protected AbstractUrlBasedView buildView(final String viewName) throws Exception {
    final RequestContext requestContext = RequestContextHolder.getRequestContext();
    final WebApplicationService service = WebUtils.getService(requestContext);
    final RegisteredService registeredService = this.servicesManager.findServiceBy(service);

    final InternalResourceView view = (InternalResourceView) BeanUtils.instantiateClass(getViewClass());

    final String defaultThemePrefix = String.format(THEME_LOCATION_PATTERN, getPrefix(), "default");
    final String defaultViewUrl = defaultThemePrefix + viewName + getSuffix();
    view.setUrl(defaultViewUrl);

    if (service != null && registeredService != null
        && registeredService.getAccessStrategy().isServiceAccessAllowed()
        && StringUtils.hasText(registeredService.getTheme())) {

        LOGGER.debug("Attempting to locate views for service [{}] with theme [{}]",
            registeredService.getServiceId(), registeredService.getTheme());

        final String themePrefix = String.format(THEME_LOCATION_PATTERN, getPrefix(), registeredService.getTheme());
        LOGGER.debug("Prefix [{}] set for service [{}] with theme [{}]", themePrefix, service,
            registeredService.getTheme());
        final String viewUrl = themePrefix + viewName + getSuffix();
        view.setUrl(viewUrl);

    }

    final String contentType = getContentType();
    if (contentType != null) {
        view.setContentType(contentType);
    }
    view.setRequestContextAttribute(getRequestContextAttribute());
    view.setAttributesMap(getAttributesMap());

    //From InternalResourceViewResolver.buildView
    view.setAlwaysInclude(false);
    view.setExposeContextBeansAsAttributes(false);
    view.setPreventDispatchLoop(true);

    LOGGER.debug("View resolved: {}", view.getUrl());

    return view;
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:52,代码来源:RegisteredServiceThemeBasedViewResolver.java

示例12: autoSchedulerFactory

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
@Bean(name = QUARTZ_SCHEDULER_FACTORY_BEAN_NAME)
@ConditionalOnMissingBean(name = QUARTZ_SCHEDULER_FACTORY_BEAN_NAME)
public SchedulerFactoryBean autoSchedulerFactory(ApplicationContext applicationContext, JobFactory jobFactory,
		QuartzSchedulerProperties properties, @Qualifier(QUARTZ_PROPERTIES_BEAN_NAME) Properties quartzProperties) {
	
	LOGGER.debug("creating SchedulerFactory");
	
	SchedulerFactoryBean factory = BeanUtils.instantiateClass(SchedulerFactoryBean.class);
	
       factory.setApplicationContext(applicationContext);
       factory.setJobFactory(jobFactory);
       
       Persistence persistenceSettings = properties.getPersistence();
       if (persistenceSettings.isPersisted()) {
       	factory.setDataSource(getDataSource(applicationContext, persistenceSettings));
       	if (persistenceSettings.isUsePlatformTxManager()) {
       		PlatformTransactionManager txManager = getTransactionManager(applicationContext);
           	if (null != txManager) {
               	factory.setTransactionManager(txManager);
               }
       	}
       }
       
       SchedulerFactory factorySettings = properties.getSchedulerFactory();
       factory.setSchedulerName(factorySettings.getSchedulerName());
       factory.setPhase(factorySettings.getPhase());
       factory.setStartupDelay(factorySettings.getStartupDelay());
       factory.setAutoStartup(factorySettings.isAutoStartup());
       factory.setWaitForJobsToCompleteOnShutdown(factorySettings.isWaitForJobsToCompleteOnShutdown());
       factory.setOverwriteExistingJobs(factorySettings.isOverwriteExistingJobs());
       factory.setExposeSchedulerInRepository(factorySettings.isExposeSchedulerInRepository());
       
       factory.setQuartzProperties(quartzProperties);
       
       Collection<Trigger> triggers = getTriggers(applicationContext);
       if (null != triggers && !triggers.isEmpty()) {
       	factory.setTriggers(triggers.toArray(new Trigger[triggers.size()]));
       	LOGGER.info("staring scheduler factory with " + triggers.size() + " job triggers");
       } else {
       	LOGGER.info("staring scheduler factory with 0 job triggers");
       }
       
       QuartzSchedulerFactoryOverrideHook hook = getQuartzSchedulerFactoryOverrideHook(applicationContext);
       if (null != hook) {
       	factory = hook.override(factory, properties, quartzProperties);
       }
       
	return factory;
}
 
开发者ID:andrehertwig,项目名称:spring-boot-starter-quartz,代码行数:50,代码来源:QuartzSchedulerAutoConfiguration.java

示例13: start

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
public BundleContext start() {
	framework = BeanUtils.instantiateClass(CONSTRUCTOR, monitor);
	ReflectionUtils.invokeMethod(LAUNCH, framework, 0);
	return (BundleContext) ReflectionUtils.invokeMethod(GET_BUNDLE_CONTEXT, framework);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:6,代码来源:KnopflerfishPlatform.java

示例14: createAnswerInstance

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
private Answer createAnswerInstance() {
	return BeanUtils.instantiateClass(answerClass);
}
 
开发者ID:pchudzik,项目名称:springmock,代码行数:4,代码来源:DefaultAnswerMockSettings.java

示例15: getCondition

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
private Condition getCondition(String conditionClassName, ClassLoader classloader) {
	Class<?> conditionClass = ClassUtils.resolveClassName(conditionClassName, classloader);
	return (Condition) BeanUtils.instantiateClass(conditionClass);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:ConditionEvaluator.java


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