List of usage examples for org.springframework.beans.factory BeanFactory getType
@Nullable
Class<?> getType(String name) throws NoSuchBeanDefinitionException;
From source file:io.neba.core.selftests.SelftestRegistrar.java
/** * A bean may be the representation of an OSGi service provided by a * different bundle - in this case we must not check it for selftests, as * this is done in the service's source bundle. *//*from ww w . jav a 2 s. co m*/ private boolean isOsgiServiceReference(BeanFactory factory, String beanName) { Class<?> beanType = factory.getType(beanName); return beanType != null && ImportedOsgiServiceProxy.class.isAssignableFrom(beanType); }
From source file:com.foreveross.modules.jsf.SpringBeanELResolver.java
@Override public Class<?> getType(ELContext elContext, Object base, Object property) throws ELException { if (base == null) { String beanName = property.toString(); BeanFactory bf = getBeanFactory(elContext); if (bf.containsBean(beanName)) { elContext.setPropertyResolved(true); return bf.getType(beanName); }// w w w. j av a 2s .c o m } return null; }
From source file:de.itsvs.cwtrpc.controller.AutowiredRemoteServiceGroupConfigTest.java
protected boolean containsServiceConfig(BeanFactory beanFactory, Collection<RemoteServiceConfig> serviceConfigs, Class<?> serviceClass) { for (RemoteServiceConfig serviceConfig : serviceConfigs) { if (serviceClass.equals(beanFactory.getType(serviceConfig.getServiceName()))) { Assert.assertNull(serviceConfig.getResponseCompressionEnabled()); Assert.assertNull(serviceConfig.getRpcTokenProtectionEnabled()); Assert.assertNull(serviceConfig.getRpcTokenValidatorName()); Assert.assertNull(serviceConfig.getServiceInterface()); Assert.assertNull(serviceConfig.getRelativePath()); return true; }//w w w.j a v a 2s . co m } return false; }
From source file:io.neba.core.util.OsgiBeanSource.java
/** * @param beanName must not be <code>null</code>. * @param factory must not be <code>null</code>. *//* ww w .j a v a 2 s . c om*/ public OsgiBeanSource(String beanName, BeanFactory factory, Bundle bundle) { if (beanName == null) { throw new IllegalArgumentException("Method argument beanName must not be null."); } if (factory == null) { throw new IllegalArgumentException("Method argument factory must not be null."); } if (bundle == null) { throw new IllegalArgumentException("Method argument bundle must not be null."); } this.beanName = beanName; this.factory = factory; this.bundleId = bundle.getBundleId(); this.bundle = bundle; // Referencing the bean type is safe: It either stems from the source bundle, or a bundle the source bundle depends on // via an import-package relationship. Thus, if the type changes, the source bundle is re-loaded as well thus // causing this bean source to be re-created. this.beanType = factory.getType(beanName); this.hashCode = new HashCodeBuilder().append(beanName).append(bundleId).toHashCode(); }
From source file:org.kuali.rice.test.CompositeBeanFactory.java
@Override public Class<?> getType(String name) throws NoSuchBeanDefinitionException { for (BeanFactory f : factories) { try {// w ww . j ava2 s .c o m Class<?> c = f.getType(name); if (c != null) { return c; } } catch (BeansException e) { LOG.info("bean exception", e); } } return null; }
From source file:org.springframework.context.support.DefaultLifecycleProcessor.java
private boolean matchesBeanType(Class<?> targetType, String beanName, BeanFactory beanFactory) { Class<?> beanType = beanFactory.getType(beanName); return (beanType != null && targetType.isAssignableFrom(beanType)); }
From source file:org.springframework.messaging.handler.HandlerMethod.java
/** * Create an instance from a bean name, a method, and a {@code BeanFactory}. * The method {@link #createWithResolvedBean()} may be used later to * re-create the {@code HandlerMethod} with an initialized bean. *//* w w w .jav a 2 s . c o m*/ public HandlerMethod(String beanName, BeanFactory beanFactory, Method method) { Assert.hasText(beanName, "Bean name is required"); Assert.notNull(beanFactory, "BeanFactory is required"); Assert.notNull(method, "Method is required"); this.bean = beanName; this.beanFactory = beanFactory; Class<?> beanType = beanFactory.getType(beanName); if (beanType == null) { throw new IllegalStateException("Cannot resolve bean type for bean with name '" + beanName + "'"); } this.beanType = ClassUtils.getUserClass(beanType); this.method = method; this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method); this.parameters = initMethodParameters(); }
From source file:org.springframework.web.jsf.el.SpringBeanFacesELResolver.java
public Class<?> getType(ELContext elContext, Object base, Object property) throws ELException { if (base == null) { // Ask Spring root application context. String name = property.toString(); if (logger.isDebugEnabled()) { logger.debug("Attempting to resolve variable '" + name + "' in root WebApplicationContext"); }//from w w w. jav a 2 s . co m BeanFactory bf = getBeanFactory(elContext); if (bf.containsBean(name)) { if (logger.isDebugEnabled()) { logger.debug("Successfully resolved variable '" + name + "' in root WebApplicationContext"); } elContext.setPropertyResolved(true); return bf.getType(name); } } return null; }
From source file:org.springframework.web.method.HandlerMethod.java
/** * Create an instance from a bean name, a method, and a {@code BeanFactory}. * The method {@link #createWithResolvedBean()} may be used later to * re-create the {@code HandlerMethod} with an initialized bean. *///from ww w .j a v a 2 s . c o m public HandlerMethod(String beanName, BeanFactory beanFactory, Method method) { Assert.hasText(beanName, "Bean name is required"); Assert.notNull(beanFactory, "BeanFactory is required"); Assert.notNull(method, "Method is required"); this.bean = beanName; this.beanFactory = beanFactory; Class<?> beanType = beanFactory.getType(beanName); if (beanType == null) { throw new IllegalStateException("Cannot resolve bean type for bean with name '" + beanName + "'"); } this.beanType = ClassUtils.getUserClass(beanType); this.method = method; this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method); this.parameters = initMethodParameters(); evaluateResponseStatus(); }