/** * Create an instance of a class using provider allocation rules of the specification as well as the InjectorFactory * only does constructor injection. * * @param clazz class * @param <T> type * @return provider instance of type T */ public <T> T createProviderInstance(Class<? extends T> clazz) { ConstructorInjector constructorInjector = createConstructorInjector(clazz); T provider = (T) constructorInjector.construct(false).toCompletableFuture().getNow(null); return provider; }
@Override public CompletionStage<Object> inject(HttpRequest request, HttpResponse response, boolean unwrapAsync) { return constructorInjector.construct(unwrapAsync) .thenCompose(target -> propertyInjector.inject(request, response, target, unwrapAsync) .thenApply(v -> target)); } }
public CompletionStage<Object> createResource(HttpRequest request, HttpResponse response, ResteasyProviderFactory factory) { return constructorInjector.construct(request, response, true) .thenCompose(obj -> propertyInjector.inject(request, response, obj, true).thenApply(v -> obj)); }
@Override public CompletionStage<Object> inject(HttpRequest request, HttpResponse response, boolean unwrapAsync) { return constructorInjector.construct(unwrapAsync) .thenCompose(target -> propertyInjector.inject(request, response, target, unwrapAsync) .thenApply(v -> target)); } }
/** * Property and constructor injection using the InjectorFactory. * * @param clazz class * @param request http request * @param response http response * @param <T> type * @return instance of type T */ public <T> T injectedInstance(Class<? extends T> clazz, HttpRequest request, HttpResponse response) { Constructor<?> constructor = PickConstructor.pickSingletonConstructor(clazz); Object obj = null; if (constructor == null) { throw new IllegalArgumentException(Messages.MESSAGES.unableToFindPublicConstructorForClass(clazz.getName())); } else { ConstructorInjector constructorInjector = getInjectorFactory().createConstructor(constructor, this); obj = constructorInjector.construct(request, response, false).toCompletableFuture().getNow(null); } PropertyInjector propertyInjector = getInjectorFactory().createPropertyInjector(clazz, this); propertyInjector.inject(request, response, obj, false).toCompletableFuture().getNow(null); return (T) obj; }
/** * Property and constructor injection using the InjectorFactory. * * @param clazz class * @param <T> type * @return instance of type T */ public <T> T injectedInstance(Class<? extends T> clazz) { Constructor<?> constructor = PickConstructor.pickSingletonConstructor(clazz); ConstructorInjector constructorInjector = getInjectorFactory().createConstructor(constructor, this); return (T) constructorInjector.construct(false).thenCompose(obj -> { PropertyInjector propertyInjector = getInjectorFactory().createPropertyInjector(clazz, this); return propertyInjector.inject(obj, false).thenApply(val -> obj); }).toCompletableFuture().getNow(null); }
@Override public Object inject(HttpRequest request, HttpResponse response) { Object target = constructorInjector.construct(); propertyInjector.inject(request, response, target); return target; } }
public Object createResource(HttpRequest request, HttpResponse response, InjectorFactory factory) { Object obj = constructorInjector.construct(request, response); propertyInjector.inject(request, response, obj); return obj; }
public Object inject(HttpRequest request, HttpResponse response) { Object target = constructorInjector.construct(); propertyInjector.inject(request, response, target); return target; } }
public Object createResource(HttpRequest request, HttpResponse response, ResteasyProviderFactory factory) { Object obj = constructorInjector.construct(request, response); propertyInjector.inject(request, response, obj); return obj; }
/** * Create an instance of a class using provider allocation rules of the specification as well as the InjectorFactory * <p/> * only does constructor injection * * @param clazz * @param <T> * @return */ public <T> T createProviderInstance(Class<? extends T> clazz) { ConstructorInjector constructorInjector = createConstructorInjector(clazz); T provider = (T) constructorInjector.construct(); return provider; }
/** * Create an instance of a class using provider allocation rules of the specification as well as the InjectorFactory * only does constructor injection. * * @param clazz class * @param <T> type * @return provider instance of type T */ public <T> T createProviderInstance(Class<? extends T> clazz) { ConstructorInjector constructorInjector = createConstructorInjector(clazz); T provider = (T) constructorInjector.construct(false).toCompletableFuture().getNow(null); return provider; }
public CompletionStage<Object> createResource(HttpRequest request, HttpResponse response, ResteasyProviderFactory factory) { return constructorInjector.construct(request, response, true) .thenCompose(obj -> propertyInjector.inject(request, response, obj, true).thenApply(v -> obj)); }
@Override public CompletionStage<Object> inject(HttpRequest request, HttpResponse response, boolean unwrapAsync) { return constructorInjector.construct(unwrapAsync) .thenCompose(target -> propertyInjector.inject(request, response, target, unwrapAsync) .thenApply(v -> target)); } }
@Override public CompletionStage<Object> inject(HttpRequest request, HttpResponse response, boolean unwrapAsync) { return constructorInjector.construct(unwrapAsync) .thenCompose(target -> propertyInjector.inject(request, response, target, unwrapAsync) .thenApply(v -> target)); } }
/** * Property and constructor injection using the InjectorFactory. * * @param clazz class * @param request http request * @param response http response * @param <T> type * @return instance of type T */ public <T> T injectedInstance(Class<? extends T> clazz, HttpRequest request, HttpResponse response) { Constructor<?> constructor = PickConstructor.pickSingletonConstructor(clazz); Object obj = null; if (constructor == null) { throw new IllegalArgumentException(Messages.MESSAGES.unableToFindPublicConstructorForClass(clazz.getName())); } else { ConstructorInjector constructorInjector = getInjectorFactory().createConstructor(constructor, this); obj = constructorInjector.construct(request, response, false).toCompletableFuture().getNow(null); } PropertyInjector propertyInjector = getInjectorFactory().createPropertyInjector(clazz, this); propertyInjector.inject(request, response, obj, false).toCompletableFuture().getNow(null); return (T) obj; }
/** * Property and constructor injection using the InjectorFactory * * @param clazz * @param <T> * @return */ public <T> T injectedInstance(Class<? extends T> clazz) { Constructor<?> constructor = PickConstructor.pickSingletonConstructor(clazz); Object obj = null; ConstructorInjector constructorInjector = getInjectorFactory().createConstructor(constructor, this); obj = constructorInjector.construct(); PropertyInjector propertyInjector = getInjectorFactory().createPropertyInjector(clazz, this); propertyInjector.inject(obj); return (T) obj; }
/** * Property and constructor injection using the InjectorFactory. * * @param clazz class * @param <T> type * @return instance of type T */ public <T> T injectedInstance(Class<? extends T> clazz) { Constructor<?> constructor = PickConstructor.pickSingletonConstructor(clazz); ConstructorInjector constructorInjector = getInjectorFactory().createConstructor(constructor, this); return (T) constructorInjector.construct(false).thenCompose(obj -> { PropertyInjector propertyInjector = getInjectorFactory().createPropertyInjector(clazz, this); return propertyInjector.inject(obj, false).thenApply(val -> obj); }).toCompletableFuture().getNow(null); }
obj = constructorInjector.construct(request, response);