@Override public <T extends ConstraintValidator<?, ?>> T getInstance(final Class<T> key) { return resourceContext.getResource(key); }
@Override public ResourceMethodDispatcher create(final Invocable resourceMethod, final InvocationHandler handler, final ConfiguredValidator validator) { if (resourceMethod.getHandlingMethod().getReturnType() != void.class || !resourceMethod.getParameters().isEmpty()) { return null; } return resourceContext.initResource(new VoidToVoidDispatcher(resourceMethod, handler, validator)); } }
@Override public boolean configure(FeatureContext context) { ConstraintValidatorFactory constraintValidatorFactory = validatorFactory.getConstraintValidatorFactory(); if (constraintValidatorFactory instanceof MutableValidatorFactory) { MutableValidatorFactory mutableValidatorFactory = (MutableValidatorFactory) constraintValidatorFactory; ConstraintValidatorFactory validatorFactory = resourceContext.getResource(InjectingConstraintValidatorFactory.class); mutableValidatorFactory.setValidatorFactory(validatorFactory); return true; } return false; } }
@Override public ResourceMethodDispatcher create(final Invocable resourceMethod, final InvocationHandler handler, final ConfiguredValidator validator) { if (resourceMethod.getHandlingMethod().getReturnType() != void.class || !resourceMethod.getParameters().isEmpty()) { return null; } return resourceContext.initResource(new VoidToVoidDispatcher(resourceMethod, handler, validator)); } }
/** * Obtains a model object for a viewable. * * @param extendedUriInfo uri info to obtain last matched resource from. * @return a model object. */ private Object getModel(final ExtendedUriInfo extendedUriInfo) { final List<Object> matchedResources = extendedUriInfo.getMatchedResources(); if (resourceInstance != null) { return setModelClass(resourceInstance); } else if (matchedResources.size() > 1) { return setModelClass(matchedResources.get(1)); } else { return setModelClass(resourceContextProvider.get().getResource(resourceClass)); } }
/** * Create traversable resolver able to process {@link javax.validation.executable.ValidateOnExecution} annotation on * beans. * * @param delegate resolver to be wrapped into the custom traversable resolver. * @param handler handler to create traversable resolver for. * @return custom traversable resolver. */ private ValidateOnExecutionTraversableResolver getTraversableResolver(TraversableResolver delegate, final ValidateOnExecutionHandler handler) { if (delegate == null) { delegate = validationConfig.getDefaultTraversableResolver(); } final boolean validationEnabled = validationConfig.getBootstrapConfiguration().isExecutableValidationEnabled(); final ValidateOnExecutionTraversableResolver traversableResolver = new ValidateOnExecutionTraversableResolver(delegate, handler, validationEnabled); return resourceContext.initResource(traversableResolver); }
/** * Return default {@link ValidatorContext validator context} able to inject JAX-RS resources/providers. * * @param handler handler to create traversable resolver for. * @return default validator context. */ private ValidatorContext getDefaultValidatorContext(final ValidateOnExecutionHandler handler) { final ValidatorContext context = factory.usingContext(); // Default Configuration. context.constraintValidatorFactory(resourceContext.getResource(InjectingConstraintValidatorFactory.class)); // Traversable Resolver. context.traversableResolver(getTraversableResolver(factory.getTraversableResolver(), handler)); return context; }
@Override public ResourceMethodDispatcher create(final Invocable resourceMethod, final InvocationHandler handler, final ConfiguredValidator validator) { if (resourceMethod.getHandlingMethod().getReturnType() != void.class || !resourceMethod.getParameters().isEmpty()) { return null; } return resourceContext.initResource(new VoidToVoidDispatcher(resourceMethod, handler, validator)); } }
@Context private ResourceContext resourceContext; @Path("{id}") public ManufacturerResource getManufacturer(@PathParam("id") String id) { ManufacturerResource r = resourceContext.getResource(ManufacturerResource.class); r.setId(id); return r; }
@Path("{categoryId}/products") public CategoryProductResource getCategoryProducts( @PathParam("categoryId") int id, @Context ResourceContext rc) { return rc.initResource(new CategoryProductResource(id)); }
@Path("root") public class Resource { @Context ResourceContext context; @Path("sub/{id}") public SubResource get() { return context.getResource(SubResource.class); } }
public <T> T inject(T instance) { rc.initResource(instance); return BeanProvider.injectFields(instance); } }
@Path("{member}") public GroupMemberResource groupMemberResource() { return resourceContext.getResource(GroupMemberResource.class); } }
@Override public <T> T initResource(final T t) { return get().initResource(t); } }
@Path("tickets") public PlatformTicketsResource getPlatformTicketsResource() { return resourceContext.getResource(PlatformTicketsResource.class); } }
@Path("") public Object start() throws Exception { Resource root = rootFactory.createRoot(); resourceContext.initResource(root); return root.init(); }
@Path("{identityProvider}") public IdentityProviderResource getIdentityProviderResource() { return resourceContext.getResource(IdentityProviderResource.class); } }
@Override public ResourceMethodDispatcher create(final Invocable resourceMethod, final InvocationHandler handler, final ConfiguredValidator validator) { if (resourceMethod.getHandlingMethod().getReturnType() != void.class || !resourceMethod.getParameters().isEmpty()) { return null; } return resourceContext.initResource(new VoidToVoidDispatcher(resourceMethod, handler, validator)); } }
@Path("{user}") public UserResource getUserResource() { return resourceContext.getResource(UserResource.class); } }
@Override public ResourceMethodDispatcher create(final Invocable resourceMethod, final InvocationHandler handler, final ConfiguredValidator validator) { if (resourceMethod.getHandlingMethod().getReturnType() != void.class || !resourceMethod.getParameters().isEmpty()) { return null; } return resourceContext.initResource(new VoidToVoidDispatcher(resourceMethod, handler, validator)); } }