/** * Get the class by contract or create and inject a new instance. * * @param <T> instance type. * @param injectionManager DI injection manager. * @param clazz class of the instance to be provider. * @return instance of the class either provided as a service or created and injected by HK2. */ public static <T> T getOrCreate(InjectionManager injectionManager, final Class<T> clazz) { try { final T component = injectionManager.getInstance(clazz); return component == null ? injectionManager.createAndInitialize(clazz) : component; } catch (final RuntimeException e) { // Look for WebApplicationException and return it if found. MultiException is thrown when *Param field is // annotated and value cannot be provided (for example fromString(String) method can throw unchecked // exception. // // see InvalidParamTest // see JERSEY-1117 Throwable throwable = e.getCause(); if (throwable != null && WebApplicationException.class.isAssignableFrom(throwable.getClass())) { throw (WebApplicationException) throwable; } throw e; } } }
/** * Get the class by contract or create and inject a new instance. * * @param <T> instance type. * @param injectionManager DI injection manager. * @param clazz class of the instance to be provider. * @return instance of the class either provided as a service or created and injected by HK2. */ public static <T> T getOrCreate(InjectionManager injectionManager, final Class<T> clazz) { try { final T component = injectionManager.getInstance(clazz); return component == null ? injectionManager.createAndInitialize(clazz) : component; } catch (final RuntimeException e) { // Look for WebApplicationException and return it if found. MultiException is thrown when *Param field is // annotated and value cannot be provided (for example fromString(String) method can throw unchecked // exception. // // see InvalidParamTest // see JERSEY-1117 Throwable throwable = e.getCause(); if (throwable != null && WebApplicationException.class.isAssignableFrom(throwable.getClass())) { throw (WebApplicationException) throwable; } throw e; } } }
@Nullable @Override protected Function<ContainerRequest, ?> createValueProvider(Parameter parameter) { final Class<?> classType = parameter.getRawType(); final Session sessionAnnotation = parameter.getAnnotation(Session.class); if (sessionAnnotation == null) { return null; } if (classType.isAssignableFrom(HttpSession.class)) { return x -> im.createAndInitialize(HttpSessionFactory.class).provide(sessionAnnotation.doNotCreate()); } else if (classType.isAssignableFrom(Flash.class)) { return x -> im.createAndInitialize(FlashFactory.class).provide(sessionAnnotation.doNotCreate()); } else { return null; } }
if (binding instanceof ClassBinding) { ClassBinding classBinding = (ClassBinding) binding; return injectionManager.createAndInitialize(classBinding.getService()); } else { InstanceBinding instanceBinding = (InstanceBinding) binding;
if (binding instanceof ClassBinding) { ClassBinding classBinding = (ClassBinding) binding; return injectionManager.createAndInitialize(classBinding.getService()); } else { InstanceBinding instanceBinding = (InstanceBinding) binding;
for (Class<ForcedAutoDiscoverable> forcedADType : ServiceFinder.find(ForcedAutoDiscoverable.class, true) .toClassArray()) { forcedAutoDiscroverables.add(injectionManager.createAndInitialize(forcedADType));
for (Class<ForcedAutoDiscoverable> forcedADType : ServiceFinder.find(ForcedAutoDiscoverable.class, true) .toClassArray()) { forcedAutoDiscroverables.add(injectionManager.createAndInitialize(forcedADType));
providers.add(injectionManager.createAndInitialize(providerClass));
feature = injectionManager.createAndInitialize(registration.getFeatureClass()); managedObjectsFinalizer.registerForPreDestroyCall(feature); } else {
providers.add(injectionManager.createAndInitialize(providerClass));
feature = injectionManager.createAndInitialize(registration.getFeatureClass()); managedObjectsFinalizer.registerForPreDestroyCall(feature); } else {
: injectionManager.createAndInitialize(applicationClass); if (app instanceof ResourceConfig) { final ResourceConfig _rc = (ResourceConfig) app;
: injectionManager.createAndInitialize(applicationClass); if (app instanceof ResourceConfig) { final ResourceConfig _rc = (ResourceConfig) app;
providers.add(injectionManager.createAndInitialize(providerClass));
: injectionManager.createAndInitialize(applicationClass); if (app instanceof ResourceConfig) { final ResourceConfig _rc = (ResourceConfig) app;
/** * Get the class by contract or create and inject a new instance. * * @param <T> instance type. * @param injectionManager DI injection manager. * @param clazz class of the instance to be provider. * @return instance of the class either provided as a service or created and injected by HK2. */ public static <T> T getOrCreate(InjectionManager injectionManager, final Class<T> clazz) { try { final T component = injectionManager.getInstance(clazz); return component == null ? injectionManager.createAndInitialize(clazz) : component; } catch (final RuntimeException e) { // Look for WebApplicationException and return it if found. MultiException is thrown when *Param field is // annotated and value cannot be provided (for example fromString(String) method can throw unchecked // exception. // // see InvalidParamTest // see JERSEY-1117 Throwable throwable = e.getCause(); if (throwable != null && WebApplicationException.class.isAssignableFrom(throwable.getClass())) { throw (WebApplicationException) throwable; } throw e; } } }
/** * Get the class by contract or create and inject a new instance. * * @param <T> instance type. * @param injectionManager DI injection manager. * @param clazz class of the instance to be provider. * @return instance of the class either provided as a service or created and injected by HK2. */ public static <T> T getOrCreate(InjectionManager injectionManager, final Class<T> clazz) { try { final T component = injectionManager.getInstance(clazz); return component == null ? injectionManager.createAndInitialize(clazz) : component; } catch (final RuntimeException e) { // Look for WebApplicationException and return it if found. MultiException is thrown when *Param field is // annotated and value cannot be provided (for example fromString(String) method can throw unchecked // exception. // // see InvalidParamTest // see JERSEY-1117 Throwable throwable = e.getCause(); if (throwable != null && WebApplicationException.class.isAssignableFrom(throwable.getClass())) { throw (WebApplicationException) throwable; } throw e; } } }
if (binding instanceof ClassBinding) { ClassBinding classBinding = (ClassBinding) binding; return injectionManager.createAndInitialize(classBinding.getService()); } else { InstanceBinding instanceBinding = (InstanceBinding) binding;
if (binding instanceof ClassBinding) { ClassBinding classBinding = (ClassBinding) binding; return injectionManager.createAndInitialize(classBinding.getService()); } else { InstanceBinding instanceBinding = (InstanceBinding) binding;
feature = injectionManager.createAndInitialize(registration.getFeatureClass()); managedObjectsFinalizer.registerForPreDestroyCall(feature); } else {