Package org.jboss.resteasy.core

Examples of org.jboss.resteasy.core.ResourceMethod


      List<ResourceInvoker> invokers = entry.getValue();
      for (ResourceInvoker invoker : invokers)
      {
        if (invoker instanceof ResourceMethod)
        {
          ResourceMethod resourceMethod = (ResourceMethod)invoker;
          Method method = resourceMethod.getMethod();
          results.add(method);
        } else
        {
          // TODO: fix this?
        }
View Full Code Here


            Iterator<ResourceMethod> it = node.methods.iterator();
            try
            {
               while (it.hasNext())
               {
                  ResourceMethod invoker = it.next();
                  if (invoker.getMethod().equals(method))
                  {
                     it.remove();
                     return invoker;
                  }

               }
            }
            finally
            {
               if (node.isEmpty())
               {
                  PathParamSegment seg = resourceExpressions.remove(expression);
                  if (seg != null) sortedResourceExpressions.remove(seg);
               }
            }
         }
      }
      else
      {
         SimpleSegment segmentNode = simpleSegments.get(segment);
         if (segmentNode == null)
         {
            return null;
         }
         if (segments.length > index + 1)
         {
            try
            {
               return segmentNode.removePath(segments, index + 1, method);
            }
            finally
            {
               if (segmentNode.isEmpty()) simpleSegments.remove(segment);
            }
         }
         else
         {
            try
            {
               if (isLocator(method))
               {
                  ResourceLocator loc = segmentNode.locator;
                  segmentNode.locator = null;
                  return loc;
               }
               else
               {
                  Iterator<ResourceMethod> it = segmentNode.methods.iterator();
                  while (it.hasNext())
                  {
                     ResourceMethod invoker = it.next();
                     if (invoker.getMethod().equals(method))
                     {
                        it.remove();
                        return invoker;
                     }
View Full Code Here

         ResourceInvoker removed = null;
         for (ResourceInvoker invoker : list)
         {
            if (invoker instanceof ResourceMethod)
            {
               ResourceMethod rm = (ResourceMethod) invoker;
               if (rm.getMethod().equals(method))
               {
                  removed = rm;
                  break;
               }
            }
View Full Code Here

      MediaType contentType = new MediaType("text", "plain");

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/foo"));
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(WebResource.class.getMethod("doGetFoo"), method.getMethod());
      }

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/foo;q=0.1"));
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(WebResource.class.getMethod("doGetFoo"), method.getMethod());
      }

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/foo"));
         accepts.add(MediaType.valueOf("application/bar;q=0.4"));
         accepts.add(MediaType.valueOf("application/baz;q=0.2"));
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(WebResource.class.getMethod("doGetFoo"), method.getMethod());
      }

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/foo;q=0.4"));
         accepts.add(MediaType.valueOf("application/bar"));
         accepts.add(MediaType.valueOf("application/baz;q=0.2"));
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(WebResource.class.getMethod("doGetBar"), method.getMethod());
      }

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/foo;q=0.4"));
         accepts.add(MediaType.valueOf("application/bar;q=0.2"));
         accepts.add(MediaType.valueOf("application/baz"));
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(WebResource.class.getMethod("doGetBaz"), method.getMethod());
      }
   }
View Full Code Here

      MediaType contentType = MediaType.valueOf("application/xml;schema=bar");

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("PUT", "/xml", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(XmlResource.class.getMethod("putBar", String.class), method.getMethod());
      }
   }
View Full Code Here

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/xml;schema=junk;q=1.0"));
         accepts.add(MediaType.valueOf("application/xml;schema=stuff;q=0.5"));
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("PUT", "/xml", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(XmlResource2.class.getMethod("putBar", String.class), method.getMethod());
      }
   }
View Full Code Here

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/xml;schema=junk;q=1.0"));
         accepts.add(MediaType.valueOf("application/xml;schema=stuff;q=0.5"));
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("PUT", "/xml", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(XmlResource2.class.getMethod("put", String.class), method.getMethod());
      }
   }
View Full Code Here

         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/wildcard"));
         accepts.add(MediaType.valueOf("application/foo;q=0.6"));
         accepts.add(MediaType.valueOf("application/bar;q=0.4"));
         accepts.add(MediaType.valueOf("application/baz;q=0.2"));
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(WebResource.class.getMethod("doGetWildCard"), method.getMethod());
      }
   }
View Full Code Here

      MediaType bar = MediaType.valueOf("application/bar");

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(foo);
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(MultipleResource.class.getMethod("get"), method.getMethod());
      }
      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(bar);
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(MultipleResource.class.getMethod("get"), method.getMethod());
      }
      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("*/*"));
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(MultipleResource.class.getMethod("get"), method.getMethod());
      }
      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/*"));
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(MultipleResource.class.getMethod("get"), method.getMethod());
      }
   }
View Full Code Here

      registry.addPerRequestResource(ConsumeResource.class);

      ArrayList<MediaType> accepts = new ArrayList<MediaType>();

      {
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", MediaType.valueOf("text/plain"), accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(ConsumeResource.class.getMethod("doGetWildCard"), method.getMethod());
      }
      {
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", MediaType.valueOf("application/foo"), accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(ConsumeResource.class.getMethod("doGetFoo"), method.getMethod());
      }
      {
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", MediaType.valueOf("application/bar"), accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(ConsumeResource.class.getMethod("doGetBar"), method.getMethod());
      }
      {
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", MediaType.valueOf("application/baz"), accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(ConsumeResource.class.getMethod("doGetBaz"), method.getMethod());
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.core.ResourceMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.