List of usage examples for org.springframework.beans.factory BeanCreationException BeanCreationException
public BeanCreationException(String msg)
From source file:cf.spring.servicebroker.AccessorUtils.java
/** * Finds a method annotated with the specified annotation. This method can * be defined in the specified class, or one of its parents. * * @return the matching method, or <tt>null</tt> if any */// w w w. j a va 2s. co m public static <T extends Annotation> Method findMethodWithAnnotation(Class<?> clazz, Class<T> annotationType) { Method annotatedMethod = null; for (Method method : clazz.getDeclaredMethods()) { T annotation = AnnotationUtils.findAnnotation(method, annotationType); if (annotation != null) { if (annotatedMethod != null) { throw new BeanCreationException("Only ONE method with @" + annotationType.getName() + " is allowed on " + clazz.getName() + "."); } annotatedMethod = method; } } if ((annotatedMethod != null) || clazz.equals(Object.class)) { return annotatedMethod; } else { return findMethodWithAnnotation(clazz.getSuperclass(), annotationType); } }
From source file:org.jboss.seam.spring.factorybean.NamedCdiBeanLookup.java
@Override public Object lookupBean(BeanManager beanManager) { Bean<Object> resolvedBean = (Bean<Object>) beanManager.resolve(beanManager.getBeans(name)); if (resolvedBean != null) { return resolvedBean.create(beanManager.createCreationalContext(resolvedBean)); } else {/* w w w . ja va 2 s .co m*/ throw new BeanCreationException("No bean named " + name + " can be found"); } }
From source file:net.javacrumbs.springws.test.util.MockMessageSenderInjector.java
@SuppressWarnings("unchecked") public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { Collection<WebServiceTemplate> templates = beanFactory.getBeansOfType(WebServiceTemplate.class).values(); if (templates.size() == 0) { throw new BeanCreationException("No WebServiceTemplate found in the servlet context."); }// ww w .j ava2 s .c o m Collection<AbstractMockWebServiceMessageSender> mockSenders = beanFactory .getBeansOfType(AbstractMockWebServiceMessageSender.class).values(); WebServiceMessageSender[] mockSenderArray = mockSenders .toArray(new WebServiceMessageSender[mockSenders.size()]); for (WebServiceTemplate template : templates) { template.setMessageSenders(mockSenderArray); } }
From source file:orz.neptune.prospring3.ch8.JdbcContactDao.java
public void afterPropertiesSet() throws Exception { if (dataSource == null) { throw new BeanCreationException("Must set dataSource on ContactDao"); }// ww w .j av a 2 s . com }
From source file:cf.spring.servicebroker.AccessorUtils.java
/** * Validates that the method annotated with the specified annotation returns * the expected type.//from ww w .j a v a2 s .c om */ public static void validateReturnType(Method method, Class<? extends Annotation> annotationType, Class<?> expectedReturnType) { if (!method.getReturnType().equals(expectedReturnType)) { throw new BeanCreationException("Method " + method.getName() + " annotated with @" + annotationType.getName() + " must have a return type of " + expectedReturnType.getName()); } }
From source file:cf.spring.servicebroker.ServiceBrokerMethods.java
private void validateProvisionMethod(Method provisionMethod) { if (provisionMethod == null) { throw new BeanCreationException("A bean with @" + ServiceBroker.class.getName() + " must have method with @" + Provision.class.getName()); }//from w w w. jav a 2 s. c o m validateReturnType(provisionMethod, Provision.class, ProvisionResponse.class); validateArgument(provisionMethod, Provision.class, ProvisionRequest.class); }
From source file:org.jasig.portlet.announcements.mvc.servlet.ApproveAjaxController.java
public void afterPropertiesSet() throws Exception { if (cacheManager == null) { throw new BeanCreationException("Required cacheManager field was not set"); }//from w w w . j av a2 s . c o m }
From source file:org.trustedanalytics.metadata.parser.AuthenticationDisabler.java
@Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { final String AUTHENTICATION_BEAN_TO_REPLACE = "OAuth2AuthenticationProcessingFilter"; if (beanName.contains(AUTHENTICATION_BEAN_TO_REPLACE)) { OAuth2AuthenticationProcessingFilter authenticationMock = mock( OAuth2AuthenticationProcessingFilter.class); try {/*from w ww .j a va 2s . c o m*/ Mockito.doAnswer(this::authenticateEverything).when(authenticationMock).doFilter(any(), any(), any()); } catch (IOException | ServletException e) { e.printStackTrace(); throw new BeanCreationException(String.format("Cannot mock '%s'", AUTHENTICATION_BEAN_TO_REPLACE)); } return authenticationMock; } return bean; }
From source file:edu.internet2.middleware.shibboleth.common.config.attribute.encoding.SAML1Base64AttributeEncoderBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { super.doParse(element, parserContext, builder); String namespace = "urn:mace:shibboleth:1.0:attributeNamespace:uri"; if (element.hasAttributeNS(null, "namespace")) { namespace = DatatypeHelper.safeTrimOrNullString(element.getAttributeNS(null, "namespace")); }//from w w w. ja va 2s .c o m builder.addPropertyValue("namespace", namespace); String attributeName = DatatypeHelper.safeTrimOrNullString(element.getAttributeNS(null, "name")); if (attributeName == null) { throw new BeanCreationException("SAML 1 attribute encoders must contain a name"); } }
From source file:org.apache.cxf.fediz.spring.FederationConfigImpl.java
public void init() { Assert.notNull(this.configFile, "property 'configFile' mandatory"); try {/*from w w w .ja v a2s . c o m*/ configurator.loadConfig(this.configFile.getFile()); } catch (Exception e) { LOG.error("Failed to parse '" + configFile.getDescription() + "'", e); throw new BeanCreationException("Failed to parse '" + configFile.getDescription() + "'"); } }