protected ResteasyUriBuilder getUriBuilder(Class<? extends Object> clazz) { MappedBy mappedBy = clazz.getAnnotation(MappedBy.class); ResteasyUriBuilder uriBuilderImpl = new ResteasyUriBuilder(); Class<?> resourceType = mappedBy.resource(); uriBuilderImpl.path(resourceType); String method = mappedBy.method(); if (method != null && method.length() > 0) { uriBuilderImpl.path(resourceType, method); } return uriBuilderImpl; } }
public ResourceClassBuilder buildMethod() { ResteasyUriBuilder builder = new ResteasyUriBuilder(); if (locator.resourceClass.path != null) builder.path(locator.resourceClass.path); if (locator.path != null) builder.path(locator.path); String pathExpression = builder.getPath(); if (pathExpression == null) pathExpression = ""; locator.fullpath = pathExpression; if (locator.resourceClass.getClazz().isAnonymousClass()) { locator.getMethod().setAccessible(true); } resourceClassBuilder.resourceLocators.add(locator); return resourceClassBuilder; }
@Override public UriBuilder segment(String... segments) throws IllegalArgumentException { if (segments == null) throw new IllegalArgumentException(Messages.MESSAGES.segmentsParameterNull()); for (String segment : segments) { if (segment == null) throw new IllegalArgumentException(Messages.MESSAGES.segmentNull()); path(Encode.encodePathSegment(segment)); } return this; }
public ResourceClassBuilder buildMethod() { ResteasyUriBuilder builder = new ResteasyUriBuilder(); if (method.resourceClass.path != null) builder.path(method.resourceClass.path); if (method.path != null) builder.path(method.path); String pathExpression = builder.getPath(); if (pathExpression == null) pathExpression = ""; method.fullpath = pathExpression; if (method.resourceClass.getClazz().isAnonymousClass()) { method.getMethod().setAccessible(true); } resourceClassBuilder.resourceMethods.add(method); return resourceClassBuilder; } }
private void removeRegistration(String base, Class<?> clazz) { for (Method method : clazz.getMethods()) { Path path = method.getAnnotation(Path.class); Set<String> httpMethods = IsHttpMethod.getHttpMethods(method); if (path == null && httpMethods == null) continue; ResteasyUriBuilder builder = new ResteasyUriBuilder(); if (base != null) builder.path(base); if (clazz.isAnnotationPresent(Path.class)) builder.path(clazz); String classExpression = builder.getPath(); if (path != null) builder.path(method); String fullpath = builder.getPath(); if (fullpath == null) fullpath = ""; if (widerMatching) rootNode.removeBinding(fullpath, method); else root.removeBinding(classExpression, fullpath, method); } }
@SuppressWarnings("unchecked") @Override public UriBuilder path(Class resource, String method) throws IllegalArgumentException { if (resource == null) throw new IllegalArgumentException(Messages.MESSAGES.resourceNull()); if (method == null) throw new IllegalArgumentException(Messages.MESSAGES.methodNull()); Method theMethod = null; for (Method m : resource.getMethods()) { if (m.getName().equals(method)) { if (theMethod != null && m.isAnnotationPresent(Path.class)) { throw new IllegalArgumentException(Messages.MESSAGES.twoMethodsSameName(method)); } if (m.isAnnotationPresent(Path.class)) theMethod = m; } } if (theMethod == null) throw new IllegalArgumentException(Messages.MESSAGES.noPublicPathAnnotatedMethod(resource.getName(), method)); return path(theMethod); }
public ClientInvoker(URI baseUri, Class declaring, Method method, ProxyConfig config) { this.declaring = declaring; this.method = method; this.marshallers = ClientMarshallerFactory.createMarshallers(declaring, method, providerFactory, config.getServerConsumes()); this.providerFactory = config.getProviderFactory(); this.executor = config.getExecutor(); accepts = MediaTypeHelper.getProduces(declaring, method, config.getServerProduces()); this.uri = new ResteasyUriBuilder(); this.baseUri = baseUri; uri.uri(baseUri); if (declaring.isAnnotationPresent(Path.class)) uri.path(declaring); if (method.isAnnotationPresent(Path.class)) uri.path(method); this.extractorFactory = config.getExtractorFactory(); this.extractor = extractorFactory.createExtractor(method); }
public ClientInvoker(URI baseUri, Class declaring, Method method, ProxyConfig config) { this.declaring = declaring; this.method = method; this.marshallers = ClientMarshallerFactory.createMarshallers(declaring, method, providerFactory, config.getServerConsumes()); this.providerFactory = (org.jboss.resteasy.spi.old.ResteasyProviderFactory)config.getProviderFactory(); this.executor = config.getExecutor(); final MediaType[] acpts = MediaTypeHelper.getProduces(declaring, method, config.getServerProduces()); accepts = acpts != null ? acpts[0] : null; this.uri = new ResteasyUriBuilder(); this.baseUri = baseUri; uri.uri(baseUri); if (declaring.isAnnotationPresent(Path.class)) uri.path(declaring); if (method.isAnnotationPresent(Path.class)) uri.path(method); this.extractorFactory = config.getExtractorFactory(); this.extractor = extractorFactory.createExtractor(method); }