Java Code Examples for javax.ws.rs.container.ResourceInfo#getResourceClass()
The following examples show how to use
javax.ws.rs.container.ResourceInfo#getResourceClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MCRJerseyDefaultFeature.java From mycore with GNU General Public License v3.0 | 6 votes |
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { Class<?> resourceClass = resourceInfo.getResourceClass(); Method resourceMethod = resourceInfo.getResourceMethod(); context.register(MCRCacheFilter.class); if (isStaticContent(resourceClass, resourceMethod)) { // class or method is annotated with MCRStaticContent // -> do only register session lock filter context.register(MCRSessionLockFilter.class); return; } String packageName = resourceClass.getPackage().getName(); if (getPackages().contains(packageName)) { registerTransactionFilter(context); registerSessionHookFilter(context); registerAccessFilter(context, resourceClass, resourceMethod); } }
Example 2
Source File: CacheControlFeature.java From seed with Mozilla Public License 2.0 | 6 votes |
@Override public void configure(ResourceInfo resourceInfo, FeatureContext featureContext) { CacheControl cacheControl = null; Method resourceMethod = resourceInfo.getResourceMethod(); if (resourceMethod != null) { cacheControl = resourceMethod.getAnnotation(CacheControl.class); } else { Class<?> resourceClass = resourceInfo.getResourceClass(); if (resourceClass != null) { cacheControl = resourceClass.getAnnotation(CacheControl.class); } } if (cacheControl == null) { featureContext.register(NO_CACHE_FILTER); } else { featureContext.register(new CacheResponseFilter(cacheControl.value())); } }
Example 3
Source File: MCRRestFeature.java From mycore with GNU General Public License v3.0 | 5 votes |
@Override public void configure(ResourceInfo resourceInfo, FeatureContext context) { Class<?> resourceClass = resourceInfo.getResourceClass(); Method resourceMethod = resourceInfo.getResourceMethod(); if (requiresTransaction(resourceClass, resourceMethod)) { context.register(MCREnableTransactionFilter.class); } super.configure(resourceInfo, context); }
Example 4
Source File: BaseUmaProtectionService.java From oxTrust with MIT License | 5 votes |
public List<String> getRequestedScopes(ResourceInfo resourceInfo) { Class<?> resourceClass = resourceInfo.getResourceClass(); ProtectedApi typeAnnotation = resourceClass.getAnnotation(ProtectedApi.class); List<String> scopes = new ArrayList<String>(); if (typeAnnotation == null) { addMethodScopes(resourceInfo, scopes); } else { scopes.addAll(Stream.of(typeAnnotation.scopes()).collect(Collectors.toList())); addMethodScopes(resourceInfo, scopes); } return scopes; }
Example 5
Source File: ErrorMessage.java From ameba with MIT License | 5 votes |
/** * <p>parseSource.</p> * * @param resourceInfo a {@link javax.ws.rs.container.ResourceInfo} object. * @return a {@link java.lang.String} object. */ public static String parseSource(ResourceInfo resourceInfo) { if (resourceInfo != null) { Class clazz = resourceInfo.getResourceClass(); if (clazz != null) return ClassUtils.toString(clazz, resourceInfo.getResourceMethod()); } return null; }
Example 6
Source File: EbeanUtils.java From ameba with MIT License | 5 votes |
/** * <p>checkQuery.</p> * * @param query a {@link io.ebean.Query} object. * @param whitelist a {@link java.util.Set} object. * @param blacklist a {@link java.util.Set} object. * @param manager a {@link InjectionManager} object. */ public static void checkQuery(Query<?> query, Set<String> whitelist, Set<String> blacklist, InjectionManager manager) { ResourceInfo resource = manager.getInstance(ResourceInfo.class); Class<?> rc = resource.getResourceClass(); Set<String> wl = null, bl = null; if (rc != null) { Filter filter = rc.getAnnotation(Filter.class); if (filter != null) { if (filter.whitelist().length > 0) { wl = Sets.newLinkedHashSet(); Collections.addAll(wl, filter.whitelist()); } if (filter.blacklist().length > 0) { bl = Sets.newLinkedHashSet(); Collections.addAll(bl, filter.blacklist()); } } } if (whitelist != null) { if (wl == null) { wl = Sets.newLinkedHashSet(); } wl.addAll(whitelist); } if (blacklist != null) { if (bl == null) { bl = Sets.newLinkedHashSet(); } bl.addAll(blacklist); } checkQuery((SpiQuery) query, wl, bl, manager.getInstance(Application.Mode.class).isProd()); }
Example 7
Source File: DataViewMessageBodyWriter.java From ameba with MIT License | 4 votes |
/** {@inheritDoc} */ @Override public void writeTo(final Object entity, final Class<?> type, final Type genericType, final Annotation[] annotations, MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException, WebApplicationException { if (mediaType == null || MediaTypes.isWildcard(mediaType) || (mediaType.getType().equals(LOW_IE_DEFAULT_REQ_TYPE.getType()) && mediaType.getSubtype().equals(LOW_IE_DEFAULT_REQ_TYPE.getSubtype()))) { mediaType = MediaType.TEXT_HTML_TYPE; } List<String> templates = Lists.newArrayList(); ResourceInfo resourceInfo = resourceInfoProvider.get(); // 1. resource method name // 2. _protected/ + req path LOWER_UNDERSCORE // 3. _protected/ + req raw path // 4. req path LOWER_UNDERSCORE // 5. req raw path // 6. index // 7. default view if (resourceInfo != null && resourceInfo.getResourceMethod() != null) { templates.add(resourceInfo.getResourceMethod().getName()); } // xxx/{a_b}.httl == xxx/{aB}.httl String path = getTemplatePath(uriInfoProvider.get()); String _path = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, path); if (!_path.equals(path)) { templates.add(Viewables.PROTECTED_DIR_PATH + _path); } templates.add(Viewables.PROTECTED_DIR_PATH + path); if (!_path.equals(path)) { templates.add(_path); } templates.add(path); templates.add("index"); if (!defaultDataViewDisabled) { if (entity == null || (entity instanceof Collection && ((Collection) entity).size() == 0) || (entity.getClass().isArray() && Array.getLength(entity) == 0)) { templates.add(dataViewNull); } else if (isItem(entity)) { templates.add(dataViewItem); } else { templates.add(dataViewList); } } Class clazz = null; if (resourceInfo != null) { clazz = resourceInfo.getResourceClass(); } if (clazz == null) { List<Object> res = uriInfoProvider.get().getMatchedResources(); if (res != null && res.size() > 0) { clazz = res.get(0).getClass(); } } if (clazz == null) { clazz = Ameba.class; } workersProvider.get().getMessageBodyWriter( ImplicitViewable.class, ImplicitViewable.class, annotations, mediaType) .writeTo(new ImplicitViewable(templates, entity, clazz), ImplicitViewable.class, ImplicitViewable.class, annotations, mediaType, httpHeaders, entityStream); }
Example 8
Source File: ValidationInterceptorsFeature.java From tomee with Apache License 2.0 | 3 votes |
@Override public void configure(final ResourceInfo resourceInfo, final FeatureContext context) { final Class<?> resourceClass = resourceInfo.getResourceClass(); final ValidationConstraints constraints = ValidationConstraints.of(resourceClass); if (constraints != null) { context.register(new ValidationInterceptor(resourceInfo, constraints)); } }