/** * Return if there are method overrides defined for this bean. * @since 5.0.2 */ public boolean hasMethodOverrides() { return (this.methodOverrides != null && !this.methodOverrides.isEmpty()); }
/** * Return if there are method overrides defined for this bean. * @since 5.0.2 */ public boolean hasMethodOverrides() { return (this.methodOverrides != null && !this.methodOverrides.isEmpty()); }
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>() { public Object run() { ReflectionUtils.makeAccessible(ctor); return null; } }); } return BeanUtils.instantiateClass(ctor, args); } else { return instantiateWithMethodInjection(beanDefinition, beanName, owner, ctor, args); } }
/** * Validate and prepare the method overrides defined for this bean. * Checks for existence of a method with the specified name. * @throws BeanDefinitionValidationException in case of validation failure */ public void prepareMethodOverrides() throws BeanDefinitionValidationException { // Check that lookup methods exists. MethodOverrides methodOverrides = getMethodOverrides(); if (!methodOverrides.isEmpty()) { for (MethodOverride mo : methodOverrides.getOverrides()) { prepareMethodOverride(mo); } } }
public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) { if (beanDefinition.getMethodOverrides().isEmpty()) { Constructor<?> constructorToUse; synchronized (beanDefinition.constructorArgumentLock) {
/** * Validate this bean definition. * @throws BeanDefinitionValidationException in case of validation failure */ public void validate() throws BeanDefinitionValidationException { if (!getMethodOverrides().isEmpty() && getFactoryMethodName() != null) { throw new BeanDefinitionValidationException( "Cannot combine static factory method with method overrides: " + "the static factory method must create the instance"); } if (hasBeanClass()) { prepareMethodOverrides(); } }
public Object instantiate( RootBeanDefinition beanDefinition, String beanName, BeanFactory owner, Constructor ctor, Object[] args) { if (beanDefinition.getMethodOverrides().isEmpty()) { return BeanUtils.instantiateClass(ctor, args); } else { return instantiateWithMethodInjection(beanDefinition, beanName, owner, ctor, args); } }
public Object instantiate( RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) { // Don't override the class with CGLIB if no overrides. if (beanDefinition.getMethodOverrides().isEmpty()) { return BeanUtils.instantiateClass(beanDefinition.getBeanClass()); } else { // Must generate CGLIB subclass. return instantiateWithMethodInjection(beanDefinition, beanName, owner); } }
public Object instantiate( RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) { // Don't override the class with CGLIB if no overrides. if (beanDefinition.getMethodOverrides().isEmpty()) { Class clazz = beanDefinition.getBeanClass(); if (clazz.isInterface()) { throw new BeanInstantiationException(clazz, "Specified class is an interface"); } try { Constructor constructor = clazz.getDeclaredConstructor((Class[]) null); return BeanUtils.instantiateClass(constructor, null); } catch (Exception ex) { throw new BeanInstantiationException(clazz, "No default constructor found", ex); } } else { // Must generate CGLIB subclass. return instantiateWithMethodInjection(beanDefinition, beanName, owner); } } }
/** * Validate this bean definition. * @throws BeanDefinitionValidationException in case of validation failure */ public void validate() throws BeanDefinitionValidationException { if (this.lazyInit && !this.singleton) { throw new BeanDefinitionValidationException( "Lazy initialization is only applicable to singleton beans"); } if (!getMethodOverrides().isEmpty() && getFactoryMethodName() != null) { throw new BeanDefinitionValidationException( "Cannot combine static factory method with method overrides: " + "the static factory method must create the instance"); } if (hasBeanClass()) { // Check that lookup methods exists for (Iterator it = getMethodOverrides().getOverrides().iterator(); it.hasNext(); ) { MethodOverride mo = (MethodOverride) it.next(); validateMethodOverride(mo); } } }