@Override public void initiate(final ResourceConfig rc, final IoCComponentProviderFactory _provider) { Errors.processWithErrors(new Errors.Closure<Void>() { @Override public Void f() { Errors.setReportMissingDependentFieldOrMethod(false); _initiate(rc, _provider); return null; } }); }
@Override public Object getValue(HttpContext c) { return i.getValue(); } };
@ConstrainedTo(ServerSide.class) public final class ViewableMessageBodyWriter implements MessageBodyWriter<Viewable> {
private PathPattern getPattern(String path, Class c) { PathPattern p = null; try { p = new PathPattern(new PathTemplate(path)); } catch (IllegalArgumentException ex) { Errors.error("Illegal URI template for root resource class " + c.getName() + ": "+ ex.getMessage()); } return p; }
Errors.missingDependency(sm.getMethod(), methodIndex); for (Map.Entry<Method, Injectable<?>> e : singletons.entrySet()) { singletonSetters[i] = e.getKey(); singletonSetterValues[i++] = e.getValue().getValue();
@Override public RequestDispatcher create(AbstractResourceMethod abstractResourceMethod) { // Mark the errors so it is possible to reset Errors.mark(); for (ResourceMethodDispatchProvider rmdp : dispatchers) { try { RequestDispatcher d = rmdp.create(abstractResourceMethod); if (d != null) { // Reset any errors, if any, produced from previous dispatch // providers Errors.reset(); return d; } } catch (Exception e) { LOGGER.log(Level.SEVERE, ImplMessages.ERROR_PROCESSING_METHOD( abstractResourceMethod.getMethod(), rmdp.getClass().getName()), e); } } Errors.unmark(); return null; } }
if (a.annotationType() == Inject.class) { final Inject i = Inject.class.cast(a); final String value = (i.value() != null) ? i.value().trim() : ""; if (value.isEmpty()) { Errors.processWithErrors(new Errors.Closure<Void>() { @Override public Void f() {
p, ComponentScope.PerRequest); if (i != null) return new InjectableScopePair(i, ComponentScope.PerRequest);
@Override public Injectable<Injectable> getInjectable(ComponentContext ic, Inject a, Type c) { if (c instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType)c; if (pt.getRawType() == Injectable.class) { if (pt.getActualTypeArguments().length == 1) { final Injectable<?> i = injectableFactory.getInjectable( a.annotationType(), ic, a, pt.getActualTypeArguments()[0], ComponentScope.PERREQUEST_UNDEFINED_SINGLETON); if (i == null) return null; return new Injectable<Injectable>() { @Override public Injectable getValue() { return i; } }; } } } return null; } });
public void onConflict(PathPattern p1, PathPattern p2) { Errors.error(String.format("Conflicting URI templates. " + "The URI templates %s and %s for root resource classes " + "transform to the same regular expression %s", p1.getTemplate().getTemplate(), p2.getTemplate().getTemplate(), p1)); } });
Errors.missingDependency(af.getField()); for (Map.Entry<Field, Injectable<?>> e : singletons.entrySet()) { singletonFields[i] = e.getKey(); singletonFieldValues[i++] = e.getValue().getValue();
public RequestDispatcher getDispatcher(AbstractResourceMethod abstractResourceMethod, JavaMethodInvoker invoker) { if (invoker == null) { return null; } // Mark the errors so it is possible to reset Errors.mark(); for (ResourceMethodCustomInvokerDispatchProvider rmdp : customInvokerDispatchProviders) { try { RequestDispatcher d = rmdp.create(abstractResourceMethod, invoker); if (d != null) { // Reset any errors, if any, produced from previous dispatch // providers Errors.reset(); return d; } } catch (Exception e) { LOGGER.log(Level.SEVERE, ImplMessages.ERROR_PROCESSING_METHOD( abstractResourceMethod.getMethod(), rmdp.getClass().getName()), e); } } Errors.unmark(); return null; } }
/* package */ UriRules<UriRule> getUriRules(final Class c) { assert c != null; // Try the non-blocking read, the most common operation UriRules<UriRule> r = rulesMap.get(c); if (r != null) { return r; } // Not present use a synchronized block to ensure that only one // instance is created and put to the map synchronized (abstractResourceMap) { // One or more threads may have been blocking on the synchronized // block, re-check the map r = rulesMap.get(c); if (r != null) { return r; } r = Errors.processWithErrors(new Errors.Closure<ResourceUriRules>() { @Override public ResourceUriRules f() { return newResourceUriRules(getAbstractResource(c)); } }).getRules(); rulesMap.put(c, r); } return r; }
public void onConflict(PathPattern p1, PathPattern p2) { Errors.error(String.format("Conflicting URI templates. " + "The URI templates %s and %s for sub-resource methods " + "and/or sub-resource locators of resource class %s " + "transform to the same regular expression %s", p1.getTemplate().getTemplate(), p2.getTemplate().getTemplate(), resource.getResourceClass().getName(), p1)); } });
Errors.processWithErrors(new Errors.Closure<Void>() { @Override public Void f() {
private boolean isPatternValid(PathPattern p, Class c) { if (p == null) return false; final PathPattern conflict = rules.hasConflict(p); if (conflict != null) { Errors.error(String.format("Conflicting URI templates. " + "The URI template %s for root resource class %s " + "and the URI template %s transform to the same regular expression %s", p.getTemplate().getTemplate(), c.getName(), conflict.getTemplate().getTemplate(), p)); return false; } else { return true; } }
@Override public IoCComponentProcessor get(final Class c, final ComponentScope scope) { IoCComponentProcessor cp = componentProcessorMap.get(c); if (cp != null) { return (cp == NULL_COMPONENT_PROCESSOR) ? null : cp; } synchronized (abstractResourceMap) { cp = componentProcessorMap.get(c); if (cp != null) { return (cp == NULL_COMPONENT_PROCESSOR) ? null : cp; } final ResourceComponentInjector rci = Errors.processWithErrors(new Errors.Closure<ResourceComponentInjector>() { @Override public ResourceComponentInjector f() { return new ResourceComponentInjector( injectableFactory, scope, getAbstractResource(c)); } }); if (rci.hasInjectableArtifacts()) { cp = new ComponentProcessorImpl(rci); componentProcessorMap.put(c, cp); } else { cp = null; componentProcessorMap.put(c, NULL_COMPONENT_PROCESSOR); } } return cp; } }
private ResourceUriRules newResourceUriRules(final AbstractResource ar) { assert null != ar; BasicValidator validator = new BasicValidator(); validator.validate(ar); for (ResourceModelIssue issue : validator.getIssueList()) { Errors.error(issue.getMessage(), issue.isFatal()); } return new ResourceUriRules( resourceConfig, getDispatchProvider(), injectableFactory, filterFactory, wadlFactory, dispatchingListener, ar); }
private boolean isValidResourceMethod( final ResourceMethod rm, final ResourceMethodMap rmm) { final List<ResourceMethod> rml = rmm.get(rm.getHttpMethod()); if (rml != null) { boolean conflict = false; ResourceMethod erm = null; for (int i = 0; i < rml.size() && !conflict; i++) { erm = rml.get(i); conflict = MediaTypes.intersects(rm.getConsumes(), erm.getConsumes()) && MediaTypes.intersects(rm.getProduces(), erm.getProduces()); } if (conflict) { if (rm.getAbstractResourceMethod().hasEntity()) { Errors.error(String.format("Consuming media type conflict. " + "The resource methods %s and %s can consume the same media type", rm.getAbstractResourceMethod().getMethod(), erm.getAbstractResourceMethod().getMethod())); } else { Errors.error(String.format("Producing media type conflict. " + "The resource methods %s and %s can produce the same media type", rm.getAbstractResourceMethod().getMethod(), erm.getAbstractResourceMethod().getMethod())); } } if (conflict) return false; } return true; }
public ResourceHttpMethod( ResourceMethodDispatchProvider dp, FilterFactory ff, List<ResourceFilter> resourceFilters, UriTemplate template, AbstractResourceMethod arm) { super(arm.getHttpMethod(), template, arm.getSupportedInputTypes(), arm.getSupportedOutputTypes(), arm.areOutputTypesDeclared(), dp.create(arm), FilterFactory.getRequestFilters(resourceFilters), FilterFactory.getResponseFilters(resourceFilters)); this.arm = arm; if (getDispatcher() == null) { Method m = arm.getMethod(); String msg = ImplMessages.NOT_VALID_HTTPMETHOD(m, arm.getHttpMethod(), m.getDeclaringClass()); Errors.error(msg); } }