List of usage examples for org.springframework.beans.factory ListableBeanFactory getType
@Nullable
Class<?> getType(String name) throws NoSuchBeanDefinitionException;
From source file:com.google.inject.spring.SpringIntegration.java
/** * Binds all Spring beans from the given factory by name. For a Spring bean * named "foo", this method creates a binding to the bean's type and * {@code @Named("foo")}./*from w w w. jav a 2 s . com*/ * * @see com.google.inject.name.Named * @see com.google.inject.name.Names#named(String) */ public static void bindAll(Binder binder, ListableBeanFactory beanFactory) { binder = binder.skipSources(SpringIntegration.class); for (String name : beanFactory.getBeanDefinitionNames()) { Class<?> type = beanFactory.getType(name); bindBean(binder, beanFactory, name, type); } }
From source file:de.itsvs.cwtrpc.controller.AutowiredRemoteServiceGroupConfig.java
public void afterPropertiesSet() { final Log log; final ListableBeanFactory beanFactory; final String[] beanNames; final List<RemoteServiceConfig> serviceConfigs; log = LogFactory.getLog(AutowiredRemoteServiceGroupConfig.class); log.debug("Searching for remote services"); beanFactory = getApplicationContext(); beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(beanFactory, RemoteService.class, true, false);/* w w w . j a va 2 s . com*/ if (beanNames.length == 0) { return; } serviceConfigs = new ArrayList<RemoteServiceConfig>(); for (String beanName : beanNames) { final Class<?> beanType; final Class<?> serviceInterface; beanType = beanFactory.getType(beanName); serviceInterface = getRemoteServiceInterface(beanType); if (serviceInterface != null) { if (serviceInterface.getAnnotation(RemoteServiceRelativePath.class) != null) { if (isAcceptedServiceInterface(serviceInterface)) { if (log.isDebugEnabled()) { log.debug("Adding service '" + beanName + "'"); } serviceConfigs.add(new RemoteServiceConfig(beanName)); } } else { if (log.isDebugEnabled()) { log.debug("Ignoring service '" + beanName + "' since service does not specify " + "remote service relative path"); } } } else { if (log.isInfoEnabled()) { log.info("Ignoring service '" + beanName + "' since it implements multiple " + "remote service interfaces"); } } } setServiceConfigs(serviceConfigs); }
From source file:ome.services.graphs.GraphEntry.java
/** * Load the spec which has the same name as this entry, but do not load the * spec if the name matches {@link #name}. This is called early in the * {@link GraphEntry} lifecycle, by {@link GraphSpec}. *//*from ww w . ja v a 2 s .c o m*/ protected void postProcess(ListableBeanFactory factory) { if (name.equals(self.getName())) { return; } else if (factory.containsBeanDefinition(name) && GraphSpec.class.isAssignableFrom(factory.getType(name))) { this.subSpec = factory.getBean(name, GraphSpec.class); this.subSpec.postProcess(factory); } }