org.springframework.context.ConfigurableApplicationContext.getType()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中org.springframework.context.ConfigurableApplicationContext.getType()方法的一些代码示例,展示了ConfigurableApplicationContext.getType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConfigurableApplicationContext.getType()方法的具体详情如下:
包路径:org.springframework.context.ConfigurableApplicationContext
类名称:ConfigurableApplicationContext
方法名:getType

ConfigurableApplicationContext.getType介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

for (EventListenerFactory factory : factories) {
  if (factory.supportsMethod(method)) {
    Method methodToUse = AopUtils.selectInvocableMethod(method, context.getType(beanName));
    ApplicationListener<?> applicationListener =
        factory.createApplicationListener(beanName, targetType, methodToUse);

代码示例来源:origin: org.springframework/spring-context

for (EventListenerFactory factory : factories) {
  if (factory.supportsMethod(method)) {
    Method methodToUse = AopUtils.selectInvocableMethod(method, context.getType(beanName));
    ApplicationListener<?> applicationListener =
        factory.createApplicationListener(beanName, targetType, methodToUse);

代码示例来源:origin: pentaho/pentaho-platform

/**
 * @see IPentahoObjectFactory#getImplementingClass(String)
 */
@SuppressWarnings( "unchecked" )
public Class getImplementingClass( String key ) {
 return beanFactory.getType( key );
}

代码示例来源:origin: NationalSecurityAgency/datawave

@Override
public Class<?> getType(String name) throws NoSuchBeanDefinitionException {
  lock.readLock().lock();
  try {
    return configurableApplicationContext.getType(name);
  } finally {
    lock.readLock().unlock();
  }
}

代码示例来源:origin: joinfaces/joinfaces

@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "getType() is always non-null when reached")
  private void warnAboutJsfManagedBeans(ConfigurableApplicationContext applicationContext, Class<? extends Annotation> managedBeanClass) {
    String[] managedBeanNames = applicationContext.getBeanNamesForAnnotation(managedBeanClass);

    for (String managedBeanName : managedBeanNames) {
      log.warn(
          "The spring bean '{}' of type '{}' is also annotated with '@javax.faces.bean.ManagedBean'. This may lead to unexpected behaviour.",
          managedBeanName,
          applicationContext.getType(managedBeanName).getName()
      );
    }
  }
}

代码示例来源:origin: spring-cloud/spring-cloud-stream-binder-kafka

@SuppressWarnings("unchecked")
private boolean isDeclarativeOutput(Method m, String targetBeanName) {
  boolean declarative;
  Class<?> returnType = m.getReturnType();
  if (returnType.isArray()) {
    Class<?> targetBeanClass = this.applicationContext.getType(targetBeanName);
    declarative = this.streamListenerResultAdapters.stream()
        .anyMatch((slpa) -> slpa.supports(returnType.getComponentType(), targetBeanClass));
    return declarative;
  }
  Class<?> targetBeanClass = this.applicationContext.getType(targetBeanName);
  declarative = this.streamListenerResultAdapters.stream()
      .anyMatch((slpa) -> slpa.supports(returnType, targetBeanClass));
  return declarative;
}

代码示例来源:origin: spring-cloud/spring-cloud-stream-binder-kafka

@SuppressWarnings("unchecked")
private boolean isDeclarativeInput(String targetBeanName, MethodParameter methodParameter) {
  if (!methodParameter.getParameterType().isAssignableFrom(Object.class) && this.applicationContext.containsBean(targetBeanName)) {
    Class<?> targetBeanClass = this.applicationContext.getType(targetBeanName);
    return this.streamListenerParameterAdapter.supports(targetBeanClass, methodParameter);
  }
  return false;
}

代码示例来源:origin: pentaho/pentaho-platform

protected Object instanceClass( Class<?> interfaceClass, String key ) throws ObjectFactoryException {
 Object object = null;
 try {
  if ( key != null ) {
   object = beanFactory.getType( key ).newInstance();
  } else {
   // No published beans by this type, try the interface simplename itself as the key (legacy behavior)
   object = beanFactory.getType( interfaceClass.getSimpleName() ).newInstance();
  }
 } catch ( Exception e ) {
  String msg =
    Messages.getInstance()
      .getString( "AbstractSpringPentahoObjectFactory.WARN_FAILED_TO_CREATE_OBJECT", key ); //$NON-NLS-1$
  throw new ObjectFactoryException( msg, e );
 }
 return object;
}

代码示例来源:origin: spring-cloud/spring-cloud-stream

/**
   * Determines if method parameters signify an imperative or declarative listener definition.
   * <br>
   * Imperative - where handler method is invoked on each message by the handler infrastructure provided
   * by the framework
   * <br>
   * Declarative - where handler  is provided by the method itself.
   * <br>
   * Declarative method parameter could either be {@link MessageChannel} or any other Object for which
   * there is a {@link StreamListenerParameterAdapter} (i.e., {@link reactor.core.publisher.Flux}). Declarative method is invoked only
   * once during initialization phase.
   */
  @SuppressWarnings("unchecked")
  private boolean isDeclarativeMethodParameter(String targetBeanName, MethodParameter methodParameter) {
    boolean declarative = false;
    if (!methodParameter.getParameterType().isAssignableFrom(Object.class) && this.applicationContext.containsBean(targetBeanName)) {
      declarative = MessageChannel.class.isAssignableFrom(methodParameter.getParameterType());
      if (!declarative) {
        Class<?> targetBeanClass = this.applicationContext.getType(targetBeanName);
        declarative = this.streamListenerParameterAdapters.stream()
            .anyMatch(slpa -> slpa.supports(targetBeanClass, methodParameter));
      }
    }
    return declarative;
  }
}

代码示例来源:origin: pentaho/pentaho-platform

protected Object instanceClass( String simpleName, String key ) throws ObjectFactoryException {
 Object object = null;
 try {
  if ( beanFactory.containsBean( simpleName ) ) {
   object = beanFactory.getType( simpleName ).newInstance();
  } else if ( key != null ) {
   object = beanFactory.getType( key ).newInstance();
  }
 } catch ( Exception e ) {
  String msg =
    Messages.getInstance()
      .getString( "AbstractSpringPentahoObjectFactory.WARN_FAILED_TO_CREATE_OBJECT", key ); //$NON-NLS-1$
  throw new ObjectFactoryException( msg, e );
 }
 return object;
}

代码示例来源:origin: org.testifyproject.di/di-spring

Object getQualifiedInstance(Annotation[] qualifiers, TypeToken token) {
  Object instance = null;
  Annotation annotation = qualifiers[0];
  Class<? extends Annotation> annotationType = annotation.annotationType();
  String[] beanNames = context.getBeanNamesForAnnotation(annotationType);
  for (String beanName : beanNames) {
    Class<?> beanType = context.getType(beanName);
    if (token.isSupertypeOf(beanType)) {
      instance = context.getBean(beanName, beanType);
      break;
    }
  }
  if (instance == null && NAME_QUALIFIER.contains(annotationType)) {
    instance = context.getBean((String) AnnotationUtils.getValue(annotation));
  }
  return instance;
}

代码示例来源:origin: com.sun.jersey.contribs/jersey-spring

private void registerSpringBeans(final ResourceConfig rc) {
  String[] names = BeanFactoryUtils.beanNamesIncludingAncestors(springContext);
  for (String name : names) {
    Class<?> type = ClassUtils.getUserClass(springContext.getType(name));
    if (ResourceConfig.isProviderClass(type)) {
      LOGGER.info("Registering Spring bean, " + name +
          ", of type " + type.getName() +
          " as a provider class");
      rc.getClasses().add(type);
    } else if (ResourceConfig.isRootResourceClass(type)) {
      LOGGER.info("Registering Spring bean, " + name +
          ", of type " + type.getName() +
          " as a root resource class");
      rc.getClasses().add(type);
    }
  }
}

代码示例来源:origin: dsyer/spring-boot-allocations

public void log(ConfigurableApplicationContext context) {
  int count = 0;
  String id = context.getId();
  List<String> names = new ArrayList<>();
  while (context != null) {
    count += context.getBeanDefinitionCount();
    names.addAll(Arrays.asList(context.getBeanDefinitionNames()));
    if (logger.isDebugEnabled()) {
      for (String name : context.getBeanDefinitionNames()) {
        Class<?> type = context.getType(name);
        if (AnnotationUtils.findAnnotation(type, Component.class)!=null) {
          logger.debug("Component: " + type);
        }
      }
    }
    context = (ConfigurableApplicationContext) context.getParent();
  }
  logger.info("Bean count: " + id + "=" + count);
  logger.debug("Bean names: " + id + "=" + names);
  try {
    logger.info("Class count: " + id + "=" + ManagementFactory
        .getClassLoadingMXBean().getTotalLoadedClassCount());
  }
  catch (Exception e) {
  }
}

代码示例来源:origin: apache/servicemix-bundles

for (EventListenerFactory factory : factories) {
  if (factory.supportsMethod(method)) {
    Method methodToUse = AopUtils.selectInvocableMethod(method, context.getType(beanName));
    ApplicationListener<?> applicationListener =
        factory.createApplicationListener(beanName, targetType, methodToUse);

相关文章

微信公众号

最新文章

更多

ConfigurableApplicationContext类方法