if (GetRestful.isRootResource(beanClass))
final Class resourceDef = GetRestful.getRootResourceClass(implClass) != null ? implClass : type;
/** * Given a class, search itself and implemented interfaces for jax-rs annotations. * * @param clazz class * @return list of class and interfaces that have jax-rs annotations */ public static Class getSubResourceClass(Class clazz) { // check class & superclasses for JAX-RS annotations for (Class<?> actualClass = clazz; isTopObject(actualClass); actualClass = actualClass.getSuperclass()) { if (hasJAXRSAnnotations(actualClass)) return actualClass; } // ok, no @Path or @HttpMethods so look in interfaces. for (Class intf : clazz.getInterfaces()) { if (hasJAXRSAnnotations(intf)) return intf; } return null; }
throw new DeploymentUnitProcessingException(e); if (!GetRestful.isRootResource(componentClass)) continue; Class<?>[] jaxrsType = GetRestful.getSubResourceClasses(componentClass); final String jndiName; if (component.getViews().size() == 1) {
throw new DeploymentUnitProcessingException(e); if (!GetRestful.isRootResource(componentClass)) continue; Class[] jaxrsType = GetRestful.getSubResourceClass(componentClass); final String jndiName; if (component.getViews().size() == 1) {
Method method = locator.getMethod(); Class<?> locatorType = method.getReturnType(); Class<?>[] locatorResourceTypes = GetRestful.getSubResourceClasses(locatorType); for (Class<?> locatorResourceType : locatorResourceTypes)
if (registry == null) if (!GetRestful.isSubResourceClass(clazz))
throw new DeploymentUnitProcessingException(e); if (!GetRestful.isRootResource(componentClass)) continue; Class<?>[] jaxrsType = GetRestful.getSubResourceClasses(componentClass); final String jndiName; if (component.getViews().size() == 1) {
Method method = locator.getMethod(); Class<?> locatorType = method.getReturnType(); Class<?>[] locatorResourceTypes = GetRestful.getSubResourceClasses(locatorType); for (Class<?> locatorResourceType : locatorResourceTypes) { if (locatorResourceType == null) {
if (registry == null) if (!GetRestful.isSubResourceClass(clazz))
if (GetRestful.isRootResource(clazz)) if (GetRestful.isRootResource(obj.getClass()))
final Class resourceDef = GetRestful.getRootResourceClass(implClass) != null ? implClass : type;
/** * Given a class, search itself and implemented interfaces for jax-rs annotations. * * @param clazz class * @return list of class and interfaces that have jax-rs annotations */ public static boolean isSubResourceClass(Class clazz) { // check class & superclasses for JAX-RS annotations for (Class<?> actualClass = clazz; isTopObject(actualClass); actualClass = actualClass.getSuperclass()) { if (hasJAXRSAnnotations(actualClass)) return true; // ok, no @Path or @HttpMethods so look in interfaces. for (Class intf : actualClass.getInterfaces()) { if (hasJAXRSAnnotations(intf)) return true; } } return false; }
Method method = locator.getMethod(); Class<?> locatorType = method.getReturnType(); Class<?>[] locatorResourceTypes = GetRestful.getSubResourceClasses(locatorType); for (Class<?> locatorResourceType : locatorResourceTypes)
if (registry == null) if (!GetRestful.isSubResourceClass(clazz))
/** * Set a default scope for each CDI bean which is a JAX-RS Resource. * * @param <T> type * @param event event * @param beanManager bean manager */ public <T> void observeResources(@WithAnnotations({Path.class}) @Observes ProcessAnnotatedType<T> event, BeanManager beanManager) { setBeanManager(beanManager); AnnotatedType<T> annotatedType = event.getAnnotatedType(); if(!annotatedType.getJavaClass().isInterface() && !isSessionBean(annotatedType) // This check is redundant for CDI 1.1 containers but required for CDI 1.0 && GetRestful.isRootResource(annotatedType.getJavaClass()) && !annotatedType.isAnnotationPresent(Decorator.class)) { LogMessages.LOGGER.debug(Messages.MESSAGES.discoveredCDIBeanJaxRsResource(annotatedType.getJavaClass().getCanonicalName())); event.setAnnotatedType(wrapAnnotatedType(annotatedType, requestScopedLiteral)); this.resources.add(annotatedType.getJavaClass()); } }
public static boolean isRootResource(Class clazz) { return getRootResourceClass(clazz) != null; } }
/** * Given a class, search itself and implemented interfaces for jax-rs annotations. * * @param clazz class * @return list of class and interfaces that have jax-rs annotations */ public static Class<?>[] getSubResourceClasses(Class<?> clazz) { List<Class<?>> classes = new ArrayList<Class<?>>(); // check class & superclasses for JAX-RS annotations for (Class<?> actualClass = clazz; isTopObject(actualClass); actualClass = actualClass.getSuperclass()) { if (hasJAXRSAnnotations(actualClass)) return new Class<?>[]{actualClass}; } // ok, no @Path or @HttpMethods so look in interfaces. for (Class<?> intf : clazz.getInterfaces()) { if (hasJAXRSAnnotations(intf)) classes.add(intf); } return classes.toArray(new Class<?>[classes.size()]); }
if (GetRestful.isRootResource(clazz)) if (GetRestful.isRootResource(obj.getClass()))
public void removeRegistrations(Class clazz, String base) { Class restful = GetRestful.getRootResourceClass(clazz); removeRegistration(base, restful); }