/** * Looks at whether the DefaultInstantiator resolving a valid constructor does not met this case: * - No constructor with @Inject annotation is defined * - NoArgs constructor is defined * - Instantiator ignores JAX-RS valid constructor with multiple params * * @param it injection target containing instantiator with resolved constructor. * @param clazz class which analyzed constructor belongs to. * @param <T> type of the analyzed class. * @return {@code true} if no-arg constructor was selected while multi-params constructor exists. */ private static <T> boolean isNoArgConstructorCase(BasicInjectionTarget<T> it, Class<T> clazz) { if (!(it instanceof NonProducibleInjectionTarget)) { Instantiator<T> instantiator = it.getInstantiator(); Constructor<T> constructor = instantiator.getConstructor(); return constructor.getParameterCount() == 0 && clazz.getConstructors().length > 1; } return false; }
@Override public T newInstance(CreationalContext<T> ctx, BeanManagerImpl manager) { if (ctx instanceof CreationalContextImpl<?>) { CreationalContextImpl<T> weldCtx = Reflections.cast(ctx); if (!weldCtx.isConstructorInterceptionSuppressed()) { registerAroundConstructCallback(weldCtx, manager); } } return delegate().newInstance(ctx, manager); }
@Override public void preDestroy(T instance, Instantiator<T> instantiator) { // this may be null for NonProducibleInjectionTarget if (instantiator != null && instantiator.hasInterceptorSupport()) { InterceptionUtils.executePredestroy(instance); } else { invokeMethods(accessiblePreDestroyMethods, instance); } }
@Override public void postConstruct(T instance, Instantiator<T> instantiator) { // this may be null for NonProducibleInjectionTarget if (instantiator != null && instantiator.hasInterceptorSupport()) { InterceptionUtils.executePostConstruct(instance); } else { invokeMethods(accessiblePostConstructMethods, instance); } }
@Override public Constructor<T> getConstructor() { return delegate().getConstructor(); } }
@Override public T newInstance(CreationalContext<T> ctx, BeanManagerImpl manager) { return delegate().newInstance(ctx, manager); }
@Override public boolean hasDecoratorSupport() { return delegate().hasDecoratorSupport(); }
@Override public boolean hasInterceptorSupport() { return delegate().hasInterceptorSupport(); }
@Override public T produce(CreationalContext<T> ctx) { return instantiator.newInstance(ctx, beanManager); }
public boolean hasDecorators() { return instantiator.hasDecoratorSupport(); }
public boolean hasInterceptors() { return instantiator.hasInterceptorSupport(); }
@Override public T newInstance(CreationalContext<T> ctx, BeanManagerImpl manager) { if (ctx instanceof CreationalContextImpl<?>) { CreationalContextImpl<T> weldCtx = Reflections.cast(ctx); if (!weldCtx.isConstructorInterceptionSuppressed()) { registerAroundConstructCallback(weldCtx, manager); } } return delegate().newInstance(ctx, manager); }
@Override public void preDestroy(T instance, Instantiator<T> instantiator) { // this may be null for NonProducibleInjectionTarget if (instantiator != null && instantiator.hasInterceptorSupport()) { InterceptionUtils.executePredestroy(instance); } else { invokeMethods(accessiblePreDestroyMethods, instance); } }
@Override public void postConstruct(T instance, Instantiator<T> instantiator) { // this may be null for NonProducibleInjectionTarget if (instantiator != null && instantiator.hasInterceptorSupport()) { InterceptionUtils.executePostConstruct(instance); } else { invokeMethods(accessiblePostConstructMethods, instance); } }
@Override public Constructor<T> getConstructor() { return delegate().getConstructor(); } }
@Override public T newInstance(CreationalContext<T> ctx, BeanManagerImpl manager) { return delegate().newInstance(ctx, manager); }
@Override public boolean hasDecoratorSupport() { return delegate().hasDecoratorSupport(); }
@Override public boolean hasInterceptorSupport() { return delegate().hasInterceptorSupport(); }
@Override public T produce(CreationalContext<T> ctx) { return instantiator.newInstance(ctx, beanManager); }
public boolean hasDecorators() { return instantiator.hasDecoratorSupport(); }