if (declaringClass.equals(Providers.class)) {
return providers;
}
if (declaringClass.equals(ContextResolver.class)) {
// NICE also throw, where the error occurs.
throw new IllegalTypeException(
"The ContextResolver is not allowed for @Context annotated fields yet. Use javax.ws.rs.ext.Providers#getContextResolver(...)");
}
if (declaringClass.equals(ExtensionBackwardMapping.class)) {
return extensionBackwardMapping;
}
if (declaringClass.equals(PathSegment.class)) {
String msg = "The use of PathSegment annotated with @Context is not standard.";
logger.config(msg);
return new GetLastPathSegment(tlContext);
}
if (declaringClass.equals(SecurityContext.class)
|| declaringClass.equals(HttpHeaders.class)
|| declaringClass.equals(Request.class)) {
return tlContext;
}
if (declaringClass.equals(UriInfo.class)) {
throw new ImplementationException(
"You must not call the method ContextInjector.getInjectObject(.......) with class UriInfo");
}
String declaringClassName = declaringClass.getName();
// compare names to avoid ClassNotFoundExceptions, if the Servlet-API is
// not in the classpath
if (declaringClassName.equals("javax.servlet.http.HttpServletRequest")
|| declaringClassName
.equals("javax.servlet.http.HttpServletResponse")) {
throw new NotYetImplementedException(
"The returnin of Servlet depending Context is not implemented for now.");
}
// NICE also allow injection of ClientInfo and Conditions. Proxies are
// required, because the injected objects must be thread local.
throw new IllegalTypeException(declaringClass
+ " must not be annotated with @Context");
}