public static List<Method> getServiceMethods(ResourceMethodRegistry registry){ ArrayList<Method> results = new ArrayList<Method>(); for (Entry<String, List<ResourceInvoker>> entry : registry.getBounded().entrySet()) { List<ResourceInvoker> invokers = entry.getValue(); for (ResourceInvoker invoker : invokers) { if (invoker instanceof ResourceMethodInvoker) { ResourceMethodInvoker resourceMethod = (ResourceMethodInvoker)invoker; Method method = resourceMethod.getMethod(); results.add(method); } else { // TODO: fix this? } } } return results; }
private String[] getStreamType(ResourceMethodInvoker method) { Stream stream = method.getMethod().getAnnotation(Stream.class); Stream.MODE mode = stream != null ? stream.value() : null; if (mode == null) { return new String[]{"text", "event-stream"}; } else if (Stream.MODE.GENERAL.equals(mode)) { return new String[] {"application", "x-stream-general"}; } else if (Stream.MODE.RAW.equals(mode)) { return new String[] {"application", "x-stream-raw"}; } throw new RuntimeException(Messages.MESSAGES.expectedStreamModeGeneralOrRaw(mode)); }
boolean hasProduces = chosen != null && Boolean.valueOf(chosen.getParameters().get(SegmentNode.RESTEASY_SERVER_HAS_PRODUCES)); hasProduces |= method != null && method.getProduces() != null && method.getProduces().length > 0; hasProduces |= method != null && method.getMethod().getClass().getAnnotation(Produces.class) != null; String[] producesValues = method.getMethod().getClass().getAnnotation(Produces.class).value(); produces = new MediaType[producesValues.length]; for (int i = 0; i < producesValues.length; i++) if (generic == null) if (method != null && !Response.class.isAssignableFrom(method.getMethod().getReturnType())) generic = method.getGenericReturnType(); else generic = type;
public ResteasyWadlMethodMetaData(final ResteasyWadlServiceRegistry serviceRegistry, final ResourceMethodInvoker resourceInvoker) { this.registry = serviceRegistry; this.resourceInvoker = resourceInvoker; this.method = resourceInvoker.getMethod(); this.klass = resourceInvoker.getResourceClass(); Path methodPath = method.getAnnotation(Path.class);
Produces produces = method.getMethod().getAnnotation(Produces.class); if (produces != null && contains(produces.value(), MediaType.SERVER_SENT_EVENTS)) SseElementType sseElementType = method.getMethod().getAnnotation(SseElementType.class); if (sseElementType != null) Stream stream = method.getMethod().getAnnotation(Stream.class); if (stream != null)
public MethodMetaData(final ServiceRegistry serviceRegistry, final ResourceMethodInvoker invoker) throws Exception { this.registry = serviceRegistry; this.invoker = invoker; this.method = invoker.getMethod();
public static AsyncResponseConsumer makeAsyncResponseConsumer(ResourceMethodInvoker method, AsyncStreamProvider<?> asyncStreamProvider) { if(method.isSse()) { return new AsyncGeneralStreamingSseResponseConsumer(method, asyncStreamProvider); } Stream stream = method.getMethod().getAnnotation(Stream.class); if (stream != null) { if (Stream.MODE.RAW.equals(stream.value())) { return new AsyncRawStreamingResponseConsumer(method, asyncStreamProvider); } else { return new AsyncGeneralStreamingSseResponseConsumer(method, asyncStreamProvider); } } return new AsyncStreamCollectorResponseConsumer(method, asyncStreamProvider); }
method.setMethod(rm.getMethod().getName()); AtomicLong stat = rm.getStats().get(httpMethod); if (stat != null) method.setInvocations(stat.longValue());
@Override public void filter(ContainerRequestContext requestContext) throws IOException { Method method = ((PostMatchContainerRequestContext) requestContext).getResourceMethod().getMethod(); Stream stream = method.getAnnotation(Stream.class); Stream.MODE mode = stream != null ? stream.value() : null; Class<?> clazz = method.getReturnType(); if ((mode == Stream.MODE.GENERAL && ResteasyProviderFactory.getInstance().getAsyncStreamProvider(clazz) != null) || requestContext instanceof PostMatchContainerRequestContext && ((PostMatchContainerRequestContext) requestContext).getResourceMethod().isSse()) { SseEventOutputImpl sink = new SseEventOutputImpl(new SseEventProvider()); ResteasyContext.getContextDataMap().put(SseEventSink.class, sink); ResteasyContext.getContextData(PostResourceMethodInvokers.class).addInvokers(new PostResourceMethodInvoker() { @Override public void invoke() { sink.flushResponseToClient(); } }); } }
ResourceMethodInvoker methodInvoker = (ResourceMethodInvoker) requestContext.getProperty("org.jboss.resteasy.core.ResourceMethodInvoker"); Method method = methodInvoker.getMethod();
Stream[] streams = method.getMethod().getAnnotationsByType(Stream.class); if (streams.length > 0)
private boolean isBridgeRequired(final ContainerRequestContext requestContext) { final ResourceMethodInvoker methodInvoker = (ResourceMethodInvoker) requestContext.getProperty("org.jboss.resteasy.core.ResourceMethodInvoker"); if (methodInvoker == null) { return false; } Method method = methodInvoker.getMethod(); return method.isAnnotationPresent(Transactional.class) || method.isAnnotationPresent(TransactionAttribute.class) || method.getDeclaringClass().isAnnotationPresent(Transactional.class) || method.getDeclaringClass().isAnnotationPresent(TransactionAttribute.class); }
import org.jboss.resteasy.core.ResourceMethodInvoker; public class MyRequestFilter implements ContainerRequestFilter { public void filter(ContainerRequestContext request) throws IOException { String propName = "org.jboss.resteasy.core.ResourceMethodInvoker"; ResourceMethodInvoker invoker = (ResourceMethodInvoker)request.getProperty(); invoker.getMethod().getParameterTypes().... } }
private String formatMethod(ResourceMethodInvoker resource, String servletMapping, String path, String contextRootPath) { StringBuilder builder = new StringBuilder(); builder.append("%1$s "); String servletPath = servletMapping.replaceAll("\\*", ""); if(servletPath.charAt(0) == '/') { servletPath = servletPath.substring(1); } builder.append(contextRootPath).append('/').append(servletPath).append(path); builder.append(" - ").append(resource.getResourceClass().getCanonicalName()).append('.').append(resource.getMethod().getName()).append('('); if (resource.getMethod().getParameterTypes().length > 0) { builder.append("..."); } builder.append(')'); return builder.toString().replaceAll("//", "/"); }
private String formatMethod(ResourceMethodInvoker resource, String servletMapping, String path, String contextRootPath) { StringBuilder builder = new StringBuilder(); builder.append("%1$s "); String servletPath = servletMapping.replaceAll("\\*", ""); if(servletPath.charAt(0) == '/') { servletPath = servletPath.substring(1); } builder.append(contextRootPath).append('/').append(servletPath).append(path); builder.append(" - ").append(resource.getResourceClass().getCanonicalName()).append('.').append(resource.getMethod().getName()).append('('); if (resource.getMethod().getParameterTypes().length > 0) { builder.append("..."); } builder.append(')'); return builder.toString().replaceAll("//", "/"); }
private JaxrsResourceMethodDescription resMethodDescription(ResourceMethodInvoker methodInvoker, String contextPath, String mapping, Collection<String> servletMappings) { JaxrsResourceMethodDescription jaxrsRes = new JaxrsResourceMethodDescription(); jaxrsRes.consumeTypes = methodInvoker.getConsumes(); jaxrsRes.contextPath = contextPath; jaxrsRes.httpMethods = methodInvoker.getHttpMethods(); jaxrsRes.method = methodInvoker.getMethod(); jaxrsRes.produceTypes = methodInvoker.getProduces(); jaxrsRes.resourceClass = methodInvoker.getResourceClass(); jaxrsRes.resourcePath = mapping; jaxrsRes.servletMappings = servletMappings; addMethodParameters(jaxrsRes, methodInvoker.getMethod()); return jaxrsRes; }
private JaxrsResourceMethodDescription resMethodDescription(ResourceMethodInvoker methodInvoker, String contextPath, String mapping, Collection<String> servletMappings) { JaxrsResourceMethodDescription jaxrsRes = new JaxrsResourceMethodDescription(); jaxrsRes.consumeTypes = methodInvoker.getConsumes(); jaxrsRes.contextPath = contextPath; jaxrsRes.httpMethods = methodInvoker.getHttpMethods(); jaxrsRes.method = methodInvoker.getMethod(); jaxrsRes.produceTypes = methodInvoker.getProduces(); jaxrsRes.resourceClass = methodInvoker.getResourceClass(); jaxrsRes.resourcePath = mapping; jaxrsRes.servletMappings = servletMappings; addMethodParameters(jaxrsRes, methodInvoker.getMethod()); return jaxrsRes; }
private String[] getStreamType(ResourceMethodInvoker method) { Stream stream = method.getMethod().getAnnotation(Stream.class); Stream.MODE mode = stream != null ? stream.value() : null; if (mode == null) { return new String[]{"text", "event-stream"}; } else if (Stream.MODE.GENERAL.equals(mode)) { return new String[] {"application", "x-stream-general"}; } else if (Stream.MODE.RAW.equals(mode)) { return new String[] {"application", "x-stream-raw"}; } throw new RuntimeException(Messages.MESSAGES.expectedStreamModeGeneralOrRaw(mode)); }