use of javax.ws.rs.Path in project feign by OpenFeign.
the class JAXRSContract method processAnnotationOnClass.
@Override
protected void processAnnotationOnClass(MethodMetadata data, Class<?> clz) {
Path path = clz.getAnnotation(Path.class);
if (path != null) {
String pathValue = emptyToNull(path.value());
checkState(pathValue != null, "Path.value() was empty on type %s", clz.getName());
if (!pathValue.startsWith("/")) {
pathValue = "/" + pathValue;
}
if (pathValue.endsWith("/")) {
// Strip off any trailing slashes, since the template has already had slashes appropriately added
pathValue = pathValue.substring(0, pathValue.length() - 1);
}
data.template().insert(0, pathValue);
}
Consumes consumes = clz.getAnnotation(Consumes.class);
if (consumes != null) {
handleConsumesAnnotation(data, consumes, clz.getName());
}
Produces produces = clz.getAnnotation(Produces.class);
if (produces != null) {
handleProducesAnnotation(data, produces, clz.getName());
}
}
use of javax.ws.rs.Path in project jersey by jersey.
the class InjectLinkFieldDescriptor method getLinkTemplate.
/**
* TODO javadoc.
*/
public static String getLinkTemplate(ResourceMappingContext rmc, InjectLink link) {
String template = null;
if (!link.resource().equals(Class.class)) {
ResourceMappingContext.Mapping map = rmc.getMapping(link.resource());
if (map != null) {
template = map.getTemplate().getTemplate().toString();
} else {
// extract template from specified class' @Path annotation
Path path = link.resource().getAnnotation(Path.class);
template = path == null ? "" : path.value();
}
// extract template from specified class' @Path annotation
if (link.method().length() > 0) {
// append value of method's @Path annotation
MethodList methods = new MethodList(link.resource());
methods = methods.withMetaAnnotation(HttpMethod.class);
Iterator<AnnotatedMethod> iterator = methods.iterator();
while (iterator.hasNext()) {
AnnotatedMethod method = iterator.next();
if (!method.getMethod().getName().equals(link.method())) {
continue;
}
StringBuilder builder = new StringBuilder();
builder.append(template);
Path methodPath = method.getAnnotation(Path.class);
if (methodPath != null) {
String methodTemplate = methodPath.value();
if (!(template.endsWith("/") || methodTemplate.startsWith("/"))) {
builder.append("/");
}
builder.append(methodTemplate);
}
CharSequence querySubString = extractQueryParams(method);
if (querySubString.length() > 0) {
builder.append("{?");
builder.append(querySubString);
builder.append("}");
}
template = builder.toString();
break;
}
}
} else {
template = link.value();
}
return template;
}
use of javax.ws.rs.Path in project jersey by jersey.
the class ClientShutdownLeakResource method invokeClient.
@POST
@Path("invoke")
public String invokeClient() {
WebTarget target2 = target.property("Washington", "Irving");
Invocation.Builder req = target2.request().property("how", "now");
req.buildGet().property("Irving", "Washington");
return target.toString();
}
use of javax.ws.rs.Path in project jersey by jersey.
the class DomainResource method post.
@Path("start")
@POST
public Response post(@DefaultValue("0") @QueryParam("testSources") int testSources) {
final Process process = new Process(testSources);
processes.put(process.getId(), process);
Executors.newSingleThreadExecutor().execute(process);
final URI processIdUri = UriBuilder.fromResource(DomainResource.class).path("process/{id}").build(process.getId());
return Response.created(processIdUri).build();
}
use of javax.ws.rs.Path in project jersey by jersey.
the class SparklinesResource method smooth.
@Path("smooth")
@GET
public Response smooth(@DefaultValue("2") @QueryParam("step") final int step, @DefaultValue("true") @QueryParam("min-m") final boolean hasMin, @DefaultValue("true") @QueryParam("max-m") final boolean hasMax, @DefaultValue("true") @QueryParam("last-m") final boolean hasLast, @DefaultValue("blue") @QueryParam("min-color") final ColorParam minColor, @DefaultValue("green") @QueryParam("max-color") final ColorParam maxColor, @DefaultValue("red") @QueryParam("last-color") final ColorParam lastColor) {
final BufferedImage image = new BufferedImage(data.size() * step - 4, imageHeight, BufferedImage.TYPE_INT_RGB);
final Graphics2D g = image.createGraphics();
g.setBackground(Color.WHITE);
g.clearRect(0, 0, image.getWidth(), image.getHeight());
g.setColor(Color.gray);
final int[] xs = new int[data.size()];
final int[] ys = new int[data.size()];
final int gap = 4;
final float d = (limits.width() + 1) / (float) (imageHeight - gap);
for (int i = 0, x = 0; i < data.size(); i++, x += step) {
final int v = data.get(i);
xs[i] = x;
ys[i] = imageHeight - 3 - (int) ((v - limits.lower()) / d);
}
g.drawPolyline(xs, ys, data.size());
if (hasMin) {
final int i = data.indexOf(Collections.min(data));
g.setColor(minColor);
g.fillRect(xs[i] - step / 2, ys[i] - step / 2, step, step);
}
if (hasMax) {
final int i = data.indexOf(Collections.max(data));
g.setColor(maxColor);
g.fillRect(xs[i] - step / 2, ys[i] - step / 2, step, step);
}
if (hasMax) {
g.setColor(lastColor);
g.fillRect(xs[xs.length - 1] - step / 2, ys[ys.length - 1] - step / 2, step, step);
}
return Response.ok(image).tag(tag).build();
}
Aggregations