private void checkNoArgsConstructor(EnhancedAnnotatedType<T> type) { if (!beanManager.getServices().get(ProxyInstantiator.class).isUsingConstructor()) { return; } EnhancedAnnotatedConstructor<T> constructor = type.getNoArgsEnhancedConstructor(); if (constructor == null) { throw BeanLogger.LOG.decoratedHasNoNoargsConstructor(this); } else if (constructor.isPrivate()) { throw BeanLogger.LOG .decoratedNoargsConstructorIsPrivate(this, Formats.formatAsStackTraceElement(constructor.getJavaMember())); } }
@Override public T run() { try { Class<T> proxyClass = getProxyClass(); boolean hasConstrutedField = SecurityActions.hasDeclaredField(proxyClass, CONSTRUCTED_FLAG_NAME); if (hasConstrutedField != useConstructedFlag()) { // The proxy class was created with a different type of ProxyInstantiator ProxyInstantiator newInstantiator = ProxyInstantiator.Factory.create(!hasConstrutedField); BeanLogger.LOG.creatingProxyInstanceUsingDifferentInstantiator(proxyClass, newInstantiator, proxyInstantiator); return newInstantiator.newInstance(proxyClass); } return proxyInstantiator.newInstance(proxyClass); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
Method finalMethod = Reflections.getNonPrivateNonStaticFinalMethod(clazz); if (finalMethod != null) { if (services.get(WeldConfiguration.class).isFinalMethodIgnored(clazz.getName())) { ValidatorLogger.LOG.notProxyableFinalMethodIgnored(finalMethod, getDeclaringBeanInfo(declaringBean)); } else { UnproxyableResolutionException exception = services.get(ProxyInstantiator.class).validateNoargConstructor(constructor, clazz, declaringBean); if (exception != null) { return exception;
@Override public T run() { try { return instantiator.newInstance(proxyClassForDecorator); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
/** * @return {@code true} if {@link #CONSTRUCTED_FLAG_NAME} should be used */ private boolean useConstructedFlag() { return !isUsingProxyInstantiator() || proxyInstantiator.isUsingConstructor(); }
@Override public T run() { try { Class<T> proxyClass = getProxyClass(); boolean hasConstrutedField = SecurityActions.hasDeclaredField(proxyClass, CONSTRUCTED_FLAG_NAME); if (hasConstrutedField != useConstructedFlag()) { // The proxy class was created with a different type of ProxyInstantiator ProxyInstantiator newInstantiator = ProxyInstantiator.Factory.create(!hasConstrutedField); BeanLogger.LOG.creatingProxyInstanceUsingDifferentInstantiator(proxyClass, newInstantiator, proxyInstantiator); return newInstantiator.newInstance(proxyClass); } return proxyInstantiator.newInstance(proxyClass); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
if (finalMethod != null) { if (ignoreFinalMethods || Beans.shouldIgnoreFinalMethods(declaringBean) || services.get(WeldConfiguration.class).isFinalMethodIgnored(clazz.getName())) { ValidatorLogger.LOG.notProxyableFinalMethodIgnored(finalMethod, getDeclaringBeanInfo(declaringBean)); } else { UnproxyableResolutionException exception = services.get(ProxyInstantiator.class).validateNoargConstructor(constructor, clazz, declaringBean); if (exception != null) { return exception;
@Override public T run() { try { return instantiator.newInstance(proxyClassForDecorator); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
/** * @return {@code true} if {@link #CONSTRUCTED_FLAG_NAME} should be used */ private boolean useConstructedFlag() { return !isUsingProxyInstantiator() || proxyInstantiator.isUsingConstructor(); }
protected void checkNoArgsConstructor(EnhancedAnnotatedType<T> type) { EnhancedAnnotatedConstructor<T> constructor = type.getNoArgsEnhancedConstructor(); if (constructor == null) { if (!beanManager.getServices().get(ProxyInstantiator.class).isUsingConstructor()) { // Relaxed construction allows us to bypass non-existent no-arg constructor return; } else { // Without relaxed contruction, CDI enforces existence of no-arg constructor throw BeanLogger.LOG.decoratedHasNoNoargsConstructor(this); } } else { if (constructor.isPrivate()) { // Private no-arg constructor is a problem while creating the decorator and we have to blow up throw BeanLogger.LOG.decoratedNoargsConstructorIsPrivate(this, Formats.formatAsStackTraceElement(constructor.getJavaMember())); } } }
@Override public T run() { try { Class<T> proxyClass = getProxyClass(); boolean hasConstrutedField = SecurityActions.hasDeclaredField(proxyClass, CONSTRUCTED_FLAG_NAME); if (hasConstrutedField != useConstructedFlag()) { // The proxy class was created with a different type of ProxyInstantiator ProxyInstantiator newInstantiator = ProxyInstantiator.Factory.create(!hasConstrutedField); BeanLogger.LOG.creatingProxyInstanceUsingDifferentInstantiator(proxyClass, newInstantiator, proxyInstantiator); return newInstantiator.newInstance(proxyClass); } return proxyInstantiator.newInstance(proxyClass); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
if (finalMethod != null) { if (ignoreFinalMethods || Beans.shouldIgnoreFinalMethods(declaringBean) || services.get(WeldConfiguration.class).isFinalMethodIgnored(clazz.getName())) { ValidatorLogger.LOG.notProxyableFinalMethodIgnored(finalMethod, getDeclaringBeanInfo(declaringBean)); } else { UnproxyableResolutionException exception = services.get(ProxyInstantiator.class).validateNoargConstructor(constructor, clazz, declaringBean); if (exception != null) { return exception;
@Override public T run() { try { return instantiator.newInstance(proxyClassForDecorator); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
/** * @return {@code true} if {@link #CONSTRUCTED_FLAG_NAME} should be used */ private boolean useConstructedFlag() { return !isUsingProxyInstantiator() || proxyInstantiator.isUsingConstructor(); }
protected void checkNoArgsConstructor(EnhancedAnnotatedType<T> type) { EnhancedAnnotatedConstructor<T> constructor = type.getNoArgsEnhancedConstructor(); if (constructor == null) { if (!beanManager.getServices().get(ProxyInstantiator.class).isUsingConstructor()) { // Relaxed construction allows us to bypass non-existent no-arg constructor return; } else { // Without relaxed contruction, CDI enforces existence of no-arg constructor throw BeanLogger.LOG.decoratedHasNoNoargsConstructor(this); } } else { if (constructor.isPrivate()) { // Private no-arg constructor is a problem while creating the decorator and we have to blow up throw BeanLogger.LOG.decoratedNoargsConstructorIsPrivate(this, Formats.formatAsStackTraceElement(constructor.getJavaMember())); } } }
@Override public T run() { try { Class<T> proxyClass = getProxyClass(); boolean hasConstrutedField = SecurityActions.hasDeclaredField(proxyClass, CONSTRUCTED_FLAG_NAME); if (hasConstrutedField != useConstructedFlag()) { // The proxy class was created with a different type of ProxyInstantiator ProxyInstantiator newInstantiator = ProxyInstantiator.Factory.create(!hasConstrutedField); BeanLogger.LOG.creatingProxyInstanceUsingDifferentInstantiator(proxyClass, newInstantiator, proxyInstantiator); return newInstantiator.newInstance(proxyClass); } return proxyInstantiator.newInstance(proxyClass); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
if (finalMethod != null) { if (ignoreFinalMethods || Beans.shouldIgnoreFinalMethods(declaringBean) || services.get(WeldConfiguration.class).isFinalMethodIgnored(clazz.getName())) { ValidatorLogger.LOG.notProxyableFinalMethodIgnored(finalMethod, getDeclaringBeanInfo(declaringBean)); } else { UnproxyableResolutionException exception = services.get(ProxyInstantiator.class).validateNoargConstructor(constructor, clazz, declaringBean); if (exception != null) { return exception;
@Override public T run() { try { return instantiator.newInstance(proxyClassForDecorator); } catch (InstantiationException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationFailed(this), e.getCause()); } catch (IllegalAccessException e) { throw new DefinitionException(BeanLogger.LOG.proxyInstantiationBeanAccessFailed(this), e.getCause()); } }
/** * @return {@code true} if {@link #CONSTRUCTED_FLAG_NAME} should be used */ private boolean useConstructedFlag() { return !isUsingProxyInstantiator() || proxyInstantiator.isUsingConstructor(); }
protected void checkNoArgsConstructor(EnhancedAnnotatedType<T> type) { EnhancedAnnotatedConstructor<T> constructor = type.getNoArgsEnhancedConstructor(); if (constructor == null) { if (!beanManager.getServices().get(ProxyInstantiator.class).isUsingConstructor()) { // Relaxed construction allows us to bypass non-existent no-arg constructor return; } else { // Without relaxed contruction, CDI enforces existence of no-arg constructor throw BeanLogger.LOG.decoratedHasNoNoargsConstructor(this); } } else { if (constructor.isPrivate()) { // Private no-arg constructor is a problem while creating the decorator and we have to blow up throw BeanLogger.LOG.decoratedNoargsConstructorIsPrivate(this, Formats.formatAsStackTraceElement(constructor.getJavaMember())); } } }